Open darinkishore opened 6 months ago
I'm being silly—You can just cast it back into a list, inputs=list(example.inputs)
.
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:
Trace*
, *Record
, and Boxed*
type classes are transparent to the user as they deviate from the expected types in code (at the very least it should be easy to recursively strip away this representation)name
field in our Object
class can conflict with user-defined fields.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 SemanticMemoryExampleDataset.load(...)
to ensure you have the right class.
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.