-
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
[Question] Is there a way to turn weave objects (tracetables, boxed types, etc....) back into the original python objects? #1602
Comments
I'm being silly—You can just cast it back into a list, |
Hi @darinkishore just wanted to confirm that all is good here and that we can close this? |
Hi! Thank you for checking—My main question is still unresolved! Can you turn weave objects back into their native python objects? Usually to preserve state, some classes can't set everything up at creation time! Also, the changed type of all inside attributes is inconvenient to keep track of and work around in code, especially if I use lots of different weave objects. |
Hi @darinkishore - thank you very much for your feedback and comments. Your request is very reasonable. Reading your use case, I am extracting 3 distinct asks:
Spitballing some API ideas: I wonder if there could be a higher level class method that could make this easier (some pseudo code): class Object():
# ...
@classmethod
def load(cls, data: "Object" | dict | TraceObject) -> "Object":
"""
"""
if isinstance(data, cls):
return data
elif isinstance(data, dict):
return cls.model_validate(dict)
elif isinstance(data, TraceObject):
return cls.load(weave.unwrap(data))
else:
raise this would allow you to run In any case, these are great requests and we need to think about a good design to improve this. Probably need to come back with more ideas/options before taking action |
Internal backlog link: https://wandb.atlassian.net/browse/WB-18889 |
Hi! So I have a weave object, initialized as follows:
The wrapper "SemanticMemoryExampleDataset" is being used because
name
is an already defined attribute forweave.Object
.I'd like to save and load this object, so I run
However,
retrieve_examples
returnsI see that
Boxed
objects have anunbox()
method, so I canunbox
the name, text, and memory by callingfrom weave.box import unbox
andunbox(thing) for thing in list
But I don't see a way to convert
inputs
, aTraceList
back into a native python datatype. Also, the manually converting everything is a hassle—is there a weave function planned (or already existing) that turns the TraceList, TraceTable, etc... objects back into native python datatypes?Loving the library—there were a LOT of good decisions made as far as what to focus on and DX. This is an almost ideal solution for me.
The text was updated successfully, but these errors were encountered: