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

Prepare FastAPI route for quotas #11315

Merged
merged 23 commits into from
Sep 8, 2021

Conversation

davelopez
Copy link
Contributor

@davelopez davelopez commented Feb 8, 2021

Ref #10889

Overview

  • Added some integration tests for the quotas API.
  • Moved the UserModel from lib/galaxy/managers/users.py to lib/galaxy/schema/schema.py.
  • Introduced the ModelClassField to represent a particular model_class in pydantic models. See additional comments [*].
  • Created pydantic models for quota operations.
  • Prepare the interfaces for QuotaManager and QuotasManager.
  • Added the FastAPI route with all endpoint operations (disabled)

Additional Comments

  • Some of the legacy controller actions return a raw string, which, sometimes, is a ';' separated list of messages. Should this be at least a JSON with an actual list of strings?
  • [*] Now most of the legacy API payloads that involve database entities have an encoded id and an additional model_class field to indicate the type of entity. After modeling every payload with pydantic models, this model_class field will be redundant? or what is the real purpose of this field?

Update

Sorry for the long PR😅

@davelopez
Copy link
Contributor Author

@jmchilton

What do you think would be the correct course of action here?

  1. Leave this PR on hold until [WIP] Implement quota tracking options per ObjectStore. #10977 is merged and then rebase before starting to refactor the managers.
  2. Merge this PR as it is (after fixing all checks and it is approved in review). And then opening a new one for the refactoring tasks after [WIP] Implement quota tracking options per ObjectStore. #10977 is completed.
  3. Maybe a better approach?

@davelopez davelopez force-pushed the prepare_fastapi_route_quotas branch from 2648e28 to a0e7be2 Compare February 12, 2021 19:28
@davelopez davelopez marked this pull request as ready for review February 12, 2021 23:13
@mvdbeek
Copy link
Member

mvdbeek commented Feb 17, 2021

  • After modeling every payload with pydantic models, this model_class field will be redundant? or what is the real purpose of this field?

We still need this if an endpoint returns a union of something and the client needs to know what it is dealing with. A common example is the history endpoint that returns either HistoryDatasetAssociation or HistoryDatasetCollectionAssociation.

  • Some of the legacy controller actions return a raw string, which, sometimes, is a ';' separated list of messages. Should this be at least a JSON with an actual list of strings?

I think that's a case-by-case decision to take. If we do change this we may also have to update whatever frontend component consumes this, and depending on the context (is this likely something external scripts are consuming ?) we would need to provide a route for these legacy consumers (i.e we could add a parameter that controls the response model).

@davelopez davelopez marked this pull request as draft February 23, 2021 14:23
@davelopez davelopez force-pushed the prepare_fastapi_route_quotas branch from a0e7be2 to c0e0ca7 Compare March 1, 2021 11:44
@davelopez davelopez force-pushed the prepare_fastapi_route_quotas branch 2 times, most recently from aa6249f to 8fcefe0 Compare March 2, 2021 14:13
@davelopez davelopez marked this pull request as ready for review March 2, 2021 17:02
@davelopez davelopez force-pushed the prepare_fastapi_route_quotas branch from 8c5cf3d to 1825a6d Compare March 11, 2021 17:44
@davelopez davelopez marked this pull request as draft March 11, 2021 18:13
@davelopez
Copy link
Contributor Author

davelopez commented Mar 16, 2021

Waiting for #11904

@davelopez davelopez mentioned this pull request Apr 13, 2021
3 tasks
@davelopez davelopez modified the milestones: 21.05, 21.09 May 3, 2021
@davelopez davelopez force-pushed the prepare_fastapi_route_quotas branch from 2fbe1bd to 81be6ff Compare June 2, 2021 09:05
@davelopez davelopez marked this pull request as draft June 2, 2021 09:18
davelopez added 2 commits June 2, 2021 13:31
The util.Params object was causing problems with the pydantic deserialization.
@davelopez davelopez marked this pull request as ready for review June 2, 2021 13:23
@jmchilton jmchilton merged commit 62295ef into galaxyproject:dev Sep 8, 2021
@jmchilton
Copy link
Member

Thank you - this looks really, really nice - sorry for the delay in reviewing it.

@bgruening
Copy link
Member

Cool @davelopez congrats! Thanks @jmchilton for reviewing!

@davelopez davelopez deleted the prepare_fastapi_route_quotas branch September 8, 2021 14:15
@davelopez
Copy link
Contributor Author

No worries and many thanks @jmchilton!

nsoranzo added a commit to nsoranzo/galaxy that referenced this pull request Sep 15, 2021
Broken in galaxyproject#11315

Results in the following failure in BioBlend tests:

```
______________________ TestGalaxyQuotas.test_create_quota ______________________

self = <bioblend._tests.TestGalaxyQuotas.TestGalaxyQuotas testMethod=test_create_quota>

    def test_create_quota(self):
        quota = self.gi.quotas.show_quota(self.quota['id'])
        self.assertEqual(quota['name'], self.quota_name)
>       self.assertEqual(quota['bytes'], 107374182400)
E       AssertionError: '107374182400' != 107374182400

bioblend/_tests/TestGalaxyQuotas.py:26: AssertionError
```

See https://github.com/galaxyproject/bioblend/runs/3593283826
@nsoranzo nsoranzo mentioned this pull request Sep 15, 2021
5 tasks
davebx pushed a commit to davebx/galaxy that referenced this pull request Sep 15, 2021
Broken in galaxyproject#11315

Results in the following failure in BioBlend tests:

```
______________________ TestGalaxyQuotas.test_create_quota ______________________

self = <bioblend._tests.TestGalaxyQuotas.TestGalaxyQuotas testMethod=test_create_quota>

    def test_create_quota(self):
        quota = self.gi.quotas.show_quota(self.quota['id'])
        self.assertEqual(quota['name'], self.quota_name)
>       self.assertEqual(quota['bytes'], 107374182400)
E       AssertionError: '107374182400' != 107374182400

bioblend/_tests/TestGalaxyQuotas.py:26: AssertionError
```

See https://github.com/galaxyproject/bioblend/runs/3593283826
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants