Let's imagine I have a simple Python script do_stuff.py
who list subfolders in a given folder:
import click
@click.command(help="Do stuff.")
@click.argument('datasets', type=click.Path(exists=True, readable=True, writable=True), nargs=-1)
def main(datasets):
for dataset in datasets:
print(dataset)
if __name__ == "__main__":
main()
In my case it returns the expected list of folder when I run python3 do_stuff.py ./s3_data/lsc2/landsat_ot_c2_l2/*
:
./s3_data/lsc2/landsat_ot_c2_l2/LC08_L2SP_195027_20220121
./s3_data/lsc2/landsat_ot_c2_l2/LC08_L2SP_195027_20220206
./s3_data/lsc2/landsat_ot_c2_l2/LC08_L2SP_195027_20220222
./s3_data/lsc2/landsat_ot_c2_l2/LC08_L2SP_195027_20220310
When I try to do the same thing from another script master.py
, importing do_stuff.py
:
from do_stuff import main as ds
ds('./s3_data/lsc2/landsat_ot_c2_l2/*')
When I run python3 master.py
it returns:
Usage: master.py [OPTIONS] [DATASETS]...
Try 'master.py --help' for help.
Error: Invalid value for '[DATASETS]...': Path '/' is not writable.
If I modify the last line of master.py
into ds(['./s3_data/lsc2/landsat_ot_c2_l2/*'])
, then I get:
Usage: master.py [OPTIONS] [DATASETS]...
Try 'master.py --help' for help.
Error: Invalid value for '[DATASETS]...': Path './s3_data/lsc2/landsat_ot_c2_l2/*' does not exist.
Thanks in advance for any help you could provide.