Skip to content

Commit

Permalink
Feature/gra 900 server side api capabilities (#763)
Browse files Browse the repository at this point in the history
*grAI
  • Loading branch information
ieaves authored Nov 11, 2023
1 parent 5ab53f8 commit df79ca2
Show file tree
Hide file tree
Showing 13 changed files with 752 additions and 144 deletions.
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 @@ def edge_model_to_edge_v1_schema(model: Edge, schema_type: Literal["EdgeV1"]) ->
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)


@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]
Loading

0 comments on commit df79ca2

Please sign in to comment.