I was playing with the library and noticed the following: When creating an object of type Dataset with type=DatasetType.raw, then calling its .dict() method, the principalInvestigator and creationLocation fields go missing. I think this might be related to #25?
Here is some example code:
from datetime import datetime
from pathlib import Path
from pprint import pprint
from pyscicat._version import get_versions
from pyscicat.model import Dataset, DatasetType, Ownable
ownable = Ownable(ownerGroup="abc", accessGroups=["abc", "def"])
file = Path("/data/some-dataset/foo.txt")
file_metadata = {"foo": "bar", "fizz": 3, "buzz": 5, "fizzbuzz": [3, 5]}
dataset = Dataset(
path=str(file),
size=33, # in bytes
owner="John Doe",
contactEmail="j.doe@localhost",
creationLocation="computer",
creationTime=str(datetime.now()),
type=DatasetType.raw,
dataFormat="txt",
principalInvestigator="John Doe",
sourceFolder=str(file.parent),
scientificMetadata=file_metadata,
keywords=["playground", "test"],
**ownable.dict(),
)
pprint(get_versions())
print()
print(f'{"principalInvestigator" in dataset.dict() = }')
print(f'{"creationLocation" in dataset.dict() = }')
print()
pprint(dataset.dict())
As you can see, the mentioned attributes are gone. When going ahead and passing this to ScicatClient.upload_raw_dataset(), this causes the following error:
pyscicat.client.ScicatCommError: Error creating raw dataset {'statusCode': 422, 'name': 'ValidationError', 'message': "The `RawDataset` instance is not valid. Details: `principalInvestigator` can't be blank (value: undefined); `creationLocation` can't be blank (value: undefined).", 'details': {'context': 'RawDataset', 'codes': {'principalInvestigator': ['presence'], 'creationLocation': ['presence']}, 'messages': {'principalInvestigator': ["can't be blank"], 'creationLocation': ["can't be blank"]}}}
I think I may have used the library wrong. I blindly copy-pasted the code from your guide without realising it refers to an ancient version of the library. Maybe you could update the page?
Hi,
I was playing with the library and noticed the following: When creating an object of type
Dataset
withtype=DatasetType.raw
, then calling its.dict()
method, theprincipalInvestigator
andcreationLocation
fields go missing. I think this might be related to #25?Here is some example code:
Executing this with Python 3.10.6 yields:
As you can see, the mentioned attributes are gone. When going ahead and passing this to
ScicatClient.upload_raw_dataset()
, this causes the following error: