Skip to content

Commit

Permalink
Merge pull request #13 from VForWaTer/param-rework
Browse files Browse the repository at this point in the history
Param rework
  • Loading branch information
mmaelicke authored Jul 9, 2024
2 parents 6e22e78 + f1b5475 commit ffc16db
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 24 deletions.
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ RUN arch=$(uname -m | sed s/x86_64/amd64/) && \
chmod +x ./duckdb && \
mv ./duckdb /duck/duckdb

# pre-install the spatial extension into duckdb as it will be used
RUN /duck/duckdb -c "INSTALL spatial;"

# go to the source directory of this tool
WORKDIR /src
CMD ["python", "run.py"]
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ tables are listed accordingly and license information is extracted and presented
| keep_data_files | If set to `false`, the data files clipped to the spatial and temporal scale will not be kept. |
| precision | The precision for aggregations along the temporal scale of the datasets. |
| resolution | The resolution of the output data. This parameter is only relevant for areal datasets. |
| connection | The connection URI to the MetaCatalog instance. |


## Development and local run
Expand Down
17 changes: 4 additions & 13 deletions src/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
from clip import reference_area_to_file
from version import __version__

# always load .env files
load_dotenv()

# parse parameters
kwargs = get_parameter()

Expand All @@ -30,20 +33,8 @@
if toolname != 'vforwater_loader':
raise AttributeError(f"[{dt.now().isocalendar()}] Either no TOOL_RUN environment variable available, or '{toolname}' is not valid.\n")


# use the pydantic model to handle the input parameters
params = load_params(**kwargs)

# check if a connection was given and if it is a valid path
# this is handled extra to keep the pydantic model simpler
if 'connection' in kwargs:
if Path(kwargs['connection']).exists():
load_dotenv(dotenv_path=kwargs['connection'])
else:
# it is interpreted as a connection uri
connection = kwargs['connection']
else:
load_dotenv()
params = load_params(**kwargs)

# check if a connection evironment variable is given
if 'VFW_POSTGRES_URI' in os.environ:
Expand Down
11 changes: 1 addition & 10 deletions src/tool.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
tools:
vforwater_loader:
title: Loader for datasets stored in a metacatalog instance
title: Dataset Loader
description: |
This tool will use `metacatalog` to load datasets stored in a metacatalog instance, like V-FOR-WaTer.
The requested datasources will be made available in the output directory of the tool. Areal datasets
Expand Down Expand Up @@ -76,12 +76,3 @@ tools:
If the dataset is areal and the parameter is set, the dataset will be resampled to the given resolution.
Note: Right now, the aggregations can only write parquet files. For larger (espeically spatio-temporal) datasets, these
aggreations can be large. A future version will write netCDF or Zarr for these cases.
connection:
type: string
optional: true
description: |
THIS OPTION IS DEPRECATED. PLEASE SET THE ENVIRONMENT VARIABLE METACATALOG_URI INSTEAD.
To connect to the V-FOR-WaTer database, you need to provide a connection URI. These URIs should be saved to an evnironment variable
called `VFW_POSTGRES_URI`. Alternatively, you can pass in a file path to an `.env` file that contains the connection URI.
Passing the string directly as this parameter is technically also possible, but not recommended.

0 comments on commit ffc16db

Please sign in to comment.