Skip to content

Commit

Permalink
Updating dependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
jgadling committed Jan 15, 2025
1 parent 09218c4 commit 0eb2531
Show file tree
Hide file tree
Showing 11 changed files with 2,057 additions and 1,895 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build-and-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,3 @@ jobs:
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ The libraries and tools that make Platformics work:
5. Run `make token` to generate an authorization token that you can use to interact with the API. The `make` target copies the necessary headers to the system clipboard. Paste the token into the `headers` section at the bottom of the GraphQL explorer API

## Versioning platformics
Platformics can be used in downstream applications by
Platformics can be used in downstream applications by
1) using the platformics image as the base Docker image. To select a version of platformics, add the appropriate version tags to the docker image
2) installing as a dependency, `pip install platformics`.

Expand Down
4 changes: 2 additions & 2 deletions platformics/cli/generate_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import click

from platformics.security.token_auth import create_token
from platformics.settings import Settings
from platformics.settings import APISettings


@click.group()
Expand Down Expand Up @@ -47,7 +47,7 @@ def auth() -> None:
)
@click.pass_context
def generate_token(ctx: click.Context, userid: int, project: list[str], expiration: int) -> None:
settings = Settings.model_validate({})
settings = APISettings.model_validate({})
private_key = settings.JWK_PRIVATE_KEY

project_roles: dict[str, list[int]] = {"member": [], "owner": [], "viewer": []}
Expand Down
4 changes: 2 additions & 2 deletions platformics/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from platformics.codegen.generator import generate
from platformics.security.token_auth import create_token
from platformics.settings import Settings
from platformics.settings import APISettings


@click.group()
Expand Down Expand Up @@ -76,7 +76,7 @@ def auth() -> None:
)
@click.pass_context
def generate_token(ctx: click.Context, userid: int, project: list[str], expiration: int) -> None:
settings = Settings.model_validate({})
settings = APISettings.model_validate({})
private_key = settings.JWK_PRIVATE_KEY

project_roles: dict[str, list[int]] = {"member": [], "owner": [], "viewer": []}
Expand Down
35 changes: 15 additions & 20 deletions platformics/graphql_api/core/strawberry_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,27 +61,22 @@ async def resolve_async(
except AttributeError:
request.context = {"dependency_cache": {}}

if not request.scope.get("sberrystack"):
async with AsyncExitStack() as async_exit_stack:
request.scope["sberrystack"] = AsyncExitStack()

solved_result = await deputils.solve_dependencies(
request=request,
dependant=self.dependant,
body={},
dependency_overrides_provider=request.app,
dependency_cache=request.context["dependency_cache"],
async_exit_stack=request.scope["sberrystack"],
)
(
solved_values,
_, # solver_errors. It shouldn't be possible for it to contain
# anything relevant to this extension.
_, # background tasks
_, # the subdependency returns the same response we have
new_cache, # sub_dependency_cache
) = solved_result
solved_result = await deputils.solve_dependencies(
request=request,
dependant=self.dependant,
body={},
dependency_overrides_provider=request.app,
dependency_cache=request.context["dependency_cache"],
async_exit_stack=async_exit_stack,
embed_body_fields=False,
)
solved_values = solved_result.values
new_cache = solved_result.dependency_cache
request.context["dependency_cache"].update(new_cache)

request.context["dependency_cache"].update(new_cache)
kwargs = solved_values | kwargs # solved_values has None values that need to be overridden by kwargs
res = await next_(source, info, **kwargs)
kwargs = solved_values | kwargs # solved_values has None values that need to be overridden by kwargs
res = await next_(source, info, **kwargs)
return res
7 changes: 6 additions & 1 deletion platformics/graphql_api/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ def get_graphql_name(self, obj: HasGraphQLName) -> str:
return super().get_graphql_name(obj)


def get_app(settings: APISettings, schema: strawberry.Schema, db_module: typing.Any, dependencies: typing.Optional[typing.Sequence[Depends]] = []) -> FastAPI:
def get_app(
settings: APISettings,
schema: strawberry.Schema,
db_module: typing.Any,
dependencies: typing.Optional[typing.Sequence[Depends]] = [],
) -> FastAPI:
"""
Make sure tests can get their own instances of the app.
"""
Expand Down
1 change: 0 additions & 1 deletion platformics/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ class APISettings(Settings):
DEFAULT_UPLOAD_BUCKET: str
DEFAULT_UPLOAD_PROTOCOL: str


@cached_property
def JWK_PRIVATE_KEY(self) -> jwk.JWK: # noqa: N802
key = None
Expand Down
Loading

0 comments on commit 0eb2531

Please sign in to comment.