gdcc / pyDataverse

Python module for Dataverse Software (dataverse.org).
http://pydataverse.readthedocs.io/
MIT License
64 stars 45 forks source link

API fails to handle metadataBlocks: "astrophysics" & "biomedical" #164

Open jmurugan-fzj opened 10 months ago

jmurugan-fzj commented 10 months ago

Bug report

The latest version of dataset-create-new-all-default-fields.json allows also "astrophysics" & "biomedical" related metadata to be populated for a newly created data set. But the present version of src/pyDataverse/models.py does not seem to be capable of handling these metadata blocks.

image

1. Describe your environment

2. Actual behaviour:

    ds = Dataset()
    ds.set({"title": "Test Data Set"})
    ds.set({"license": "CC0 1.0"})
    ds.set({"astroType": ["Mosaic"],
            "astroFacility": ["AIK-2", "AIK-3"],
            "studyDesignType": ["Case Control", "Cross Sectional"],
            "studyAssayOrganism": ["Arabidopsis thaliana", "Bos taurus", "Zea mays"]})
    ds.validate_json()
   native_api.create_dataset(dataverse=dataverse_id, metadata=ds.json(), auth=True)

3. Expected behaviour:

4. Steps to reproduce

  1. Create a new data-set using the method mentioned in the "expected behavior" above
  2. Check the created data set in dataverse to see that the "astrophysics" & "biomedical" metadata are missing..

5. Possible solution

pdurbin commented 10 months ago

I don't mean to speak for @JR-1991 but I believe this is supported by EasyDataverse: https://github.com/gdcc/easyDataverse

JR-1991 commented 10 months ago

@pdurbin, thanks for raising this. The latest version of EasyDatavere now handles metadata configs dynamically, so you can easily get metadata schemes as classes and populate them like any other Python/PyDantic dataclass.

I've tested your use case and created a Jupyter Notebook that shows how to upload metadata to Demo Dataverse. Also, find a small documentation of other features in the flexible-connect branches Readme file.

Let me know if you have any questions 😊

Colab notebook

image

jmurugan-fzj commented 10 months ago

I don't mean to speak for @JR-1991 but I believe this is supported by EasyDataverse: https://github.com/gdcc/easyDataverse

@pdurbin Thanks for the suggestion, does that mean that I have to switch to easyDataverse instead of pyDataverse? Also I guess, there won't be any future pyDataverse extension planned for this support?

@JR-1991 I will try this solution also, thanks for the detailed explanation with the snippets too :+1:

JR-1991 commented 10 months ago

@jmurugan-fzj - For the time being, I suggest using EasyDataverse to work around the issue. However, in the future, you can continue to use PyDataverse since we are currently planning the next version of PyDataverse. This will address a multitude of issues and PRs filed within this repository.

pdurbin commented 10 months ago

we are currently planning the next version of PyDataverse

Please see https://dataverse.zulipchat.com/#narrow/stream/377090-python/topic/PyDataverse.20Re-Vamp/near/404845745 and https://docs.google.com/document/d/15cd_I2caOX5ekJrGI_kTe2KibenMk6kZ4qy9y135_60/edit?usp=sharing