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

Api shared datamodels #134

Merged
merged 12 commits into from
Aug 5, 2024
Merged

Api shared datamodels #134

merged 12 commits into from
Aug 5, 2024

Conversation

liviuba
Copy link
Contributor

@liviuba liviuba commented Jul 31, 2024

To test:

Actual changes:

  • the one test that creates/gets a study (tests/test_minimal.py)
  • api/private, api/public

@ctr26
Copy link
Contributor

ctr26 commented Aug 1, 2024

@liviuba I've got most of the docker compose changes here in the docker compose branch and I've rebased on this branch to merge them

@liviuba
Copy link
Contributor Author

liviuba commented Aug 1, 2024

@liviuba I've got most of the docker compose changes here in the docker compose branch and I've rebased on this branch to merge them

Thanks, will look at it! Do you want to merge into this before we merge this into main to avoid a re-rebase if we squash&merge this? If you want to merge into main, then I can fastforward main to this branch after the PR is done to merge, and then the docker-compose one shouldn't need another rebase

@ctr26
Copy link
Contributor

ctr26 commented Aug 1, 2024

Happy to it's just got some of your API code in it too now, so it won't be completely clean, but it's all additive so it won't cause obvious problems

@liviuba liviuba requested a review from sherwoodf August 5, 2024 09:46
@liviuba liviuba marked this pull request as ready for review August 5, 2024 09:46
from .models.repository import Repository


router = APIRouter()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should the be using the public tag, like the private one is?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I think I missed it, fixed

from fastapi import APIRouter
from pydantic.alias_generators import to_snake

# ?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha, must have added it as a note because I wasn't sure if importing directly would work out, deleted now

return get_item


for t in models_public:
Copy link
Contributor

@sherwoodf sherwoodf Aug 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

am i right in thinking that this gets run when app.py imports the public and private endpoints? Just wondering whether it would be better python practice to have methods that get explicitly called in app.py...? (This is a question, not a suggestion, i'm genuinely not sure about the implications)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree it would be nice to not run code in global scope at import, was just handwaving the problem until I get an example of a non-generated handler too, so I can see how I'd like to do it but still keep router global (to avoid nesting custom handlers in the factory), and make "the correct way" to use a router easy to tell (e.g. no import first and then a function to attach the generation functionality)

Added a fix, but I'm not sure we'll keep it like this once we have more functionality

Copy link
Contributor

@sherwoodf sherwoodf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks good, but left a couple of comments. Checked it out and it builds locally with the docker command & was able to post & get a study (only got some errors due to the problems with model).

Was able to run the test 'manually' successfully but had issues with pydantic trying to find them - that's going to just be user error though.

Copy link
Contributor

@sherwoodf sherwoodf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@liviuba liviuba merged commit 80bb8d7 into main Aug 5, 2024
32 of 33 checks passed
@liviuba liviuba deleted the api_shared_datamodels branch August 5, 2024 14:05
ctr26 pushed a commit that referenced this pull request Aug 6, 2024
* Rebase api on new main, new v2 wip module root

* Add post handler, fix scoping

* wip

* wip rebase on remote branch & add wip work for actually saving data

* Add date codec

* Add first passing create/get test

* Add all models

* Speedup successive api builds

* Fix GET * typing

* Add public tag to public router

* Delete ?

* Add router factory
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.

3 participants