SuperDuperDB / superduperdb

🔮 SuperDuperDB: Bring AI to your database! Build, deploy and manage any AI application directly with your existing data infrastructure, without moving your data. Including streaming inference, scalable model training and vector search.
https://superduperdb.com
Apache License 2.0
4.54k stars 444 forks source link

[BUG]: Exporting the component in YAML format encountered an error. #2177

Open jieguangzhou opened 2 weeks ago

jieguangzhou commented 2 weeks ago

Contact Details [Optional]

No response

System Information

main

What happened?

from superduperdb import *
from superduperdb.backends.mongodb import MongoQuery
from pprint import pprint
from superduperdb.components.application import Application

class TestModel(Model):
    def predict(self, text):
        return text

model = TestModel(identifier="test_model")

listener = model.to_listener(key="x", select=MongoQuery(table="docs").find())

pprint(listener.encode())

application = Application(
    identifier="metadata_application",
    components=[listener],
)

pprint(application.encode())
pprint(Document.decode(application.encode()).encode())

application.export("test_application", format="yaml")

Steps to reproduce

No response

Relevant log output

Traceback (most recent call last):
  File "/Users/zhouhaha/workspace/SuperDuperDB/superduper-apps/legal_tech_demo/test_encode.py", line 28, in <module>
    application.export("test_application", format="yaml")
  File "/Users/zhouhaha/workspace/SuperDuperDB/superduper-apps/legal_tech_demo/env/lib/python3.11/site-packages/superduperdb/components/component.py", line 405, in export
    yaml.dump(r, stream)
  File "/Users/zhouhaha/workspace/SuperDuperDB/superduper-apps/legal_tech_demo/env/lib/python3.11/site-packages/ruamel/yaml/main.py", line 594, in dump
    return self.dump_all([data], stream, transform=transform)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/zhouhaha/workspace/SuperDuperDB/superduper-apps/legal_tech_demo/env/lib/python3.11/site-packages/ruamel/yaml/main.py", line 604, in dump_all
    self._context_manager.dump(data)
  File "/Users/zhouhaha/workspace/SuperDuperDB/superduper-apps/legal_tech_demo/env/lib/python3.11/site-packages/ruamel/yaml/main.py", line 953, in dump
    self._yaml.representer.represent(data)
  File "/Users/zhouhaha/workspace/SuperDuperDB/superduper-apps/legal_tech_demo/env/lib/python3.11/site-packages/ruamel/yaml/representer.py", line 83, in represent
    node = self.represent_data(data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/zhouhaha/workspace/SuperDuperDB/superduper-apps/legal_tech_demo/env/lib/python3.11/site-packages/ruamel/yaml/representer.py", line 115, in represent_data
    node = self.yaml_representers[None](self, data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/zhouhaha/workspace/SuperDuperDB/superduper-apps/legal_tech_demo/env/lib/python3.11/site-packages/ruamel/yaml/representer.py", line 347, in represent_undefined
    raise RepresenterError(f'cannot represent an object: {data!s}')
ruamel.yaml.representer.RepresenterError: cannot represent an object: {'_base': '?metadata_application', '_builds': {'dill': {'_path': 'superduperdb/components/datatype/get_serializer', 'method': 'dill', 'encodable': 'artifact'}, '67a99890b4ac06372ce99db9013259253eb5ed71': {'_path': 'superduperdb/components/datatype/Artifact', 'datatype': '?dill', 'blob': '&:blob:67a99890b4ac06372ce99db9013259253eb5ed71'}, 'test_model': {'_object': '?67a99890b4ac06372ce99db9013259253eb5ed71'}, 'docs-find': {'_path': 'superduperdb/backends/mongodb/query/parse_query', 'documents': [], 'query': 'docs.find()'}, 'deb014ca-f311-442a-8245-2bdb75a5f0b1': {'_path': 'superduperdb/components/listener/Listener', 'key': 'x', 'model': '?test_model', 'select': '?docs-find'}, 'metadata_application': {'_path': 'superduperdb/components/application/Application', 'components': ['?deb014ca-f311-442a-8245-2bdb75a5f0b1'], '_literals': ['template']}}, '_files': {}}