Giter Site home page Giter Site logo

Comments (5)

Andrew-S-Rosen avatar Andrew-S-Rosen commented on July 22, 2024 1

Apologies for not being clear. I was knee deep in debugging and being too brief.

Yes, I would recommend having an automatically generated _id field if the user passed task_id=None. In the original example with MontyStore, and _id was automatically generated already. For the JSONStore, there is no such _id field. But I would support this automatic implementation in Store.

from maggma.

rkingsbury avatar rkingsbury commented on July 22, 2024

Good point @arosen93 . Maybe we could implement this in Store.__init__ such that if you set key=None then the _id field is used by default?

This would require us to manually create ObjectID whenever not using an actual MongoDB - backed store.

from maggma.

Andrew-S-Rosen avatar Andrew-S-Rosen commented on July 22, 2024

That seems like a logical approach to me!

from maggma.

Andrew-S-Rosen avatar Andrew-S-Rosen commented on July 22, 2024

Motivation for not defaulting to _id: not all Stores have or use _id.

from maggma.stores import JSONStore

with JSONStore("test.json", read_only=False) as store:
    store.update({"test": "hi"})

doesn't work and

from maggma.stores import JSONStore

with JSONStore("test.json", read_only=False) as store:
    store.update({"task_id": "hello", "test": "hi"})

does work and yields a file that contains

[{"task_id": "hello", "test": "hi"}]

with no _id.

from maggma.

rkingsbury avatar rkingsbury commented on July 22, 2024

Motivation for not defaulting to _id: not all Stores have or use _id.

I'm not sure I understand your point in this example. Is the recommended behavior still to default to an automatically generated _id field if the user passes task_id=None? Obviously we would need to implement this in the base Store class so that it would always be assigned if needed.

from maggma.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.