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

[SYNPY-1415] Folder model finishing touches #1061

Merged
merged 33 commits into from
Feb 12, 2024

Conversation

BryanFauble
Copy link
Contributor

@BryanFauble BryanFauble commented Feb 7, 2024

Problem:

  1. The folder model needed some TLC and bug fixing
  2. We needed to add some more functionality to the Folder model to make it more usable

Solution:

  1. Updating and bug squashing
  2. Writing a sync_from_synapse function in the Folder model
  3. Including a copy method

Testing:

  1. Integration and unit testing
  2. Some initial testing (Obviously more is needed) compared to the synapseutils.syncFromSynapse on a project with 10 files/9 directories:

async: 1.9427805209998041
syncFromSynapse: 3.578380188002484

image

@pep8speaks
Copy link

pep8speaks commented Feb 7, 2024

Hello @BryanFauble! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 823:89: E501 line too long (128 > 88 characters)

Line 36:89: E501 line too long (89 > 88 characters)
Line 353:89: E501 line too long (112 > 88 characters)
Line 387:89: E501 line too long (90 > 88 characters)

Line 52:89: E501 line too long (109 > 88 characters)
Line 93:89: E501 line too long (90 > 88 characters)
Line 97:89: E501 line too long (100 > 88 characters)
Line 123:89: E501 line too long (90 > 88 characters)
Line 132:89: E501 line too long (109 > 88 characters)
Line 169:89: E501 line too long (92 > 88 characters)
Line 176:89: E501 line too long (99 > 88 characters)
Line 183:89: E501 line too long (96 > 88 characters)
Line 193:89: E501 line too long (100 > 88 characters)
Line 194:89: E501 line too long (103 > 88 characters)
Line 405:89: E501 line too long (93 > 88 characters)

Line 337:89: E501 line too long (107 > 88 characters)

Comment last updated at 2024-02-12 16:56:25 UTC

Base automatically changed from SYNPY-1416-file-model to develop February 7, 2024 16:48
@BryanFauble BryanFauble changed the title DRAFT: [SYNPY-1415] Folder model finishing touches [SYNPY-1415] Folder model finishing touches Feb 8, 2024
@BryanFauble BryanFauble marked this pull request as ready for review February 8, 2024 00:29
@BryanFauble BryanFauble requested a review from a team as a code owner February 8, 2024 00:29
@@ -12,6 +12,7 @@ repos:
- id: check-merge-conflict
- id: check-xml
- id: check-yaml
exclude: ^mkdocs\.yml$
Copy link
Contributor Author

Choose a reason for hiding this comment

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

format: !!python/name:pymdownx.superfences.fence_code_format is not valid syntax according this this check-yml check - However, this is the format required for it to work: https://squidfunk.github.io/mkdocs-material/reference/diagrams/#configuration

@@ -2342,27 +2341,28 @@ def getChildren(

- [synapseutils.walk][]
"""
parentId = id_of(parent) if parent is not None else None
with tracer.start_as_current_span("Synapse::getChildren"):
Copy link
Member

Choose a reason for hiding this comment

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

I thought we were using the decorator?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The decorator is not working right for generators - This was the most straight forward solution at the moment to get it working.

@@ -15,6 +15,10 @@ class SynapseFileNotFoundError(SynapseError):
"""Error thrown when a local file is not found in Synapse."""


class SynapseNotFoundError(SynapseError):
Copy link
Member

Choose a reason for hiding this comment

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

Nit: does python base exceptions have something for Not found errors?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did not find one - The closet from: https://docs.python.org/3/library/exceptions.html

were:

  1. FileNotFoundError - Derived from OSError and not applicable in all cases
  2. ModuleNotFoundError - Not really the same thing

synapseclient/models/file.py Outdated Show resolved Hide resolved
synapseclient/models/folder.py Outdated Show resolved Hide resolved
@@ -1,5 +1,9 @@
"""References to the mixins that are used in the Synapse models."""

Copy link
Member

Choose a reason for hiding this comment

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

Out of scope for this ticket but I think there is also a versionable mixin that currently exists in the client.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is this Versionable: https://github.com/Sage-Bionetworks/synapsePythonClient/blob/develop/synapseclient/entity.py#L23

Which is focused on extending data (Multiple Inheritance) rather than extending functionality.

For these models I am already explicitly adding the fields to the dataclasses themselves:
https://github.com/Sage-Bionetworks/synapsePythonClient/blob/develop/synapseclient/models/file.py#L256

It may make sense later on to add a mixin for doing version specific operations later on though - (Read, Delete) for those that support it (Like Table, File)

@@ -63,13 +63,13 @@ def test_json_schema_organization(js):


class TestJsonSchemaSchemas:
@pytest.fixture(autouse=True)
@pytest.fixture(autouse=True, scope="function")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is an effort to resolve these integration test errors:

Semantic version: '0.48786.1' already exists for this JSON schema

That have been popping up. These passed on my local machine - Will be verifying they also pass in the CI pipeline

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can confirm these tests also passed on my machine.

Copy link
Collaborator

@jaymedina jaymedina left a comment

Choose a reason for hiding this comment

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

This looks good. Integration tests pass and I can confirm the poc script for the Folder model works. I had a few comments, but if anything comes out of them, I think it can be for another PR. Don't see anything getting in the way of having this one merged for validation.

Just a note: The provenance of copied entities gets updated with where they were copied from and the version appears to reset, which I believe is expected behavior(?) but want to post here in case not
image

Copy link

sonarcloud bot commented Feb 12, 2024

@BryanFauble BryanFauble merged commit 44fb1d0 into develop Feb 12, 2024
38 checks passed
@BryanFauble BryanFauble deleted the SYNPY-1415-folder-model branch February 12, 2024 21:33
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.

None yet

4 participants