Bug 1937228 - pg_activity fails to build with Python 3.10: AttributeError: 'dict' object has no attribute 'bytes'
Summary: pg_activity fails to build with Python 3.10: AttributeError: 'dict' object ha...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: pg_activity
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Mikel Olasagasti Uranga
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.10
TreeView+ depends on / blocked
 
Reported: 2021-03-10 08:08 UTC by Tomáš Hrnčiar
Modified: 2021-03-19 20:13 UTC (History)
3 users (show)

Fixed In Version: pg_activity-2.1.2-1.fc34
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-03-12 20:23:01 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Tomáš Hrnčiar 2021-03-10 08:08:07 UTC
pg_activity fails to build with Python 3.10.0a6.

=================================== FAILURES ===================================
__________________ [doctest] pgactivity.types.Deserializable ___________________
041 
042     >>> @attr.s(auto_attribs=True)
043     ... class Line(Deserializable):
044     ...     start: Point
045     ...     end: Point
046     ...     color: str = "black"
047     ...     label: Optional[str] = None
048 
049     >>> data = {"start": {"x": 1, "y": 1}, "end": {"x": 2, "y": 2, "label": "p2"}}
050     >>> Line.deserialize(data)
Expected:
    Line(start=Point(x=1, y=1, label=None), end=Point(x=2, y=2, label='p2'), color='black', label=None)
Got:
    Line(start={'x': 1, 'y': 1}, end={'x': 2, 'y': 2, 'label': 'p2'}, color='black', label=None)

/builddir/build/BUILD/pg_activity-2.1.0/pgactivity/types.py:50: DocTestFailure
_______________________ [doctest] pgactivity.types.Flag ________________________
138 Column flag.
139 
140     >>> f = Flag(3)
141     >>> f
Expected:
    <Flag.APPNAME|DATABASE: 3>
Got:
    <Flag.DATABASE|APPNAME: 3>

/builddir/build/BUILD/pg_activity-2.1.0/pgactivity/types.py:141: DocTestFailure
_________________ [doctest] pgactivity.types.Flag.from_options _________________
194         ... 'nodb': False,
195         ... 'nomem': False,
196         ... 'nopid': False,
197         ... 'noread': False,
198         ... 'notime': False,
199         ... 'nouser': False,
200         ... 'nowait': False,
201         ... 'nowrite': False,
202         ... }
203         >>> Flag.from_options(is_local=True, **options)
Expected:
    <Flag.PID|IOWAIT|MODE|TYPE|RELATION|WAIT|TIME|WRITE|READ|MEM|CPU|USER|CLIENT|APPNAME|DATABASE: 32767>
Got:
    <Flag.DATABASE|APPNAME|CLIENT|USER|CPU|MEM|READ|WRITE|TIME|WAIT|RELATION|TYPE|MODE|IOWAIT|PID: 32767>

/builddir/build/BUILD/pg_activity-2.1.0/pgactivity/types.py:203: DocTestFailure
_______________________________ test_ps_complete _______________________________

system_processes = ([RunningProcess(pid=6221, application_name='pgbench', database='pgbench', user='postgres', client='local', duration=-...0.0, cpu_times=[0.27, 0.05, 0, 0, 0.07], read_delta=0.0, write_delta=0.0, io_wait=False, psutil_proc=None), ...}, 4096)

    def test_ps_complete(system_processes):
        pg_processes, system_procs, new_system_procs, fs_blocksize = system_processes
    
        def sys_get_proc(pid):
            return new_system_procs.pop(pid, None)
    
        n_system_procs = len(system_procs)
    
        with patch("pgactivity.activities.sys_get_proc", new=sys_get_proc):
>           procs, io_read, io_write = activities.ps_complete(
                pg_processes, system_procs, fs_blocksize
            )

tests/test_activities.py:58: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

pg_processes = [RunningProcess(pid=6221, application_name='pgbench', database='pgbench', user='postgres', client='local', duration=-0...postgres', client='local', duration=-0.002623, state='active', query='END;', wait=True, is_parallel_worker=False), ...]
processes = {6221: SystemProcess(meminfo=[63885312, 219631616, 61571072, 4608000, 0, 2908160, 0], io_read={'bytes': 163840, 'chars...ercent=0.0, cpu_times=[0.23, 0.08, 0, 0, 0.03], read_delta=0.0, write_delta=0.0, io_wait=False, psutil_proc=None), ...}
fs_blocksize = 4096

    def ps_complete(
        pg_processes: Sequence[RunningProcess],
        processes: Dict[int, SystemProcess],
        fs_blocksize: int,
    ) -> Tuple[List[LocalRunningProcess], IOCounter, IOCounter]:
        """Transform the sequence of 'pg_processes' (RunningProcess) as LocalRunningProcess
        with local system information from the 'processes' map. Return LocalRunningProcess
        list, as well as read and write IO counters.
    
        The 'processes' map is updated in place.
        """
        local_procs = []
        read_bytes_delta = 0.0
        write_bytes_delta = 0.0
        read_count_delta = 0
        write_count_delta = 0
        n_io_time = time.time()
        for pg_proc in pg_processes:
            pid = pg_proc.pid
            new_proc = sys_get_proc(pid)
            if new_proc is None:
                continue
            try:
                # Getting informations from the previous loop
                proc = processes[pid]
            except KeyError:
                # No previous information about this process
                proc = new_proc
            else:
                # Update old process with new informations
                mem_percent = proc.mem_percent
                cpu_percent = proc.cpu_percent
                if proc.psutil_proc is not None:
                    try:
                        mem_percent = proc.psutil_proc.memory_percent()
                        cpu_percent = proc.psutil_proc.cpu_percent(interval=0)
                    except (psutil.NoSuchProcess, psutil.AccessDenied):
                        pass
                proc = attr.evolve(
                    proc,
                    io_wait=new_proc.io_wait,
                    read_delta=(
>                       (new_proc.io_read.bytes - proc.io_read.bytes)
                        / (n_io_time - proc.io_time)
                    ),
                    write_delta=(
                        (new_proc.io_write.bytes - proc.io_write.bytes)
                        / (n_io_time - proc.io_time)
                    ),
                    io_read=new_proc.io_read,
                    io_write=new_proc.io_write,
                    io_time=n_io_time,
                    mem_percent=mem_percent,
                    cpu_percent=cpu_percent,
                )
E               AttributeError: 'dict' object has no attribute 'bytes'

pgactivity/activities.py:101: AttributeError
=========================== short test summary info ============================
FAILED pgactivity/types.py::pgactivity.types.Deserializable
FAILED pgactivity/types.py::pgactivity.types.Flag
FAILED pgactivity/types.py::pgactivity.types.Flag.from_options
FAILED tests/test_activities.py::test_ps_complete - AttributeError: 'dict' ob...
================== 4 failed, 40 passed, 1 deselected in 0.37s ==================

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.10/fedora-rawhide-x86_64/02060798-pg_activity/

For all our attempts to build pg_activity with Python 3.10, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.10/package/pg_activity/

Testing and mass rebuild of packages is happening in copr. You can follow these instructions to test locally in mock if your package builds with Python 3.10:
https://copr.fedorainfracloud.org/coprs/g/python/python3.10/

Let us know here if you have any questions.

Python 3.10 will be included in Fedora 35. To make that update smoother, we're building Fedora packages with early pre-releases of Python 3.10.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires), so if this package is required a lot, it's important for us to get it fixed soon.
We'd appreciate help from the people who know this package best, but if you don't want to work on this now, let us know so we can try to work around it on our side.

Comment 1 Fedora Update System 2021-03-12 16:08:15 UTC
FEDORA-2021-a95c597518 has been submitted as an update to Fedora 34. https://bodhi.fedoraproject.org/updates/FEDORA-2021-a95c597518

Comment 2 Fedora Update System 2021-03-12 18:57:09 UTC
FEDORA-2021-a95c597518 has been pushed to the Fedora 34 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2021-a95c597518`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2021-a95c597518

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 3 Mikel Olasagasti Uranga 2021-03-12 20:23:01 UTC
Fixed upstream and released 2.1.2 with the fix, already in rawhide.

https://github.com/dalibo/pg_activity/pull/193

Comment 4 Fedora Update System 2021-03-19 20:13:49 UTC
FEDORA-2021-a95c597518 has been pushed to the Fedora 34 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.