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

Fix optional properties in LocalFile.serialize_v2() #615

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

rikroe
Copy link

@rikroe rikroe commented Jun 13, 2023

Problem

I tried to upload a file to a V7 2.0 dataset and wanted to add a tag to it while uploading.

local_file = LocalFile("~/test.png", tags=["some-tag"])
dataset.push([local_file])

While the image is uploaded correctly, no tags are set.

Incorrect behavior of darwin-py==0.8.27

>>> local_file.serialize_v2()
{'slots': [{'file_name': 'test.png', 'slot_name': '0', 'tags': ['some-tag']}],
 'name': 'test.png',
 'path': '/'}

Fixed behavior

>>> local_file.serialize_v2()
{'slots': [{'file_name': 'test.png', 'slot_name': '0'}],
 'name': 'test.png',
 'path': '/',
 'tags': ['some-tag']}

Solution

Store optional_properties on the dictionary root instead of slots[0] (c.f. Register data for proceessing).

Example cURL request from the 2.0 REST API
curl --request POST \
     --url https://darwin.v7labs.com/api/v2/teams/my-team/items/register_existing \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
  "items": [
    {
      "path": "/",
      "name": "test.png",
      "slots": [
        {
          "as_frames": false,
          "extract_views": false,
          "file_name": "test.png"
        }
      ],
      "tags": [
        "some-tag"
      ]
    }
  ],
  "options": {
    "force_tiling": false,
    "ignore_dicom_layout": true
  },
  "dataset_slug": "my-dataset"
}
'

Changelog

  • Fix LocalFile serialization for v7 2.0

@rikroe
Copy link
Author

rikroe commented Jun 13, 2023

Additional note: just realized that the REST API does allow for a slot to be tagged as well:

Screenshot from V7 REST API docs ![image](https://github.com/v7labs/darwin-py/assets/42204099/92fc7aed-d684-4dc4-9384-2cfb9dafdadf)

However when uploading just one image/slot, the tag was not applied to the whole image/not visible in the UI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant