Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure output logs directory exists #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jrbourbeau
Copy link

I was playing playing around with this today and got this error

Traceback (most recent call last):
  File "/Users/james/projects/earth-mover/serverless-datacube-demo/src/main.py", line 181, in <module>
    main()
  File "/Users/james/mambaforge/envs/datacube-env5/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/james/mambaforge/envs/datacube-env5/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/Users/james/mambaforge/envs/datacube-env5/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/james/mambaforge/envs/datacube-env5/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/james/projects/earth-mover/serverless-datacube-demo/src/main.py", line 177, in main
    save_output_log(results, log_fname)
  File "/Users/james/projects/earth-mover/serverless-datacube-demo/src/lib.py", line 322, in save_output_log
    df.to_csv(fname, index=False)
  File "/Users/james/mambaforge/envs/datacube-env5/lib/python3.11/site-packages/pandas/util/_decorators.py", line 333, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/james/mambaforge/envs/datacube-env5/lib/python3.11/site-packages/pandas/core/generic.py", line 3967, in to_csv
    return DataFrameRenderer(formatter).to_csv(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/james/mambaforge/envs/datacube-env5/lib/python3.11/site-packages/pandas/io/formats/format.py", line 1014, in to_csv
    csv_formatter.save()
  File "/Users/james/mambaforge/envs/datacube-env5/lib/python3.11/site-packages/pandas/io/formats/csvs.py", line 251, in save
    with get_handle(
         ^^^^^^^^^^^
  File "/Users/james/mambaforge/envs/datacube-env5/lib/python3.11/site-packages/pandas/io/common.py", line 749, in get_handle
    check_parent_directory(str(handle))
  File "/Users/james/mambaforge/envs/datacube-env5/lib/python3.11/site-packages/pandas/io/common.py", line 616, in check_parent_directory
    raise OSError(rf"Cannot save file into a non-existent directory: '{parent}'")
OSError: Cannot save file into a non-existent directory: 'logs'

because it's assumed the output logs directory already exists. This PR just adds a line of code to make sure the logs directory is around.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant