Skip to content

Commit

Permalink
fixed requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
jhnnsrs committed Oct 25, 2024
1 parent 50d0010 commit 03f04f1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion fakts/base_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@


class Requirement(BaseModel):
key: str
service: str
""" The service is the service that will be used to fill the key, it will be used to find the correct instance. It needs to fullfill
the reverse domain naming scheme"""
Expand All @@ -35,7 +36,7 @@ class Manifest(BaseModel):
""" The logo is a url to a logo that should be used for the client. """
scopes: Optional[list[str]] = Field(default_factory=list)
""" The scopes are a list of scopes that the client can request. """
requirements: Optional[dict[str, Requirement]] = Field(default_factory=dict)
requirements: Optional[List[Requirement]] = Field(default_factory=list)
""" The requirements are a list of requirements that the client needs to run on (e.g. needs GPU)"""


Expand Down
2 changes: 1 addition & 1 deletion fakts/graphql/mutations/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def create_developmental_client(info: Info, input: inputs.DevelopmentClientInput
version=input.manifest.version,
logo=input.manifest.logo,
scopes=input.manifest.scopes or [],
requirements={x.key: Requirement(service=x.service, optional=x.optional, description=x.description) for x in input.requirements},
requirements=[strawberry.asdict(x) for x in input.requirements],
)

client = create_client(
Expand Down
10 changes: 5 additions & 5 deletions fakts/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ def find_instance_for_requirement(service: models.Service, requirement: base_mod



def hash_requirements(requirements: dict[str, base_models.Requirement]) -> str:
return sha256(".".join([key + req.service for key, req in requirements.items()]).encode()).hexdigest()
def hash_requirements(requirements: list[base_models.Requirement]) -> str:
return sha256(".".join([req.service + req.key for req in requirements]).encode()).hexdigest()


def auto_create_composition(manifest: base_models.Manifest) -> models.Composition:
Expand All @@ -78,7 +78,7 @@ def auto_create_composition(manifest: base_models.Manifest) -> models.Compositio
errors = []
warnings = []

for key, req in manifest.requirements.items():
for req in manifest.requirements:

try:
service = models.Service.objects.get(identifier=req.service)
Expand All @@ -88,7 +88,7 @@ def auto_create_composition(manifest: base_models.Manifest) -> models.Compositio
models.ServiceInstanceMapping.objects.create(
composition=composition,
instance=instance,
key=key,
key=req.key,
)

except Exception as e:
Expand Down Expand Up @@ -116,7 +116,7 @@ def check_compability(manifest: base_models.Manifest) -> list[str] | list[str]:
errors = []
warnings = []

for key, req in manifest.requirements.items():
for req in manifest.requirements:

try:
try:
Expand Down
2 changes: 1 addition & 1 deletion fakts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def get_context_data(self, **kwargs):

print(manifest.requirements)

context["composition_requirements"] = {key: req.service for key, req in manifest.requirements.items()}
context["composition_requirements"] = {req.key: req.service for req in manifest.requirements}
context["composition_errors"] = composition_errors
context["composition_warnings"] = composition_warnings
context["staging_identifier"] = x.staging_manifest["identifier"]
Expand Down

0 comments on commit 03f04f1

Please sign in to comment.