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

Issues with migrating data_catalog to v1 #1078

Open
2 tasks done
veenstrajelmer opened this issue Sep 30, 2024 · 0 comments
Open
2 tasks done

Issues with migrating data_catalog to v1 #1078

veenstrajelmer opened this issue Sep 30, 2024 · 0 comments
Labels
Bug Something isn't working Needs refinement issue still needs refinement

Comments

@veenstrajelmer
Copy link
Collaborator

veenstrajelmer commented Sep 30, 2024

HydroMT version checks

  • I have checked that this issue has not already been reported.
  • I have checked that this bug exists on the latest version of HydroMT.

Reproducible Example

In the process of updating hydromt_delft3dfm to support hydromt v1 (Deltares/hydromt_delft3dfm#162), I am running into numerous problems. The most reproducible one is with reading a model from a yml file with a local data_catalog yml:

    model = DFlowFMModel(
        root=join(EXAMPLEDIR, "dflowfm_local"), 
        mode="r", 
        data_libs=[join(TESTDATADIR, "test_data.yaml")]
    )

The yml files are available at https://github.com/Deltares/hydromt_delft3dfm/tree/main/tests/data

Minimal hydromt code to reproduce:

from hydromt.data_catalog import DataCatalog
# from https://github.com/Deltares/hydromt_delft3dfm/blob/8862432e235ff5740c83dd322d76d22f6b22271b/tests/data/test_data.yaml
dcat = DataCatalog(data_libs=[r"c:\DATA\hydromt_delft3dfm\tests\data\test_data.yaml"])

Current behaviour

I got several validation errors:

ValidationError: 5 validation errors for GeoDataFrameSource
uri
  Field required [type=missing, input_value={'driver': 'vector', 'pat...\\data', 'metadata': {}}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.9/v/missing
driver
  Value error, Unknown 'name': 'vector' [type=value_error, input_value='vector', input_type=str]
    For further information visit https://errors.pydantic.dev/2.9/v/value_error
path
  Extra inputs are not permitted [type=extra_forbidden, input_value='local_data/1D_rivers.geojson', input_type=str]
    For further information visit https://errors.pydantic.dev/2.9/v/extra_forbidden
crs
  Extra inputs are not permitted [type=extra_forbidden, input_value='32647', input_type=str]
    For further information visit https://errors.pydantic.dev/2.9/v/extra_forbidden
rename
  Extra inputs are not permitted [type=extra_forbidden, input_value={'BRANCH_ID': 'branchid', 'BR_TYPE': 'branchtype'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.9/v/extra_forbidden

I could work around all these, but have some suggestions to improve this migration for others.

Desired behaviour

After some digging, I read on https://github.com/Deltares/hydromt/blob/main/docs/guides/plugin_dev/migrating_to_v1.rst, that I convert the data catalog with https://github.com/Deltares/hydromt/blob/main/scripts/migrate_catalog_to_v1.py. Useful setup, but:

  • It would be more useful to raise an error that an old datacatalog is supplied which is not supported
  • It would be very helpful if the script would be integrated into hydromt, so one can just call it as a function. Numerous people will have to do this.
  • If both the above things are implemented, you could also even consider supporting old data catalogs.
  • I had to set “driver=raster” with every RasterDataset, hydromt<1 did not require this so it would be convenient if it would be resolved automatically in the migration function/script.
  • Would be great to get the name of the dataset that is imported before the list of validationerrrors are given, makes it easier to find what is wrong. This was quite some trial and error now.
  • “meta: null” was added as first line, resulting in AttributeError: 'NoneType' object has no attribute 'get'
@veenstrajelmer veenstrajelmer added Bug Something isn't working Needs refinement issue still needs refinement labels Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Needs refinement issue still needs refinement
Projects
None yet
Development

No branches or pull requests

1 participant