AgnostiqHQ / covalent-slurm-plugin

Executor plugin interfacing Covalent with Slurm
https://covalent.xyz
Apache License 2.0
27 stars 6 forks source link

Support more robust path handling with `remote_workdir` #91

Open Andrew-S-Rosen opened 4 months ago

Andrew-S-Rosen commented 4 months ago

Environment

What is happening?

Related to #95, when one specifies the remote_workdir with a path like ~/my/dir, it raises an error upon trying to parse the pkl file. The UI shows [Errno 1] : PosixPath('~/test/ef5861af-7b92-4dbc-a52c-eb83bb137496/node_0/result-ef5861af-7b92-4dbc-a52c-eb83bb137496-0.pkl').

How can we reproduce the issue?

import covalent as ct

executor = ct.executor.SlurmExecutor(
    username="rosen",
    address="perlmutter-p1.nersc.gov",
    ssh_key_file="/home/rosen/.ssh/nersc",
    cert_file="/home/rosen/.ssh/nersc-cert.pub",
    conda_env="covalent",
    options={
        "nodes": 1,
        "qos": "debug",
        "constraint": "cpu",
        "account": "matgen",
        "job-name": "test",
        "time": "00:10:00",
    },
    remote_workdir="~/test",
    create_unique_workdir=True,
    cleanup=False,
)

@ct.lattice(executor=executor)
@ct.electron
def workflow():

    return "<3"

ct.dispatch(workflow)()

What should happen?

Filepaths like ~/my/dir should work

Any suggestions?

Wrap the file path in Path().expanduser().resolve() client-side before the electron is launched. As a stretch goal, I would even suggest trying to support something like $SCRATCH/my/dir by wrapping the path call with os.path.expandvars() on the client side too.

You can basically copy what I have done in the covalent-hpc-plugin in terms of file path handling, such as here.