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

Feature/gra 900 server side api capabilities #763

Merged
merged 12 commits into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions grai-server/app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ RUN apt update \
&& ACCEPT_EULA=Y apt-get install -y msodbcsql18 \
&& rm -rf /var/lib/apt/lists/*


ENTRYPOINT ["/usr/src/app/entrypoint.sh"]

# --------- final images --------------- #
Expand Down
13 changes: 12 additions & 1 deletion grai-server/app/connections/adapters/schemas.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pprint
from typing import Any, List, Literal, Optional, Sequence, Type
from uuid import UUID

from django.db.models.query import QuerySet
from django.db.models import Q
from grai_schemas.v1.edge import EdgeSpec, EdgeV1, SourcedEdgeSpec, SourcedEdgeV1
from grai_schemas.v1.node import (
Expand Down Expand Up @@ -216,3 +216,14 @@
model_dict["destination"] = NodeNamedID(**model.destination.__dict__)
model_dict["destination"] = {"id": model_dict.pop("destination_id")}
return EdgeV1.from_spec(model_dict)


@model_to_schema.register
def sequence_model_to_sequence_v1_schema(models: list | tuple, schema_type: str) -> list | tuple:
iter = (model_to_schema(model, schema_type) for model in models)
return type(models)(iter)

Check warning on line 224 in grai-server/app/connections/adapters/schemas.py

View check run for this annotation

Codecov / codecov/patch

grai-server/app/connections/adapters/schemas.py#L223-L224

Added lines #L223 - L224 were not covered by tests


@model_to_schema.register
def queryset_to_sequence_v1_schema(models: QuerySet, schema_type: str) -> list:
return [model_to_schema(model, schema_type) for model in models]

Check warning on line 229 in grai-server/app/connections/adapters/schemas.py

View check run for this annotation

Codecov / codecov/patch

grai-server/app/connections/adapters/schemas.py#L229

Added line #L229 was not covered by tests
Loading
Loading