Skip to content

Auto-serialize pathlib.Path inputs #773

Description

@GeigerJ2

Problem

When passing a pathlib.Path as an input to a WorkGraph task (e.g., via shelljob nodes), serialization fails with:

ValueError: Cannot serialize the provided object.

Type: pathlib.PosixPath
Tried entry-point key: 'pathlib.PosixPath' -- not found in provided serializers.

Current workaround

Users must manually convert Path objects before passing them:

script_node = orm.SinglefileData(SCRIPT_PATH)

Expected behavior

pathlib.Path is a common Python type. WorkGraph (or aiida-pythonjob's serializer) should serialize it automatically, similar to how launch_shell_job from aiida-shell already handles Path inputs.

Context

This came up while writing the AiiDA core tutorials (Module 3: WorkGraph workflows). The simulation script path is a pathlib.Path from a constants file, and passing it to a shelljob inside @task.graph() fails at serialization time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions