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
feat(artifacts): add save() method on ArtifactCollection
to allow persisting changes
#7555
feat(artifacts): add save() method on ArtifactCollection
to allow persisting changes
#7555
Conversation
ArtifactCollection
to allow persisting changes
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## amusipatla/artifact-collection-pull-fields #7555 +/- ##
==============================================================================
+ Coverage 75.82% 75.86% +0.04%
==============================================================================
Files 500 500
Lines 54066 54119 +53
==============================================================================
+ Hits 40993 41055 +62
+ Misses 12665 12656 -9
Partials 408 408
Flags with carried forward coverage won't be shown. Click here to find out more.
|
tests/pytest_tests/system_tests/test_artifacts/test_wandb_artifacts.py
Outdated
Show resolved
Hide resolved
71b993e
to
dc3cd1d
Compare
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.
most of the tag-related changes lgtm. just a suggestion regarding the characters that aren't allowed.
…atla/artifact-collection-save
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.
Approving mainly for the tags part. The rest lgtm too, but might want to check with @estellazx or @moredatarequired since they were involved in the api design. Great work! 😄
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.
Thanks for adding the deprecation! LGTM
wandb/apis/public/artifacts.py
Outdated
) | ||
self._type = type | ||
|
||
def save(self) -> None: |
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 have a mild preference for breaking this up somehow, probably by making smaller private functions for each of the GQL operations. It's up to you though, feel free to merge as-is
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.
Looks good, thanks! Only had one question (with a possible suggestion depending on the answer)
@property | ||
def tags(self): | ||
"""The tags associated with the artifact collection.""" | ||
return self._tags | ||
|
||
@tags.setter | ||
def tags(self, tags: List[str]) -> None: | ||
if any(not re.match(r"^[-\w]+([ ]+[-\w]+)*$", tag) for tag in tags): |
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.
question: may have missed this, so looking to understand first -- is the tag allowed to start or end with a hyphen/underscore (e.g. "-this-is-my-tag_"
)? If yes, understood -- just wanted to check
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.
suggestion(if-minor): If no, I think the condition/regex may need to could be stricter here -- up to you -- since it'll consider the above example valid. Possible, rough suggestion below:
if any(not re.match(r"^[-\w]+([ ]+[-\w]+)*$", tag) for tag in tags): | |
if any(not _is_valid_tag(tag) for tag in tags): |
where:
def _is_valid_tag(tag: str) -> bool:
split_tag = re.split(r"[ ]+|[-]+|[_]+", tag)
return all(part.isalnum() for part in split_tag)
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.
good point, it looks like via the UI we're able to start or end tags with hyphens/underscores so I think what we have right now should be fine
…atla/artifact-collection-save
…atla/artifact-collection-save
249c2c5
into
amusipatla/artifact-collection-pull-fields
Description
This PR adds the setter functions for name, type, description, and tags in ArtifactCollection, and adds a save function to persist these changes.
Example usage:
Testing
Added integration tests