DPDK patches and discussions
 help / color / mirror / Atom feed
From: Luca Vizzarro <Luca.Vizzarro@arm.com>
To: Patrick Robb <probb@iol.unh.edu>
Cc: dev@dpdk.org, Paul Szczepanek <paul.szczepanek@arm.com>
Subject: Re: [PATCH 4/6] dts: add artifact module
Date: Tue, 12 Aug 2025 09:31:09 +0100	[thread overview]
Message-ID: <df1c5f22-4dce-48a1-9152-4e508efd068b@arm.com> (raw)
In-Reply-To: <CAJvnSUAvo4NimU9xVVGY10uGhGDcsQQ-gBbW0QfHS3pANf64pQ@mail.gmail.com>

On 12/08/2025 02:25, Patrick Robb wrote:
> On Fri, Jul 25, 2025 at 11:15 AM Luca Vizzarro <luca.vizzarro@arm.com 
> <mailto:luca.vizzarro@arm.com>> wrote:
> 
> 
>     +
>     +@overload
>     +def make_file_path(node: Node, file_name: str, custom_path:
>     PurePath | None = None) -> PurePath: ...
>     +
>     +
>     +@overload
>     +def make_file_path(node: None, file_name: str, custom_path:
>     PurePath | None = None) -> Path: ...
>     +
>     +
>     +def make_file_path(
>     +    node: Node | None, file_name: str, custom_path: PurePath | None
>     = None
> 
> 
> Maybe it makes sense to set a default value of None for node? That way 
> people don't have to pass in None every time they want to make a path on 
> the DTS engine system.

Even though this function is not private, ideally we don't want this to 
be used outside of the artifact module. But we want the Artifact class 
to be used instead. For this reason the node argument is kept without a 
default to match the behaviour of the Artifact constructor.

Could just make this private.

>     +    def open(
>     +        self, file_mode: BinaryMode | TextMode = "rb", buffering:
>     int = -1
>     +    ) -> Union["ArtifactFile", TextIOWrapper]:
>     +        """Open the artifact file.
>     +
>     +        Args:
>     +            file_mode: The mode of file opening.
>     +            buffering: The size of the buffer to use. If -1, the
>     default buffer size is used.
>     +
>     +        Returns:
>     +            An instance of :class:`ArtifactFile`
>     or :class:`TextIOWrapper`.
>     +        """
>     +        if self._fd is not None and not self._fd.closed:
>     +            self._logger.warning(
>     +                f"Artifact {self.path} is already open. Closing the
>     previous file descriptor."
>     +            )
>     +            self._fd.close()
>     +        elif not self._directories_created:
>     +            self.mkdir()
>     +
>     +        # SFTPFile does not support text mode, therefore everything
>     needs to be handled as binary.
>     +        if "t" in file_mode:
>     +            actual_mode = cast(BinaryMode, cast(str,
>     file_mode).replace("t", "") + "b")
> 
> 
> Is it worth logging this event to prevent confusion? (where we change 
> the requested mode to binary mode)
This is an implementation-related internal detail. At a higher level, 
where the user and test writer are interested, the mode is the same as 
specific in `mode`. The only reason why this is happening is because the 
lower level implementation works in binary mode only. Text mode (in 
standard Python too) is just an encoder/decoder wrapper as used here. 
Under the hood all the file operations are done in binary mode.

A user shouldn't be concerned about how it works internally. Quite the 
opposite, introducing logging for this kind of thing will introduce 
confusion. The user should only care about the higher level 
functionality, which is the API.

Please let me know if it's not clear.

  reply	other threads:[~2025-08-12  8:31 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-25 15:11 [PATCH 0/6] dts: add file management Luca Vizzarro
2025-07-25 15:11 ` [PATCH 1/6] dts: merge RemoteSession class Luca Vizzarro
2025-08-08  1:15   ` Patrick Robb
2025-07-25 15:11 ` [PATCH 2/6] dts: add node retriever by identifier Luca Vizzarro
2025-08-08 18:10   ` Patrick Robb
2025-07-25 15:11 ` [PATCH 3/6] dts: add current test suite and cases to context Luca Vizzarro
2025-08-08 18:19   ` Patrick Robb
2025-07-25 15:11 ` [PATCH 4/6] dts: add artifact module Luca Vizzarro
2025-08-12  1:25   ` Patrick Robb
2025-08-12  8:31     ` Luca Vizzarro [this message]
2025-08-12 13:50       ` Patrick Robb
2025-08-12  3:26   ` Patrick Robb
2025-08-12  8:21     ` Luca Vizzarro
2025-07-25 15:11 ` [PATCH 5/6] dts: make log files into artifacts Luca Vizzarro
2025-08-12  3:10   ` Patrick Robb
2025-07-25 15:11 ` [PATCH 6/6] dts: use artifacts in packet capture and softnic Luca Vizzarro
2025-08-12  3:29   ` Patrick Robb

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=df1c5f22-4dce-48a1-9152-4e508efd068b@arm.com \
    --to=luca.vizzarro@arm.com \
    --cc=dev@dpdk.org \
    --cc=paul.szczepanek@arm.com \
    --cc=probb@iol.unh.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).