-
Notifications
You must be signed in to change notification settings - Fork 6
Metadata updates #6
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
Conversation
| try: | ||
| contents[field.name] = t(contents[field.name]) | ||
| except ValueError: | ||
| if field.list and type(value) is list: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here the value is not defined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
| Metadata document that was added to database | ||
| """ | ||
| if (file := await db["files"].find_one({"_id": ObjectId(file_id)})) is not None: | ||
| md = _build_metadata_db_obj(db, metadata_in, FileOut(**file)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got an error here
File "/Users/cwang138/Documents/Clowder/clowder2/backend/app/routers/metadata_files.py", line 98, in add_file_metadata
md = _build_metadata_db_obj(db, metadata_in, FileOut(**file), user)
TypeError: _build_metadata_db_obj() missing 1 required positional argument: 'user'
when trying to attach metadata to a file:
{
"definition": "LatLon",
"contents": {
"longitude":40.123,
"latitude":-88.777
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be fixed
|
|
||
|
|
||
| @router.patch("/{dataset_id}/metadata", response_model=MetadataOut) | ||
| async def update_dataset_metadata( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trying to patch an exist metadata entry by giving the "definition", "metadata id" as well as the "contents". But somehow it's not patching the correct metadata?
My request is
{"id":"628664405685a1694705c863","definition":"LatLon","contents":{"latitude":"111","longitude":"222"}}
and my response is on another metadata definition:
{"id":"6286642c5685a1694705c85f","context":null,"context_url":"clowder.org","definition":null,"contents":{"color":"blue","latitude":"111","longitude":"222"},"resource":{"collection":"datasets","resource_id":"627a8d09ca3d2920a17f602a","version":null},"agent":{"id":"6286642c5685a1694705c860","creator":{"id":"627a8d01ca3d2920a17f6025","email":"[email protected]","first_name":"Chen","last_name":"Wang"},"extractor":null},"created":"2022-05-19T15:37:16.065000"}
| definition = metadata_in.definition | ||
| if definition is not None: | ||
| existing_q = { | ||
| "resource.resource_id": dataset.id, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got an error complaing that dict object doesn't have id field and I looked at the object it has "_id" instead:

I could fix it on but then i looked at similar endpoints on metadata_file.py and saw you are using file.id there and it worked... No sure what's going on here? @max-zilla
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh actually i know... it's missing dataset = DatasetOut(**dataset).
…rk/clowder2 into metadata-updates
Adds additional metadata features including deleting, PUT and PATCH, more validation on metadata definitions.