Skip to content
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

Corrected the documentation at https://docs.superduperdb.com/docs/docs/minimum_working_example #1296

Merged
merged 3 commits into from
Nov 17, 2023

Conversation

frozenmafia
Copy link
Contributor

Description

Related Issues

Checklist

  • Is this code covered by new or existing unit tests or integration tests?
  • Did you run make test successfully?
  • Do new classes, functions, methods and parameters all have docstrings?
  • Were existing docstrings updated, if necessary?
  • Was external documentation updated, if necessary?

Additional Notes or Comments

@blythed
Copy link
Collaborator

blythed commented Nov 15, 2023

@frozenmafia thanks for the contribution!
I think you still need to add the Encoder right?

@frozenmafia
Copy link
Contributor Author

@frozenmafia thanks for the contribution! I think you still need to add the Encoder right?
Yes, but when I use encoder I get this error.

@blythed
Copy link
Collaborator

blythed commented Nov 15, 2023

@frozenmafia thanks for the contribution! I think you still need to add the Encoder right?
Yes, but when I use encoder I get this error.

db.execute(c.insert_many(), encoders=(e,))

@blythed
Copy link
Collaborator

blythed commented Nov 15, 2023

@frozenmafia thanks for the contribution! I think you still need to add the Encoder right?
Yes, but when I use encoder I get this error.

db.execute(c.insert_many(), encoders=(e,))

(We changed this)

@frozenmafia
Copy link
Contributor Author

frozenmafia commented Nov 15, 2023

@blythed I am sorry , I think I have misunderstood something.I followed from here . I do not know what that e means.
If I use encoders it tells that it is an unexpected keyword argument. Here is the link

import numpy as np
from mongomock import MongoClient
from superduperdb.base.document import Document as D
from superduperdb.components.model import Model
from superduperdb.ext.numpy import array
from superduperdb.backends.mongodb.query import Collection
import superduperdb as s

db = s.superduper(MongoClient().documents)
collection = Collection('docs')

a = array('float64', shape=(32,))
db.add(a)

db.execute(
    collection.insert_many([
        D({'x': a(np.random.randn(32))})
        for _ in range(100)
    ])
)

model = Model(
    identifier='test-model',
    object=lambda x: x + 1,
    encoder=a,
)

model.predict(X='x', db=db, select=collection.find())

print(db.execute(collection.find_one()))

@blythed
Copy link
Collaborator

blythed commented Nov 15, 2023

@blythed I am sorry , I think I have misunderstood something.I followed from here . I do not know what that e means. If I use encoders it tells that it is an unexpected keyword argument. Here is the link

import numpy as np
from mongomock import MongoClient
from superduperdb.base.document import Document as D
from superduperdb.components.model import Model
from superduperdb.ext.numpy import array
from superduperdb.backends.mongodb.query import Collection
import superduperdb as s

db = s.superduper(MongoClient().documents)
collection = Collection('docs')

a = array('float64', shape=(32,))
db.add(a)

db.execute(
    collection.insert_many([
        D({'x': a(np.random.randn(32))})
        for _ in range(100)
    ])
)

model = Model(
    identifier='test-model',
    object=lambda x: x + 1,
    encoder=a,
)

model.predict(X='x', db=db, select=collection.find())

print(db.execute(collection.find_one()))

Sorry I meant encoders=(a,).

@frozenmafia
Copy link
Contributor Author

@blythed I have seen my mistake . There was some error in the bracket. I have corrected that and updated the code.

@blythed
Copy link
Collaborator

blythed commented Nov 17, 2023

Great first contribution @frozenmafia! Keep it coming!

@blythed blythed merged commit 9d24957 into superduper-io:main Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants