Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/134794/?format=api
http://patches.dpdk.org/api/patches/134794/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20231204102429.106709-7-juraj.linkes@pantheon.tech/", "project": { "id": 1, "url": "http://patches.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<20231204102429.106709-7-juraj.linkes@pantheon.tech>", "list_archive_url": "https://inbox.dpdk.org/dev/20231204102429.106709-7-juraj.linkes@pantheon.tech", "date": "2023-12-04T10:24:14", "name": "[v9,06/21] dts: logger and utils docstring update", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": true, "hash": "ab5572e22d343fc042005d916f4ac60fe54d8287", "submitter": { "id": 1626, "url": "http://patches.dpdk.org/api/people/1626/?format=api", "name": "Juraj Linkeš", "email": "juraj.linkes@pantheon.tech" }, "delegate": { "id": 1, "url": "http://patches.dpdk.org/api/users/1/?format=api", "username": "tmonjalo", "first_name": "Thomas", "last_name": "Monjalon", "email": "thomas@monjalon.net" }, "mbox": "http://patches.dpdk.org/project/dpdk/patch/20231204102429.106709-7-juraj.linkes@pantheon.tech/mbox/", "series": [ { "id": 30441, "url": "http://patches.dpdk.org/api/series/30441/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=30441", "date": "2023-12-04T10:24:08", "name": "dts: docstrings update", "version": 9, "mbox": "http://patches.dpdk.org/series/30441/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/134794/comments/", "check": "success", "checks": "http://patches.dpdk.org/api/patches/134794/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@inbox.dpdk.org", "Delivered-To": "patchwork@inbox.dpdk.org", "Received": [ "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 9B7C54366A;\n\tMon, 4 Dec 2023 11:25:19 +0100 (CET)", "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id E5B1841101;\n\tMon, 4 Dec 2023 11:24:40 +0100 (CET)", "from mail-wm1-f50.google.com (mail-wm1-f50.google.com\n [209.85.128.50]) by mails.dpdk.org (Postfix) with ESMTP id 7CC3340DF5\n for <dev@dpdk.org>; Mon, 4 Dec 2023 11:24:37 +0100 (CET)", "by mail-wm1-f50.google.com with SMTP id\n 5b1f17b1804b1-40c09f4bea8so9309595e9.1\n for <dev@dpdk.org>; Mon, 04 Dec 2023 02:24:37 -0800 (PST)", "from jlinkes-PT-Latitude-5530.pantheon.local ([81.89.53.154])\n by smtp.gmail.com with ESMTPSA id\n m28-20020a05600c3b1c00b0040b2b38a1fasm14255415wms.4.2023.12.04.02.24.36\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Mon, 04 Dec 2023 02:24:36 -0800 (PST)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=pantheon.tech; s=google; t=1701685477; x=1702290277; darn=dpdk.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=HwU+LFHRLrk+IQzVJORkHjCvcMai8+Em9v6JYz1n0S0=;\n b=s7SGDW2RSWesA5wtzCjFs2UTLxXeMGfxp4A60QmL5IOUAsaE3ePw/vPBcJIbunOaZx\n +l3ixCDWWDBJBU9wm9uulbqIqCvFQtwVuNgn1Wt0X4WirEf7f+93g3Nn4ZDZJGouoxc7\n 5DRLCKlKrZVr8RopQztfTAv2mdp00g/44vx4QC75gGGq09D9ms9rE1wql1lsv45OBMoP\n q3we0vBMkOwrOMaaqZgmAxkRQzPUpqDmPxBW/lpGa0felFRBw7p0wlPy+cPRF3CkWJvb\n c6KNL8rG+W+1GZGpFq88z9UuZNl2RrU6ur+KSPP0i1vBLmjAxRJViYjTG9nLUMu79JkE\n 63lw==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1701685477; x=1702290277;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n :subject:date:message-id:reply-to;\n bh=HwU+LFHRLrk+IQzVJORkHjCvcMai8+Em9v6JYz1n0S0=;\n b=FpHEFWsLStztLpHpGT7d7grwHo0ui9btg0HRphRsmvG0WNNJKspwuDs9Ky+JOqIGeJ\n mHFRmbGCB0qUjiU9Ec/dMGOhh9X/76NFOfcrqZfcJ7KM33iTlm5PeX1KuWbVN80zUAPj\n vRKLTG4rz+8/N2u10MLkIssdZreKTPfNGjF79TwE2LWwEYgJbX21KdEk+mWJrfIDcGqc\n wIYcprn1NcPJijz9XpKcUFGEhZiOLe6VSxthpmTEIbNearM9g10PHM8bW1z1doRF4i8s\n YzlkAUFjt8hRZ9C0j9HguZhUpAO9xTKejV/gJidpg/nB6HAIKzoMmbmN6CVTSSIAWfiz\n lf7A==", "X-Gm-Message-State": "AOJu0Yw+klItUfYzo1T2lg8sjOYc0jV1/FTwiyJiyvaTplvQDLtmox/L\n sqcOad4W6NOHB9nd6swvIzq7Vg==", "X-Google-Smtp-Source": "\n AGHT+IH1uVgmitNN/f45TtEPbXCCaRsP+Bt+rTSvE+GJ6LCmiPXQkK97jxPHMCb/yoNKsa5NAVLMpg==", "X-Received": "by 2002:a05:600c:46c7:b0:40b:35aa:bfdd with SMTP id\n q7-20020a05600c46c700b0040b35aabfddmr2209558wmo.27.1701685477142;\n Mon, 04 Dec 2023 02:24:37 -0800 (PST)", "From": "=?utf-8?q?Juraj_Linke=C5=A1?= <juraj.linkes@pantheon.tech>", "To": "thomas@monjalon.net, Honnappa.Nagarahalli@arm.com, jspewock@iol.unh.edu,\n probb@iol.unh.edu, paul.szczepanek@arm.com, yoan.picchi@foss.arm.com,\n Luca.Vizzarro@arm.com", "Cc": "dev@dpdk.org, =?utf-8?q?Juraj_Linke=C5=A1?= <juraj.linkes@pantheon.tech>", "Subject": "[PATCH v9 06/21] dts: logger and utils docstring update", "Date": "Mon, 4 Dec 2023 11:24:14 +0100", "Message-Id": "<20231204102429.106709-7-juraj.linkes@pantheon.tech>", "X-Mailer": "git-send-email 2.34.1", "In-Reply-To": "<20231204102429.106709-1-juraj.linkes@pantheon.tech>", "References": "<20231123151344.162812-1-juraj.linkes@pantheon.tech>\n <20231204102429.106709-1-juraj.linkes@pantheon.tech>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://mails.dpdk.org/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org" }, "content": "Format according to the Google format and PEP257, with slight\ndeviations.\n\nSigned-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>\n---\n dts/framework/logger.py | 72 ++++++++++++++++++++++-----------\n dts/framework/utils.py | 88 +++++++++++++++++++++++++++++------------\n 2 files changed, 113 insertions(+), 47 deletions(-)", "diff": "diff --git a/dts/framework/logger.py b/dts/framework/logger.py\nindex bb2991e994..cfa6e8cd72 100644\n--- a/dts/framework/logger.py\n+++ b/dts/framework/logger.py\n@@ -3,9 +3,9 @@\n # Copyright(c) 2022-2023 PANTHEON.tech s.r.o.\n # Copyright(c) 2022-2023 University of New Hampshire\n \n-\"\"\"\n-DTS logger module with several log level. DTS framework and TestSuite logs\n-are saved in different log files.\n+\"\"\"DTS logger module.\n+\n+DTS framework and TestSuite logs are saved in different log files.\n \"\"\"\n \n import logging\n@@ -18,19 +18,21 @@\n stream_fmt = \"%(asctime)s - %(name)s - %(levelname)s - %(message)s\"\n \n \n-class LoggerDictType(TypedDict):\n- logger: \"DTSLOG\"\n- name: str\n- node: str\n-\n+class DTSLOG(logging.LoggerAdapter):\n+ \"\"\"DTS logger adapter class for framework and testsuites.\n \n-# List for saving all using loggers\n-Loggers: list[LoggerDictType] = []\n+ The :option:`--verbose` command line argument and the :envvar:`DTS_VERBOSE` environment\n+ variable control the verbosity of output. If enabled, all messages will be emitted to the\n+ console.\n \n+ The :option:`--output` command line argument and the :envvar:`DTS_OUTPUT_DIR` environment\n+ variable modify the directory where the logs will be stored.\n \n-class DTSLOG(logging.LoggerAdapter):\n- \"\"\"\n- DTS log class for framework and testsuite.\n+ Attributes:\n+ node: The additional identifier. Currently unused.\n+ sh: The handler which emits logs to console.\n+ fh: The handler which emits logs to a file.\n+ verbose_fh: Just as fh, but logs with a different, more verbose, format.\n \"\"\"\n \n _logger: logging.Logger\n@@ -40,6 +42,15 @@ class DTSLOG(logging.LoggerAdapter):\n verbose_fh: logging.FileHandler\n \n def __init__(self, logger: logging.Logger, node: str = \"suite\"):\n+ \"\"\"Extend the constructor with additional handlers.\n+\n+ One handler logs to the console, the other one to a file, with either a regular or verbose\n+ format.\n+\n+ Args:\n+ logger: The logger from which to create the logger adapter.\n+ node: An additional identifier. Currently unused.\n+ \"\"\"\n self._logger = logger\n # 1 means log everything, this will be used by file handlers if their level\n # is not set\n@@ -92,26 +103,43 @@ def __init__(self, logger: logging.Logger, node: str = \"suite\"):\n super(DTSLOG, self).__init__(self._logger, dict(node=self.node))\n \n def logger_exit(self) -> None:\n- \"\"\"\n- Remove stream handler and logfile handler.\n- \"\"\"\n+ \"\"\"Remove the stream handler and the logfile handler.\"\"\"\n for handler in (self.sh, self.fh, self.verbose_fh):\n handler.flush()\n self._logger.removeHandler(handler)\n \n \n+class _LoggerDictType(TypedDict):\n+ logger: DTSLOG\n+ name: str\n+ node: str\n+\n+\n+# List for saving all loggers in use\n+_Loggers: list[_LoggerDictType] = []\n+\n+\n def getLogger(name: str, node: str = \"suite\") -> DTSLOG:\n+ \"\"\"Get DTS logger adapter identified by name and node.\n+\n+ An existing logger will be returned if one with the exact name and node already exists.\n+ A new one will be created and stored otherwise.\n+\n+ Args:\n+ name: The name of the logger.\n+ node: An additional identifier for the logger.\n+\n+ Returns:\n+ A logger uniquely identified by both name and node.\n \"\"\"\n- Get logger handler and if there's no handler for specified Node will create one.\n- \"\"\"\n- global Loggers\n+ global _Loggers\n # return saved logger\n- logger: LoggerDictType\n- for logger in Loggers:\n+ logger: _LoggerDictType\n+ for logger in _Loggers:\n if logger[\"name\"] == name and logger[\"node\"] == node:\n return logger[\"logger\"]\n \n # return new logger\n dts_logger: DTSLOG = DTSLOG(logging.getLogger(name), node)\n- Loggers.append({\"logger\": dts_logger, \"name\": name, \"node\": node})\n+ _Loggers.append({\"logger\": dts_logger, \"name\": name, \"node\": node})\n return dts_logger\ndiff --git a/dts/framework/utils.py b/dts/framework/utils.py\nindex a0f2173949..cc5e458cc8 100644\n--- a/dts/framework/utils.py\n+++ b/dts/framework/utils.py\n@@ -3,6 +3,16 @@\n # Copyright(c) 2022-2023 PANTHEON.tech s.r.o.\n # Copyright(c) 2022-2023 University of New Hampshire\n \n+\"\"\"Various utility classes and functions.\n+\n+These are used in multiple modules across the framework. They're here because\n+they provide some non-specific functionality, greatly simplify imports or just don't\n+fit elsewhere.\n+\n+Attributes:\n+ REGEX_FOR_PCI_ADDRESS: The regex representing a PCI address, e.g. ``0000:00:08.0``.\n+\"\"\"\n+\n import atexit\n import json\n import os\n@@ -19,12 +29,20 @@\n \n \n def expand_range(range_str: str) -> list[int]:\n- \"\"\"\n- Process range string into a list of integers. There are two possible formats:\n- n - a single integer\n- n-m - a range of integers\n+ \"\"\"Process `range_str` into a list of integers.\n+\n+ There are two possible formats of `range_str`:\n+\n+ * ``n`` - a single integer,\n+ * ``n-m`` - a range of integers.\n \n- The returned range includes both n and m. Empty string returns an empty list.\n+ The returned range includes both ``n`` and ``m``. Empty string returns an empty list.\n+\n+ Args:\n+ range_str: The range to expand.\n+\n+ Returns:\n+ All the numbers from the range.\n \"\"\"\n expanded_range: list[int] = []\n if range_str:\n@@ -37,6 +55,14 @@ def expand_range(range_str: str) -> list[int]:\n \n \n def get_packet_summaries(packets: list[Packet]) -> str:\n+ \"\"\"Format a string summary from `packets`.\n+\n+ Args:\n+ packets: The packets to format.\n+\n+ Returns:\n+ The summary of `packets`.\n+ \"\"\"\n if len(packets) == 1:\n packet_summaries = packets[0].summary()\n else:\n@@ -45,27 +71,36 @@ def get_packet_summaries(packets: list[Packet]) -> str:\n \n \n class StrEnum(Enum):\n+ \"\"\"Enum with members stored as strings.\"\"\"\n+\n @staticmethod\n def _generate_next_value_(name: str, start: int, count: int, last_values: object) -> str:\n return name\n \n def __str__(self) -> str:\n+ \"\"\"The string representation is the name of the member.\"\"\"\n return self.name\n \n \n class MesonArgs(object):\n- \"\"\"\n- Aggregate the arguments needed to build DPDK:\n- default_library: Default library type, Meson allows \"shared\", \"static\" and \"both\".\n- Defaults to None, in which case the argument won't be used.\n- Keyword arguments: The arguments found in meson_options.txt in root DPDK directory.\n- Do not use -D with them, for example:\n- meson_args = MesonArgs(enable_kmods=True).\n- \"\"\"\n+ \"\"\"Aggregate the arguments needed to build DPDK.\"\"\"\n \n _default_library: str\n \n def __init__(self, default_library: str | None = None, **dpdk_args: str | bool):\n+ \"\"\"Initialize the meson arguments.\n+\n+ Args:\n+ default_library: The default library type, Meson supports ``shared``, ``static`` and\n+ ``both``. Defaults to :data:`None`, in which case the argument won't be used.\n+ dpdk_args: The arguments found in ``meson_options.txt`` in root DPDK directory.\n+ Do not use ``-D`` with them.\n+\n+ Example:\n+ ::\n+\n+ meson_args = MesonArgs(enable_kmods=True).\n+ \"\"\"\n self._default_library = f\"--default-library={default_library}\" if default_library else \"\"\n self._dpdk_args = \" \".join(\n (\n@@ -75,6 +110,7 @@ def __init__(self, default_library: str | None = None, **dpdk_args: str | bool):\n )\n \n def __str__(self) -> str:\n+ \"\"\"The actual args.\"\"\"\n return \" \".join(f\"{self._default_library} {self._dpdk_args}\".split())\n \n \n@@ -96,24 +132,14 @@ class _TarCompressionFormat(StrEnum):\n \n \n class DPDKGitTarball(object):\n- \"\"\"Create a compressed tarball of DPDK from the repository.\n-\n- The DPDK version is specified with git object git_ref.\n- The tarball will be compressed with _TarCompressionFormat,\n- which must be supported by the DTS execution environment.\n- The resulting tarball will be put into output_dir.\n+ \"\"\"Compressed tarball of DPDK from the repository.\n \n- The class supports the os.PathLike protocol,\n+ The class supports the :class:`os.PathLike` protocol,\n which is used to get the Path of the tarball::\n \n from pathlib import Path\n tarball = DPDKGitTarball(\"HEAD\", \"output\")\n tarball_path = Path(tarball)\n-\n- Arguments:\n- git_ref: A git commit ID, tag ID or tree ID.\n- output_dir: The directory where to put the resulting tarball.\n- tar_compression_format: The compression format to use.\n \"\"\"\n \n _git_ref: str\n@@ -128,6 +154,17 @@ def __init__(\n output_dir: str,\n tar_compression_format: _TarCompressionFormat = _TarCompressionFormat.xz,\n ):\n+ \"\"\"Create the tarball during initialization.\n+\n+ The DPDK version is specified with `git_ref`. The tarball will be compressed with\n+ `tar_compression_format`, which must be supported by the DTS execution environment.\n+ The resulting tarball will be put into `output_dir`.\n+\n+ Args:\n+ git_ref: A git commit ID, tag ID or tree ID.\n+ output_dir: The directory where to put the resulting tarball.\n+ tar_compression_format: The compression format to use.\n+ \"\"\"\n self._git_ref = git_ref\n self._tar_compression_format = tar_compression_format\n \n@@ -196,4 +233,5 @@ def _delete_tarball(self) -> None:\n os.remove(self._tarball_path)\n \n def __fspath__(self) -> str:\n+ \"\"\"The os.PathLike protocol implementation.\"\"\"\n return str(self._tarball_path)\n", "prefixes": [ "v9", "06/21" ] }{ "id": 134794, "url": "