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

[NEAT-734] 👮 Experiment idempotent #1034

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft

Conversation

doctrino
Copy link
Collaborator

@doctrino doctrino commented Mar 4, 2025

Description

Basic idea for how to implement a lock down of the neat session such that the user cannot call the 'wrong' methods. Instead get an appropriate error message.

I think the way to do this is to change the SessionState into something like the following. In other words, control all changes to the state through a change method that validates that you can do the change. For example, you can only import a data model, if you do not already have a data model. Furthermore, all export/load/read is also exposed so we can use that, but we are not allowed to change the state through any other method than change.

class ReadQueriesAPI:
    def list_types(self) -> list[str]:
        ...

class SessionState:
    def __init__(self, client: NeatClient):
        self.instances = ReadQueriesAPI()

    def change(self, action: Action, description: str | None) -> IssueList:
        ...
    
    def export(self, exporter: BaseExporter[T_Export]) -> T_Export:
        ...

    def export_to_file(self, exporter: BaseExporter, path: Path) -> None:
        ...

    def export_to_cdf(self, exporter: CDFExporter, client: NeatClient, dry_run: bool) -> UploadResultList:
        ...
    
    def load(self, loader: BaseLoader) -> UploadResultList:
        ...

Bump

  • Patch
  • Minor
  • Skip

Changelog

Changed/Improved

  • All methods in the NeatSession are now strictly validated.

Copy link

github-actions bot commented Mar 4, 2025

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
15032 12022 80% 60% 🟢

New Files

File Coverage Status
cognite/neat/_store/_manager.py 50% 🟢
TOTAL 50% 🟢

Modified Files

File Coverage Status
cognite/neat/_graph/transformers/init.py 100% 🟢
cognite/neat/_session/_read.py 72% 🟢
cognite/neat/_session/_state.py 78% 🟢
cognite/neat/_store/init.py 100% 🟢
cognite/neat/_store/exceptions.py 68% 🟢
TOTAL 84% 🟢

updated for commit: 20144f7 by action🐍

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.

1 participant