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

[PY-622][PY-626][PY-665] Import Properties (create/update) while importing annotations #759

Merged
merged 22 commits into from
Jan 25, 2024

Conversation

saurbhc
Copy link
Member

@saurbhc saurbhc commented Dec 19, 2023

Problem

  • [PY-622] Import Annotations is missing new Properties import feature (create and update properties)
  • [PY-626] Updates to import endpoint - annotation_properties
  • [PY-665] Update property-value object structure to support un-nested value field

Solution

Implement _import_properties before _import_annotations & add those properties in import annotations API payload.

Changelog

Implement Import Properties (create/update) while importing annotations

@saurbhc saurbhc added the enhancement New feature or request label Dec 19, 2023
@saurbhc saurbhc self-assigned this Dec 19, 2023
Copy link

linear bot commented Dec 19, 2023

@saurbhc saurbhc added the wip label Dec 19, 2023
@saurbhc saurbhc marked this pull request as ready for review December 21, 2023 11:54
@saurbhc saurbhc removed the wip label Dec 22, 2023
Copy link
Contributor

@owencjones owencjones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intricate work, good stuff. Some concern that there are not extra tests for the extra functionality. Reach out to me if there's a reason for that, or if you need backup, and we can sort it together.

@@ -405,13 +405,13 @@ class Property:
name: str

# Type of the property
type: str
type: PropertyType
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wasn't you who did this, but changing this block to a triple quote block instead would be a decent low hanging fruit improvement.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean something like this:

    type: """PropertyType"""

darwin/datatypes.py Show resolved Hide resolved
darwin/future/data_objects/properties.py Show resolved Hide resolved
@@ -267,6 +274,159 @@ def _resolve_annotation_classes(
return local_classes_not_in_dataset, local_classes_not_in_team


def _import_properties(
metadata_path: Union[Path, bool],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this function, I'd (like in the other PR I reviewed), say break this down. I haven't counted the McCabe complexity of this, but it looks like it's quite high. We removed the requirement for lower than 10 complexity because of some older inherited code, but it would be good to apply a higher standard for these lints on this level.

Also, same note on the function names. These can be more explanatory, and refactored with no difficulty.

If you break this down, no need to rewrite tests if it's already adequately covered, as this just becomes social testing of all.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we have some tickets on E2E test on properties import - so testing this function properly should be covered in that.

For the function names, what would you prefer? some examples:

  • _import_properties -> _create_update_properties? - as it Creates/Updates missing/mismatched properties from annotation & metadata.json file to team-properties.
  • _update_payload_with_properties -> _update_annotation_payload_with_properties? - as it updates the annotation import API payload data with annotation-properties data

What are your thoughts on it?

darwin/importer/importer.py Outdated Show resolved Hide resolved
darwin/importer/importer.py Outdated Show resolved Hide resolved
darwin/importer/importer.py Outdated Show resolved Hide resolved
darwin/importer/importer.py Outdated Show resolved Hide resolved
Copy link
Contributor

@Nathanjp91 Nathanjp91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall good code, but I think there's one issue that might come into play and maybe requires changing.

darwin/importer/importer.py Outdated Show resolved Hide resolved
darwin/importer/importer.py Show resolved Hide resolved
darwin/importer/importer.py Outdated Show resolved Hide resolved
* handling properties data while importing annotations

* add tests for _handle_annotation_data

* update importer - add annotations_properties in payload of import annotations

* update importer - rm _handle_properties code

* fix test

* update test

* fix indent

* add the missing return value

* fix issues with multi_select create_property
@saurbhc saurbhc changed the title [PY-622] Import Properties (create/update) while importing annotations [PY-622][PY-626] Import Properties (create/update) while importing annotations Jan 10, 2024
Copy link

linear bot commented Jan 10, 2024

Copy link
Contributor

@AndriiKlymchuk AndriiKlymchuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left couple of comments

@saurbhc saurbhc changed the title [PY-622][PY-626] Import Properties (create/update) while importing annotations [PY-622][PY-626][PY-665] Import Properties (create/update) while importing annotations Jan 22, 2024
Copy link

linear bot commented Jan 22, 2024

@saurbhc saurbhc merged commit 2ab1cef into master Jan 25, 2024
16 checks passed
@saurbhc saurbhc deleted the PY-622 branch January 25, 2024 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants