-
Notifications
You must be signed in to change notification settings - Fork 52
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
artifact link #1363
artifact link #1363
Conversation
a90b2e2
to
f2716f1
Compare
It looks good, just not sure, how to support the overwrite args. |
Hi @elronbandel , |
The issue is old code with references to deprecated catalog names. |
src/unitxt/artifact.py
Outdated
@@ -412,6 +412,18 @@ def get_raw(obj): | |||
return shallow_copy(obj) | |||
|
|||
|
|||
class ArtifactLink(Artifact): | |||
new_artifact: Artifact | |||
is_self_deprecated: bool |
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.
In think deprecation and linking are distinct properties.
We can deprecate something without having a new link to it. So every artifact should have a deprecated field.
2878941
to
871ebaf
Compare
@yoavkatz , @elronbandel , I tried to address both your valuable comments. Please see. |
306bc37
to
09b6611
Compare
src/unitxt/artifact.py
Outdated
@@ -138,6 +139,14 @@ class Artifact(Dataclass): | |||
) | |||
__id__: str = InternalField(default=None, required=False, also_positional=False) | |||
|
|||
__is_deprecated__: bool = NonPositionalField( |
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.
We should add description of the features to the
https://www.unitxt.ai/en/latest/docs/saving_and_loading_from_catalog.html
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.
@yoavkatz , I removed field __is_deprecated__
altogether, since we already have the @deprecation
decorator from deprecation_utils
. Decorating class RenameFields
, for example.
Yet, I added a test that combines deprecation with links.
And moved the link to the other Artifact to class ArtifactLink
as you suggested.
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 Dafna.
There is a difference between deprecating a class and deprecating an instance.
For example, I can have a card saved as "card.sst" and at some point I want to call it "card.sst2".
I want to make the change be backward compatible, so "cards.sst" becomes a deprecated with warning. It is also replaced with ArtficactLink to "card.sst2".
Note that "Card" class was never deprecated
I also think a link should always be to acatalog entry and not an object.
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.
Thank you, Yoav,
I hope I got it better now.. The easy thing was only allowing a link to be expressed as a catalog-entry id.
What I was not sure about is what to do with the 'deprecated bit' that is now back into Artifact
's fields.
For now, I implemented the bit as a string | None. I.e.: if None then not deprecated, and if string - is deprecated. In such a case, a warning message, being that string, is logged as a Warn, when the artifact's prepare(self)
is run. That's the only sanction..
22781e2
to
8a2cfb9
Compare
c3931a7
to
33fc54a
Compare
src/unitxt/artifact.py
Outdated
return Artifact.load(artifact_rep), None | ||
artifact_to_return = Artifact.load(artifact_rep) | ||
if isinstance(artifact_rep, ArtifactLink): | ||
artifact_to_return = artifact_to_return.artifact_linked_to |
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 here. The fetch_artificat should return the artificat, not the name of the artifact we link to.
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.
Hi @yoavkatz , and thanks again for your neat idea about the dedicated load
of ArtifactLink
. I just expanded it to also allow link to link to link (imagine that.. with the overwrites
that @elronbandel emphasized floating all the way over the links in the middle, until they can be applied on the final, non-link Artifact
that can digest them - only it is expected to have these keys that show in the overwrites).
And thanks for your new comment. I see what you mean, and hope I put it right now, backed with many tests. Please see, and suggest any test you see fit.
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.
Hi @yoavkatz , I also added the requested documentation:
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! I've added some followup feedback.
97ce658
to
86f2dd1
Compare
4676b32
to
117080d
Compare
Signed-off-by: dafnapension <[email protected]>
Signed-off-by: dafnapension <[email protected]>
…y to the final target artifact, which is the only one that can digest them. Signed-off-by: dafnapension <[email protected]>
…he target of the link Signed-off-by: dafnapension <[email protected]>
Signed-off-by: dafnapension <[email protected]>
Signed-off-by: dafnapension <[email protected]>
Signed-off-by: dafnapension <[email protected]>
Signed-off-by: dafnapension <[email protected]>
Signed-off-by: Yoav Katz <[email protected]>
Added example of links in catalog. Signed-off-by: Yoav Katz <[email protected]>
Signed-off-by: Yoav Katz <[email protected]>
Signed-off-by: dafnapension <[email protected]>
Signed-off-by: dafnapension <[email protected]>
Signed-off-by: dafnapension <[email protected]>
89b3bcf
to
3a95494
Compare
Signed-off-by: dafnapension <[email protected]>
Hi @yoavkatz , I fought the red color, but I think I won. please let me know if this is anywhere near what you had in mind. The deprecation msg is printed at the top of the artifact documentation. which also shows on the dir level: |
Thanks Dafna. Looking good. Two suggestions:
|
Hi @yoavkatz , how's this: ? Please point for me where you see the |
…side the yanl Signed-off-by: dafnapension <[email protected]>
Signed-off-by: dafnapension <[email protected]>
Signed-off-by: dafnapension <[email protected]>
Thanks for the great work. Once it finishes testing , I'll merge it. |
* artifact link Signed-off-by: dafnapension <[email protected]> * riding on recursive_load to allow overwrites with links Signed-off-by: dafnapension <[email protected]> * prepare for replacement sitting in a different catalog Signed-off-by: dafnapension <[email protected]> * removed __is_deprecated__ and moved the link to a dedicated class ArtifactLink Signed-off-by: dafnapension <[email protected]> * link only via catalog-entry id, deprecation msg for individual artifacts, not only classes Signed-off-by: dafnapension <[email protected]> * added a dedicated load() for ArtifactLink, per yoav's suggestion Signed-off-by: dafnapension <[email protected]> * a cleaner separation Signed-off-by: dafnapension <[email protected]> * allow link to link to link.. with the overwriting floating all the way to the final target artifact, which is the only one that can digest them. Signed-off-by: dafnapension <[email protected]> * test ultimate instantiation of ArtifactLink to an Actual Artifact - the target of the link Signed-off-by: dafnapension <[email protected]> * artifact_linked_to is a required field Signed-off-by: dafnapension <[email protected]> * added documentation to Tutorials Signed-off-by: dafnapension <[email protected]> * reworded documentation some Signed-off-by: dafnapension <[email protected]> * check validity of artifact_linked_to before fetching by it Signed-off-by: dafnapension <[email protected]> * Added example of deprecation of an asset Signed-off-by: Yoav Katz <[email protected]> * Made link a position field in ArtificatLink. Added example of links in catalog. Signed-off-by: Yoav Katz <[email protected]> * Fixed typo. Signed-off-by: Yoav Katz <[email protected]> * rephrased documentation per Yoav's suggestions, and added a test Signed-off-by: dafnapension <[email protected]> * made explanation rst-friendly Signed-off-by: dafnapension <[email protected]> * some suggested changes I missed before Signed-off-by: dafnapension <[email protected]> * red deprecation Signed-off-by: dafnapension <[email protected]> * show deprecation message only at the top of the documentation, not inside the yanl Signed-off-by: dafnapension <[email protected]> * also leave the existing removal of __tags__ and __description__ Signed-off-by: dafnapension <[email protected]> * deprecated regular asset Signed-off-by: dafnapension <[email protected]> --------- Signed-off-by: dafnapension <[email protected]> Signed-off-by: Yoav Katz <[email protected]> Co-authored-by: Yoav Katz <[email protected]>
closes: #1341