-
Notifications
You must be signed in to change notification settings - Fork 67
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
[SYNPY-1414] Project model finishing touches #1067
[SYNPY-1414] Project model finishing touches #1067
Conversation
Hello @BryanFauble! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2024-02-15 21:20:43 UTC |
docs/scripts/object_orientated_programming_poc/oop_poc_project.py
Outdated
Show resolved
Hide resolved
Quality Gate passedIssues Measures |
|
||
|
||
def merge_dataclass_entities( | ||
source: typing.Union["Project", "Folder"], |
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 can see this function being helpful for any Entities that support annotations. (File, Table, Dataset, etc). Not sure if we need to add it in right here, but just a note
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.
Agreed - Since the FileEntity is currently doing this is a special path in syn.store I did not add this there yet. I intend that we'll follow a similar pattern of all Entities.
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.
Do you think that there is an "annotation" mixIn here where the classes that can have annotations can do something like sets in python and have .update
functionality?
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.
Can you elaborate a bit more on your thoughts on this? I see what sets is doing, but I'm unclear what you mean about applying it in this use-case.
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.
Hmm, I didn't realize that dataclasses
had implemented the __eq__
and __hash__
under the hood. I was wondering if its possible to just do something like
MyFileEntity.update(MySecondFileEntity)
and it would just update the annotations.
It may be helpful to be able to do set
operations on groups of entities, but I just haven't done that yet.
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.
MyFileEntity.update(MySecondFileEntity) and it would just update the annotations.
I don't think so in this case because we are setting annotations to be a dict. This function was built out of the need that dataclasses didn't have any nifty mechanism I could find that would do a merge.
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.
🔥 Nice work here! I'm going to pre-approve, just some minor comments.
@@ -324,6 +370,8 @@ async def copy( | |||
parent_id: str, | |||
copy_annotations: bool = True, | |||
exclude_types: Optional[List[str]] = None, | |||
file_update_existing: bool = False, |
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 makes sense in a Folder context, but you can also update existing projects, tables, and other entities.
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.
Per this documentation here - It is explicit that updateExisting is only applicable in the case of a File copy. Agreed on the Table front - However, the boolean isn't being used during a table copy.
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.
Shows how much I remember for a function I wrote. 🙃
@@ -113,25 +120,25 @@ class Project(AccessControllable, StorableContainer): | |||
concurrent updates. Since the E-Tag changes every time an entity is updated it | |||
is used to detect when a client's current representation of an entity is out-of-date.""" | |||
|
|||
created_on: Optional[str] = None | |||
"""The date this entity was created.""" | |||
created_on: Optional[str] = field(default=None, compare=False) |
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.
TIL: compare=False
- very neat!
copy_annotations: bool = True, | ||
copy_wiki: bool = True, | ||
exclude_types: Optional[List[str]] = None, | ||
file_update_existing: bool = False, |
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.
Same comment as above, now that this is on a project level, there's other entities that can be updated beyond files
can_search = ( | ||
entity.id | ||
or ( | ||
entity.name and (entity.__class__.__name__ == "Project" or entity.parent_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.
Nit: Is this where you can use isinstance(entity, Project)
?
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.
Yes - However I had implemented it this way to prevent circular imports. I could have done a lazy import above this line, but this also works.
…ds (#1068) * Sync interface for all async methods
Problem:
is_restricted
flag at the folder level that gets passed to syn.store()createOrUpdate
) we did so only after we got an HTTP 409 conflict, but only if we did not specify the ID of the resource. This led to inconsistent behavior if you supplied an ID, instead of a name when saving resources like the Project.Solution:
is_restricted
flag to the folder levelTesting: