Giter Site home page Giter Site logo

bunnet's People

Contributors

rabarbra avatar roman-right avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

bunnet's Issues

Migration file names

Hi @roman-right,

we've started using this project as an ODM and also for data migrations. It serves its purpose very well! I have a suggestion for you to consider.

It would be great if the name provided by the caller of bunnet new-migration command was sanitized to only contain letters, numbers, and underscores. That way the final file name (module name) would conform to https://peps.python.org/pep-0008/#package-and-module-names

We've had a case where hyphens were used as part of the migration name and it confused IntelliJ IDEA when trying to run a unit test for that module. It would be great if we were guarded against that by the library itself.

I believe this could be changed here:
https://github.com/roman-right/bunnet/blob/748cae319314b55f4683ef5b83f8d154f4cec2df/bunnet/executors/migrate.py#L166

[BUG] Wrong return type of `Document.get`

Describe the bug
The return type of Document.get is Optional["DocType"].
However it always returns cls.find_one(...), which has DocType as returned type.

To Reproduce

class Doc(Document):
    pass
# init bunnet, ...

doc = ~Doc.get(id_) # pyre warning: Undefined attribute [16]: `Optional` has no attribute `__invert__`.
# OR
doc = Doc.get(id_).run() # pyre warning: Undefined attribute [16]: `Optional` has no attribute `run`.

Expected behavior
Document.get should always return DocType

[BUG] Documentation of CurrentDate and others update operators

Describe the bug
For example CurrentDate documentation (here)

class Sample(Document):
    ts: datetime

CurrentDate({Sample.ts, True})

Will return query object like

{"$currentDate": {"ts": True}}

It should be CurrentDate({Sample.ts: True}).

To Reproduce

from bunnet.operators import Set, CurrentDate
print(CurrentDate({Sample.ts, True}))
# {'$currentDate': {True, 'ts'}}

print(CurrentDate({Sample.ts: True}))
# {'$currentDate': {'ts': True}}

Just typo in docstring documentation in file bunnet/odm/operators/update/general.py

toml requirement missing?

Describe the bug
With code that invokes migrations programmatically via run_migrate function using

from bunnet.executors.migrate import run_migrate

the application fails to start with

Exception: ModuleNotFoundError: No module named 'toml'. Please check the requirements.txt file for the missing module.

and the stack ends with

File "C:\myproject\venv\lib\site-packages\bunnet\executors\migrate.py", line 8, in <module>
    import toml

Expected behavior
No need to add additional requirements unless they're documented in bunnet's readme.

Additional context
Listing toml in our requirements.txt fixes this. But we didn't have to do that when using beanie.
Was removing toml requirement intentional in bunnet?

Transactions during migrations

Hi @roman-right,

I have another suggestion for you to consider.

It's related to this code:
https://github.com/roman-right/bunnet/blob/748cae319314b55f4683ef5b83f8d154f4cec2df/bunnet/migrations/runner.py#L145

Overall, we prefer to run migrations in transactions. However, we've hit an issue with CosmosDB - it doesn't support reading from/writing to multiple collections in a single transaction.
Would it be possible to add an option for the migration file to define if it should run in a transaction or not?
It could be a decorator on Forward and Backward classes with default behavior 'use transaction' (for backward compatibility).

Error on import, pydantic V2[BUG]

I get this error when I try to import bunnet to my project:

Traceback (most recent call last):
  File "C:\Users\robin\Desktop\test\test.py", line 1, in <module>
    import bunnet
  File "C:\Users\robin\Desktop\test\venv\lib\site-packages\bunnet\__init__.py", line 1, in <module>
    from bunnet.migrations.controllers.free_fall import free_fall_migration
  File "C:\Users\robin\Desktop\test\venv\lib\site-packages\bunnet\migrations\controllers\free_fall.py", line 4, in <module>
    from bunnet.odm.documents import Document
  File "C:\Users\robin\Desktop\test\venv\lib\site-packages\bunnet\odm\documents.py", line 17, in <module>
    from lazy_model import LazyModel
  File "C:\Users\robin\Desktop\test\venv\lib\site-packages\lazy_model\__init__.py", line 1, in <module>
    from lazy_model.main import LazyModel, NAO
  File "C:\Users\robin\Desktop\test\venv\lib\site-packages\lazy_model\main.py", line 5, in <module>
    from pydantic.error_wrappers import ErrorWrapper
  File "C:\Users\robin\Desktop\test\venv\lib\site-packages\pydantic\_migration.py", line 295, in wrapper
    raise PydanticImportError(f'`{import_path}` has been removed in V2.')
pydantic.errors.PydanticImportError: `pydantic.error_wrappers:ErrorWrapper` has been removed in V2.

For further information visit https://errors.pydantic.dev/2.1.1/u/import-error

Seems like bunnet is not compatible with pydantic V2.
If I use pydantic V1 instead it works.

Are there plans to support pydantic V2? Maybe an intermediate fix could be to limit the package dependency to pydantic V1?

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.