payu-org / payu

A workflow management tool for numerical models on the NCI computing systems
Apache License 2.0
19 stars 26 forks source link

Need for absolute paths when doing a `payu clone -r` could be clearer #514

Open anton-seaice opened 2 days ago

anton-seaice commented 2 days ago

Doing a payu clone using a relative restart path doesn't work with a warning:

Cloned repository from om2 to directory: /g/data/tm70/as2285/payu/om2-clone-r
Checked out branch: om2_1deg_ryf
laboratory path:  /scratch/tm70/as2285/access-om2
binary path:  /scratch/tm70/as2285/access-om2/bin
input path:  /scratch/tm70/as2285/access-om2/input
work path:  /scratch/tm70/as2285/access-om2/work
archive path:  /scratch/tm70/as2285/access-om2/archive
/g/data/tm70/as2285/payu-dev/payu-dev/lib64/python3.11/site-packages/payu/branch.py:46: UserWarning: Given restart path om2/archive/restart000 does not exist. Skipping setting 'restart' in config file

...

As it relies on an absolute path

https://github.com/payu-org/payu/blob/master/payu/branch.py#L245-L246

This could be clearer in the docs and help, e.g.:

$ payu clone --help
usage: payu clone [-h] [--model MODEL_TYPE] [--config CONFIG_PATH] [--laboratory LAB_PATH] [-k] [--branch BRANCH] [--new-branch NEW_BRANCH_NAME] [--restart RESTART_PATH]
                  [--parent-experiment PARENT_EXPERIMENT]
                  repository local_directory
...
  --restart RESTART_PATH, -r RESTART_PATH
                        The restart path from which to start the model run
...

its also not clear to me why the relative path can't work?

jo-basevi commented 1 day ago

Thanks for raising this issue! Yeah relative paths should be supported..

So restart path is added to the configuration as part of the checkout method and is resolved to an absolute path: https://github.com/payu-org/payu/blob/e59d4005db7a5ae73e4055903945a665f908533b/payu/branch.py#L51

The error is happening because checkout runs inside the newly cloned directory. So the clone method could be changed to resolve the restart path before passing the path to checkout. The code documentation will need to be fixed too.