uhd-urz / elAPI

An extensible API client for eLabFTW
GNU Affero General Public License v3.0
5 stars 0 forks source link

Improve export feature - [merged] #54

Closed alexander-haller closed 4 months ago

alexander-haller commented 1 year ago

In GitLab by @mhxion on Oct 6, 2023, 16:23

Merges fix-export -> dev

Fixes #2

Exporting data now is stable. A new ExportToDirectory class has been added (cli/_export.py) that handles all sorts of exports. Export now works the following way:

  1. An --export-dir (alias -e) option for the following commands: bill-teams, get. E.g.,

    elapi bill-teams -o yaml --export-dir

    Note: The name --export-dir explicitly implies it only supports directory paths not file paths!

  2. Passing --export-dir will mean elAPI will look for export_dir field (previously named download-dir) in configuration files. If no export-dir is defined, then --export-dir will assign XDG_DOWNLOAD_DIR as its export path. If XDG_DOWNLOAD_DIR isn't defined either, then $HOME/Downloads. If neither is defined, elAPI will simply quite throwing an error message before even running any task. See comments for more about this behavior.

  3. This PR also makes passing an arbitrary directory to --export-dir possible.

    elapi bill-teams -o yaml --export-dir ~/Downloads/elabftw/bill-teams

    If the passing path isn't valid (no write permission) then elAPI will fallback to no. 2 above.

  4. --export-dir understands output format option -o. The exporting format will be that of -o. If -o yaml is passed then --export-dir will save the data as a YAML file. If no -o is passed the default output format JSON assumed.

alexander-haller commented 1 year ago

In GitLab by @mhxion on Oct 6, 2023, 16:23

requested review from @alexander-haller

alexander-haller commented 1 year ago

In GitLab by @mhxion on Oct 6, 2023, 16:36

Note from no. 2: In an upcoming merge (branch path-validation), a new path validator is added that makes sure all the essential paths are validated before any tasks are run. I.e., elAPI only runs or continues any task like bill-teams if paths like log path, export path are validated first, so we wouldn't waste our time by waiting for 15 minutes for bill-teams to finish only to find out that the data can't export because of an invalid path!

alexander-haller commented 1 year ago

In GitLab by @mhxion on Nov 5, 2023, 13:38

Many of the changes are now obsolete since they have been improved upon again in the future branch new-export-behavior. A new PR/MR will be made soon.

alexander-haller commented 1 year ago

In GitLab by @mhxion on Nov 5, 2023, 13:38

removed review request for @alexander-haller