get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/133912/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 133912,
    "url": "http://patches.dpdk.org/api/patches/133912/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20231106171601.160749-12-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": "<20231106171601.160749-12-juraj.linkes@pantheon.tech>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20231106171601.160749-12-juraj.linkes@pantheon.tech",
    "date": "2023-11-06T17:15:49",
    "name": "[v5,11/23] dts: remote session docstring update",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "a96e9828d57d62219669d240bf2abe09354641e2",
    "submitter": {
        "id": 1626,
        "url": "http://patches.dpdk.org/api/people/1626/?format=api",
        "name": "Juraj Linkeš",
        "email": "juraj.linkes@pantheon.tech"
    },
    "delegate": {
        "id": 2642,
        "url": "http://patches.dpdk.org/api/users/2642/?format=api",
        "username": "mcoquelin",
        "first_name": "Maxime",
        "last_name": "Coquelin",
        "email": "maxime.coquelin@redhat.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20231106171601.160749-12-juraj.linkes@pantheon.tech/mbox/",
    "series": [
        {
            "id": 30173,
            "url": "http://patches.dpdk.org/api/series/30173/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=30173",
            "date": "2023-11-06T17:15:38",
            "name": "dts: add dts api docs",
            "version": 5,
            "mbox": "http://patches.dpdk.org/series/30173/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/133912/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/133912/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 5EB39432BB;\n\tMon,  6 Nov 2023 18:17:42 +0100 (CET)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 851524111B;\n\tMon,  6 Nov 2023 18:16:23 +0100 (CET)",
            "from mail-ej1-f43.google.com (mail-ej1-f43.google.com\n [209.85.218.43]) by mails.dpdk.org (Postfix) with ESMTP id BA4BB40EE1\n for <dev@dpdk.org>; Mon,  6 Nov 2023 18:16:20 +0100 (CET)",
            "by mail-ej1-f43.google.com with SMTP id\n a640c23a62f3a-9dd3f4a0f5aso465848366b.1\n for <dev@dpdk.org>; Mon, 06 Nov 2023 09:16:20 -0800 (PST)",
            "from jlinkes-PT-Latitude-5530.. (ip-46.34.243.197.o2inet.sk.\n [46.34.243.197]) by smtp.gmail.com with ESMTPSA id\n s10-20020a170906354a00b009b947aacb4bsm47016eja.191.2023.11.06.09.16.19\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Mon, 06 Nov 2023 09:16:20 -0800 (PST)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=pantheon.tech; s=google; t=1699290980; x=1699895780; 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=t7XOoo85AsM+xPhfLGE4ILJ7NUrsoVLB8WhGDmtkhUM=;\n b=MUHEUq2XOqB/5J8Ebh10HfxvQVTLS0jUVTjcxyeshQ0gTOkyNr2bx59bEgBLIEsuw9\n r709+H6YMuowYazvv5nvxqs5W3kMqDi0tfE0INfOw5gvmJ+98nUr2ACa1yvKsLddnBqX\n dsk8DFtHIIWEI+CR8fUgKq2sIQIxnrOjuXRDoIGP4TesedtFCko4hZoaSZbZTYOxAJzc\n LcI3Wj8Mtu1ODoV7g685vmIETuRxumdyv7pN1DjeNboLh77bMAAYwUOjiwbCnucn6jZB\n mXyF8M5gl6rl43lskW5Q0F0HQzG36KaEM4wpshdN7RgvtW3PxkRrICoci16bBuEHg8bL\n 8YEw==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1699290980; x=1699895780;\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=t7XOoo85AsM+xPhfLGE4ILJ7NUrsoVLB8WhGDmtkhUM=;\n b=iNsUDpQhNgImq1q4iFW29SbNHh51ARiI3yquupsLGlAntcEDXLJlAs+1orZmtma/Gs\n HzND9+lAUpDAQ39e3WQ3UhVrGG82aXMKxsMBltyUsQVXQ7Ce9j34jAtdra4ZTLeXBnru\n IffARFcC+/VoR3P8lFlpIVzfF8cfXY0jO0090DBnpjo9cg0TQIgHPcf5ZLyXZPwKAjYz\n o4S7k+L7IrTYWZnGffRv0bLXbjp+uAs8h91slGoH+5mBDLu3wN6wt0RLQ66HJb8MQqFs\n L2Pc8y89U4h5tzlIuDy7syNCDuPYuOOdi0TyhgNDvC2s7Sh2L9oriydKX67fppLKNthN\n w8ow==",
        "X-Gm-Message-State": "AOJu0YwOMCiYPADk1uVkFGKj7BivQoc2e9rYA/JTLh1a0d79yPkr6qdg\n gn+sxKXbHnH2dJwJfKELU9HGew==",
        "X-Google-Smtp-Source": "\n AGHT+IGlIPnNsR2jBMEiUTRWT535DWkVFE8Hy9GwTQO6rr8UpSKUN9sOazZbPkhJLeZzLWyjlwQZhw==",
        "X-Received": "by 2002:a17:907:26ce:b0:9c6:9342:1459 with SMTP id\n bp14-20020a17090726ce00b009c693421459mr15513548ejc.20.1699290980384;\n Mon, 06 Nov 2023 09:16:20 -0800 (PST)",
        "From": "=?utf-8?q?Juraj_Linke=C5=A1?= <juraj.linkes@pantheon.tech>",
        "To": "thomas@monjalon.net, Honnappa.Nagarahalli@arm.com,\n bruce.richardson@intel.com, jspewock@iol.unh.edu, probb@iol.unh.edu,\n paul.szczepanek@arm.com, yoan.picchi@foss.arm.com",
        "Cc": "dev@dpdk.org, =?utf-8?q?Juraj_Linke=C5=A1?= <juraj.linkes@pantheon.tech>",
        "Subject": "[PATCH v5 11/23] dts: remote session docstring update",
        "Date": "Mon,  6 Nov 2023 18:15:49 +0100",
        "Message-Id": "<20231106171601.160749-12-juraj.linkes@pantheon.tech>",
        "X-Mailer": "git-send-email 2.34.1",
        "In-Reply-To": "<20231106171601.160749-1-juraj.linkes@pantheon.tech>",
        "References": "<20230831100407.59865-1-juraj.linkes@pantheon.tech>\n <20231106171601.160749-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/remote_session/__init__.py      |  39 +++++-\n .../remote_session/remote_session.py          | 128 +++++++++++++-----\n dts/framework/remote_session/ssh_session.py   |  16 +--\n 3 files changed, 135 insertions(+), 48 deletions(-)",
    "diff": "diff --git a/dts/framework/remote_session/__init__.py b/dts/framework/remote_session/__init__.py\nindex 5e7ddb2b05..51a01d6b5e 100644\n--- a/dts/framework/remote_session/__init__.py\n+++ b/dts/framework/remote_session/__init__.py\n@@ -2,12 +2,14 @@\n # Copyright(c) 2023 PANTHEON.tech s.r.o.\n # Copyright(c) 2023 University of New Hampshire\n \n-\"\"\"\n-The package provides modules for managing remote connections to a remote host (node),\n-differentiated by OS.\n-The package provides a factory function, create_session, that returns the appropriate\n-remote connection based on the passed configuration. The differences are in the\n-underlying transport protocol (e.g. SSH) and remote OS (e.g. Linux).\n+\"\"\"Remote interactive and non-interactive sessions.\n+\n+This package provides modules for managing remote connections to a remote host (node).\n+\n+The non-interactive sessions send commands and return their output and exit code.\n+\n+The interactive sessions open an interactive shell which is continuously open,\n+allowing it to send and receive data within that particular shell.\n \"\"\"\n \n # pylama:ignore=W0611\n@@ -26,10 +28,35 @@\n def create_remote_session(\n     node_config: NodeConfiguration, name: str, logger: DTSLOG\n ) -> RemoteSession:\n+    \"\"\"Factory for non-interactive remote sessions.\n+\n+    The function returns an SSH session, but will be extended if support\n+    for other protocols is added.\n+\n+    Args:\n+        node_config: The test run configuration of the node to connect to.\n+        name: The name of the session.\n+        logger: The logger instance this session will use.\n+\n+    Returns:\n+        The SSH remote session.\n+    \"\"\"\n     return SSHSession(node_config, name, logger)\n \n \n def create_interactive_session(\n     node_config: NodeConfiguration, logger: DTSLOG\n ) -> InteractiveRemoteSession:\n+    \"\"\"Factory for interactive remote sessions.\n+\n+    The function returns an interactive SSH session, but will be extended if support\n+    for other protocols is added.\n+\n+    Args:\n+        node_config: The test run configuration of the node to connect to.\n+        logger: The logger instance this session will use.\n+\n+    Returns:\n+        The interactive SSH remote session.\n+    \"\"\"\n     return InteractiveRemoteSession(node_config, logger)\ndiff --git a/dts/framework/remote_session/remote_session.py b/dts/framework/remote_session/remote_session.py\nindex 0647d93de4..629c2d7b9c 100644\n--- a/dts/framework/remote_session/remote_session.py\n+++ b/dts/framework/remote_session/remote_session.py\n@@ -3,6 +3,13 @@\n # Copyright(c) 2022-2023 PANTHEON.tech s.r.o.\n # Copyright(c) 2022-2023 University of New Hampshire\n \n+\"\"\"Base remote session.\n+\n+This module contains the abstract base class for remote sessions and defines\n+the structure of the result of a command execution.\n+\"\"\"\n+\n+\n import dataclasses\n from abc import ABC, abstractmethod\n from pathlib import PurePath\n@@ -15,8 +22,14 @@\n \n @dataclasses.dataclass(slots=True, frozen=True)\n class CommandResult:\n-    \"\"\"\n-    The result of remote execution of a command.\n+    \"\"\"The result of remote execution of a command.\n+\n+    Attributes:\n+        name: The name of the session that executed the command.\n+        command: The executed command.\n+        stdout: The standard output the command produced.\n+        stderr: The standard error output the command produced.\n+        return_code: The return code the command exited with.\n     \"\"\"\n \n     name: str\n@@ -26,6 +39,7 @@ class CommandResult:\n     return_code: int\n \n     def __str__(self) -> str:\n+        \"\"\"Format the command outputs.\"\"\"\n         return (\n             f\"stdout: '{self.stdout}'\\n\"\n             f\"stderr: '{self.stderr}'\\n\"\n@@ -34,13 +48,24 @@ def __str__(self) -> str:\n \n \n class RemoteSession(ABC):\n-    \"\"\"\n-    The base class for defining which methods must be implemented in order to connect\n-    to a remote host (node) and maintain a remote session. The derived classes are\n-    supposed to implement/use some underlying transport protocol (e.g. SSH) to\n-    implement the methods. On top of that, it provides some basic services common to\n-    all derived classes, such as keeping history and logging what's being executed\n-    on the remote node.\n+    \"\"\"Non-interactive remote session.\n+\n+    The abstract methods must be implemented in order to connect to a remote host (node)\n+    and maintain a remote session.\n+    The subclasses must use (or implement) some underlying transport protocol (e.g. SSH)\n+    to implement the methods. On top of that, it provides some basic services common to all\n+    subclasses, such as keeping history and logging what's being executed on the remote node.\n+\n+    Attributes:\n+        name: The name of the session.\n+        hostname: The node's hostname. Could be an IP (possibly with port, separated by a colon)\n+            or a domain name.\n+        ip: The IP address of the node or a domain name, whichever was used in `hostname`.\n+        port: The port of the node, if given in `hostname`.\n+        username: The username used in the connection.\n+        password: The password used in the connection. Most frequently empty,\n+            as the use of passwords is discouraged.\n+        history: The executed commands during this session.\n     \"\"\"\n \n     name: str\n@@ -59,6 +84,16 @@ def __init__(\n         session_name: str,\n         logger: DTSLOG,\n     ):\n+        \"\"\"Connect to the node during initialization.\n+\n+        Args:\n+            node_config: The test run configuration of the node to connect to.\n+            session_name: The name of the session.\n+            logger: The logger instance this session will use.\n+\n+        Raises:\n+            SSHConnectionError: If the connection to the node was not successful.\n+        \"\"\"\n         self._node_config = node_config\n \n         self.name = session_name\n@@ -79,8 +114,13 @@ def __init__(\n \n     @abstractmethod\n     def _connect(self) -> None:\n-        \"\"\"\n-        Create connection to assigned node.\n+        \"\"\"Create a connection to the node.\n+\n+        The implementation must assign the established session to self.session.\n+\n+        The implementation must except all exceptions and convert them to an SSHConnectionError.\n+\n+        The implementation may optionally implement retry attempts.\n         \"\"\"\n \n     def send_command(\n@@ -90,11 +130,24 @@ def send_command(\n         verify: bool = False,\n         env: dict | None = None,\n     ) -> CommandResult:\n-        \"\"\"\n-        Send a command to the connected node using optional env vars\n-        and return CommandResult.\n-        If verify is True, check the return code of the executed command\n-        and raise a RemoteCommandExecutionError if the command failed.\n+        \"\"\"Send `command` to the connected node.\n+\n+        The :option:`--timeout` command line argument and the :envvar:`DTS_TIMEOUT`\n+        environment variable configure the timeout of command execution.\n+\n+        Args:\n+            command: The command to execute.\n+            timeout: Wait at most this long in seconds to execute `command`.\n+            verify: If :data:`True`, will check the exit code of `command`.\n+            env: A dictionary with environment variables to be used with `command` execution.\n+\n+        Raises:\n+            SSHSessionDeadError: If the session isn't alive when sending `command`.\n+            SSHTimeoutError: If `command` execution timed out.\n+            RemoteCommandExecutionError: If verify is :data:`True` and `command` execution failed.\n+\n+        Returns:\n+            The output of the command along with the return code.\n         \"\"\"\n         self._logger.info(\n             f\"Sending: '{command}'\" + (f\" with env vars: '{env}'\" if env else \"\")\n@@ -115,29 +168,36 @@ def send_command(\n     def _send_command(\n         self, command: str, timeout: float, env: dict | None\n     ) -> CommandResult:\n-        \"\"\"\n-        Use the underlying protocol to execute the command using optional env vars\n-        and return CommandResult.\n+        \"\"\"Send a command to the connected node.\n+\n+        The implementation must execute the command remotely with `env` environment variables\n+        and return the result.\n+\n+        The implementation must except all exceptions and raise an SSHSessionDeadError if\n+        the session is not alive and an SSHTimeoutError if the command execution times out.\n         \"\"\"\n \n     def close(self, force: bool = False) -> None:\n-        \"\"\"\n-        Close the remote session and free all used resources.\n+        \"\"\"Close the remote session and free all used resources.\n+\n+        Args:\n+            force: Force the closure of the connection. This may not clean up all resources.\n         \"\"\"\n         self._logger.logger_exit()\n         self._close(force)\n \n     @abstractmethod\n     def _close(self, force: bool = False) -> None:\n-        \"\"\"\n-        Execute protocol specific steps needed to close the session properly.\n+        \"\"\"Protocol specific steps needed to close the session properly.\n+\n+        Args:\n+            force: Force the closure of the connection. This may not clean up all resources.\n+                This doesn't have to be implemented in the overloaded method.\n         \"\"\"\n \n     @abstractmethod\n     def is_alive(self) -> bool:\n-        \"\"\"\n-        Check whether the remote session is still responding.\n-        \"\"\"\n+        \"\"\"Check whether the remote session is still responding.\"\"\"\n \n     @abstractmethod\n     def copy_from(\n@@ -147,12 +207,12 @@ def copy_from(\n     ) -> None:\n         \"\"\"Copy a file from the remote Node to the local filesystem.\n \n-        Copy source_file from the remote Node associated with this remote\n-        session to destination_file on the local filesystem.\n+        Copy `source_file` from the remote Node associated with this remote session\n+        to `destination_file` on the local filesystem.\n \n         Args:\n-            source_file: the file on the remote Node.\n-            destination_file: a file or directory path on the local filesystem.\n+            source_file: The file on the remote Node.\n+            destination_file: A file or directory path on the local filesystem.\n         \"\"\"\n \n     @abstractmethod\n@@ -163,10 +223,10 @@ def copy_to(\n     ) -> None:\n         \"\"\"Copy a file from local filesystem to the remote Node.\n \n-        Copy source_file from local filesystem to destination_file\n-        on the remote Node associated with this remote session.\n+        Copy `source_file` from local filesystem to `destination_file` on the remote Node\n+        associated with this remote session.\n \n         Args:\n-            source_file: the file on the local filesystem.\n-            destination_file: a file or directory path on the remote Node.\n+            source_file: The file on the local filesystem.\n+            destination_file: A file or directory path on the remote Node.\n         \"\"\"\ndiff --git a/dts/framework/remote_session/ssh_session.py b/dts/framework/remote_session/ssh_session.py\nindex cee11d14d6..7186490a9a 100644\n--- a/dts/framework/remote_session/ssh_session.py\n+++ b/dts/framework/remote_session/ssh_session.py\n@@ -1,6 +1,8 @@\n # SPDX-License-Identifier: BSD-3-Clause\n # Copyright(c) 2023 PANTHEON.tech s.r.o.\n \n+\"\"\"SSH session remote session.\"\"\"\n+\n import socket\n import traceback\n from pathlib import PurePath\n@@ -26,13 +28,8 @@\n class SSHSession(RemoteSession):\n     \"\"\"A persistent SSH connection to a remote Node.\n \n-    The connection is implemented with the Fabric Python library.\n-\n-    Args:\n-        node_config: The configuration of the Node to connect to.\n-        session_name: The name of the session.\n-        logger: The logger used for logging.\n-            This should be passed from the parent OSSession.\n+    The connection is implemented with\n+    `the Fabric Python library <https://docs.fabfile.org/en/latest/>`_.\n \n     Attributes:\n         session: The underlying Fabric SSH connection.\n@@ -80,6 +77,7 @@ def _connect(self) -> None:\n             raise SSHConnectionError(self.hostname, errors)\n \n     def is_alive(self) -> bool:\n+        \"\"\"Overrides :meth:`~.remote_session.RemoteSession.is_alive`.\"\"\"\n         return self.session.is_connected\n \n     def _send_command(\n@@ -89,7 +87,7 @@ def _send_command(\n \n         Args:\n             command: The command to execute.\n-            timeout: Wait at most this many seconds for the execution to complete.\n+            timeout: Wait at most this long in seconds to execute the command.\n             env: Extra environment variables that will be used in command execution.\n \n         Raises:\n@@ -118,6 +116,7 @@ def copy_from(\n         source_file: str | PurePath,\n         destination_file: str | PurePath,\n     ) -> None:\n+        \"\"\"Overrides :meth:`~.remote_session.RemoteSession.copy_from`.\"\"\"\n         self.session.get(str(destination_file), str(source_file))\n \n     def copy_to(\n@@ -125,6 +124,7 @@ def copy_to(\n         source_file: str | PurePath,\n         destination_file: str | PurePath,\n     ) -> None:\n+        \"\"\"Overrides :meth:`~.remote_session.RemoteSession.copy_to`.\"\"\"\n         self.session.put(str(source_file), str(destination_file))\n \n     def _close(self, force: bool = False) -> None:\n",
    "prefixes": [
        "v5",
        "11/23"
    ]
}