-
Notifications
You must be signed in to change notification settings - Fork 73
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(weave): Make ref-getting more pleasant #3362
Conversation
Preview this PR with FeatureBee: https://beta.wandb.ai/?betaVersion=896d90b9964e9af637a4553d2fce551b5e90edb3 |
ace5c77
to
2102674
Compare
e50012f
to
646dba8
Compare
|
||
res = cls.from_obj(obj) | ||
if ref := getattr(obj, "ref", None): | ||
res.ref = ref |
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.
Not sure if we prefer this or to set obj.__dict__["ref"]
weave/flow/obj.py
Outdated
f"`{cls.__name__}` must implement `from_obj` to support deserialization from a URI." | ||
) | ||
|
||
import weave |
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.
Could we just import the ref method?
Resolves:
This PR:
@register_object
, to register objects that can be converted fromWeaveObject
into their base python classes. This can be used both internally and by end-users.from_uri
to registered objectsref(...).get()
to return the actual python class instead ofWeaveObject
for registered objectsweave.Object
which are initially unset, but can be set when the object is re-created from a refNow you can do: