aiida-core icon indicating copy to clipboard operation
aiida-core copied to clipboard

Standardize path handling throughout the code base

Open GeigerJ2 opened this issue 8 months ago • 2 comments

As discussed with @edan-bainglass.

In PR #6255, an inconsistency in the type handling of the filepath_executable of PortableCode was identified by the introduction of pydantic (see here for reference).

Looking throughout the code base, we have two different type aliases for path-like types: https://github.com/aiidateam/aiida-core/blob/660fec70ef43a64be7edae3c12f0a0fd5ef84349/src/aiida/transports/transport.py#L27 https://github.com/aiidateam/aiida-core/blob/660fec70ef43a64be7edae3c12f0a0fd5ef84349/src/aiida/repository/repository.py#L15 FilePath also here: https://github.com/aiidateam/aiida-core/blob/660fec70ef43a64be7edae3c12f0a0fd5ef84349/src/aiida/orm/nodes/data/folder.py#L26 https://github.com/aiidateam/aiida-core/blob/660fec70ef43a64be7edae3c12f0a0fd5ef84349/src/aiida/orm/nodes/data/singlefile.py#L25

As well as standard type hints for paths, and combinations of the two: https://github.com/aiidateam/aiida-core/blob/660fec70ef43a64be7edae3c12f0a0fd5ef84349/src/aiida/repository/repository.py#L483

While I wouldn't deem this super high priority, it might be useful to standardize those path-like annotations if possible, or at least put them in a dedicated module, e.g., aiida/common/types.py. Also, many (probably older) parts of the codebase use os.path (this is especially prevalent in the transport plugins), where we could also consider switching to pathlib at some point.

GeigerJ2 avatar Apr 03 '25 10:04 GeigerJ2

Hi @GeigerJ2 , I'd like to work on this issue. Please let me know if there are any specific guidelines you'd like me to follow while making these changes.

Thanks!

ayushjariyal avatar Apr 06 '25 07:04 ayushjariyal

@GeigerJ2 , I’ve opened a PR addressing this issue. Could you please review it?

ayushjariyal avatar Apr 10 '25 18:04 ayushjariyal