openclimatefix / Satip

Satip contains the code necessary for retrieving, transforming and storing EUMETSAT data
https://satip.readthedocs.io/
MIT License
41 stars 28 forks source link

Add input validation of directory paths given to satip #245

Closed jsbaasi closed 6 months ago

jsbaasi commented 6 months ago

…ries

Pull Request

Description

This change adds a function to utils.py that checks whether a provided path leads to a directory or just a file

The aforementioned function is then added to the top of app.py to check whether save_dir and/or save_dir_native are valid paths

I want to add this change because this will save resources in case you input a bad path. Otherwise the script proceeds to make expensive API calls to EUMETSAT etc. to then fail at the very end when it tries pushing files to the provided save_dir and/or save_dir_native paths.

This has not been put on the issues page

How Has This Been Tested?

The following list shows the 3 save_dir paths that been given as arguments and their results after this PR's changes:

  1. A save_dir path that leads to a directory, satip continues executing
  2. A save_dir path that leads to a file, satip logs the error and halts execution
  3. A save_dir path that doesn't lead to a file or directory, satip logs the error and halts execution

Checklist:

jsbaasi commented 6 months ago

Apologies, the name of the branch does not detail what this PR does!

peterdudfield commented 5 months ago

@all-contributors please add @jsbaasi for code

allcontributors[bot] commented 5 months ago

@peterdudfield

I've put up a pull request to add @jsbaasi! :tada: