Skip to content

Commit

Permalink
Dependency update:
Browse files Browse the repository at this point in the history
- Pydantic v2 dependency update
- Update graphql-pydantic-converter
  • Loading branch information
Jozef Volak authored and Jozefiel committed Nov 6, 2023
1 parent 48202fd commit 9d67c1c
Show file tree
Hide file tree
Showing 46 changed files with 4,577 additions and 3,507 deletions.
2 changes: 2 additions & 0 deletions inventory/python/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# 1.0.0
- Upgrade pydantic version to v2
260 changes: 137 additions & 123 deletions inventory/python/frinx_worker/inventory/__init__.py

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions inventory/python/frinx_worker/inventory/utils.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
from dataclasses import dataclass
from typing import Any
from typing import Optional
from typing import TypeAlias

import requests
from frinx.common.frinx_rest import INVENTORY_HEADERS
from frinx.common.frinx_rest import INVENTORY_URL_BASE
from frinx.common.type_aliases import DictAny

CoursorGroup: TypeAlias = dict[str, list[dict[str, str]]]
CoursorGroups: TypeAlias = dict[str, dict[str, list[dict[str, str]]]]
CursorGroup: TypeAlias = dict[str, list[dict[str, str]]]
CursorGroups: TypeAlias = dict[str, dict[str, list[dict[str, str]]]]


@dataclass
Expand All @@ -20,7 +21,7 @@ class InventoryOutput:

def execute_inventory_query(
query: str,
variables: DictAny | None = None,
variables: Optional[DictAny] = None,
inventory_url_base: str = INVENTORY_URL_BASE
) -> InventoryOutput:
"""
Expand Down
48 changes: 32 additions & 16 deletions inventory/python/frinx_worker/inventory/workflows/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class InstallAllFromInventory(WorkflowImpl):
version: int = 1
description: str = 'Install all devices from device inventory or by label'
labels: list[str] = ['INVENTORY']
timeout_seconds = 3600
timeout_seconds: int = 3600

class WorkflowInput(WorkflowImpl.WorkflowInput):
labels: WorkflowInputField = WorkflowInputField(
Expand All @@ -42,15 +42,19 @@ def workflow_builder(self, workflow_inputs: WorkflowInput) -> None:
name=InventoryService.InventoryGetLabelsId,
task_reference_name='get_labels',
input_parameters=SimpleTaskInputParameters(
labels=workflow_inputs.labels.wf_input
root=dict(
labels=workflow_inputs.labels.wf_input
)
)
)

get_pages_cursors = SimpleTask(
name=InventoryService.InventoryGetPagesCursors,
task_reference_name='get_pages_cursors',
input_parameters=SimpleTaskInputParameters(
labels=get_labels.output_ref('labels_id')
root=dict(
labels=get_labels.output_ref('labels_id')
)
)
)

Expand All @@ -68,8 +72,10 @@ def workflow_builder(self, workflow_inputs: WorkflowInput) -> None:
name=InventoryService.InventoryGetPagesCursorsForkTasks,
task_reference_name='get_pages_cursors_fork_task',
input_parameters=SimpleTaskInputParameters(
task=InventoryService.InventoryInstallInBatch().WorkerDefinition().name,
cursors_groups=convert_to_string.output_ref('result'),
root=dict(
task=InventoryService.InventoryInstallInBatch().WorkerDefinition().name,
cursors_groups=convert_to_string.output_ref('result')
)
)
)

Expand Down Expand Up @@ -122,14 +128,14 @@ def workflow_builder(self, workflow_inputs: WorkflowInput) -> None:

self.output_parameters = self.WorkflowOutput(
response_body=join_results.output_ref('result.output')
).dict()
).model_dump()

class InstallInBatch(WorkflowImpl):
name: str = 'INVENTORY_install_in_batch'
version: int = 1
description: str = 'Install devices in batch'
labels: list[str] = ['INVENTORY']
timeout_seconds = 3600
timeout_seconds: int = 3600

class WorkflowInput(WorkflowImpl.WorkflowInput):
devices: WorkflowInputField = WorkflowInputField(
Expand All @@ -148,7 +154,9 @@ def workflow_builder(self, workflow_inputs: WorkflowInput) -> None:
name=InventoryService.InventoryInstallInBatch,
task_reference_name='install_in_batch',
input_parameters=SimpleTaskInputParameters(
devices=workflow_inputs.devices.wf_input
root=dict(
devices=workflow_inputs.devices.wf_input
)
)
)
)
Expand All @@ -158,7 +166,7 @@ class UninstallAllFromInventory(WorkflowImpl):
version: int = 1
description: str = 'Uninstall all devices from device inventory or by label'
labels: list[str] = ['INVENTORY']
timeout_seconds = 3600
timeout_seconds: int = 3600

class WorkflowInput(WorkflowImpl.WorkflowInput):
labels: WorkflowInputField = WorkflowInputField(
Expand All @@ -177,15 +185,19 @@ def workflow_builder(self, workflow_inputs: WorkflowInput) -> None:
name=InventoryService.InventoryGetLabelsId,
task_reference_name='get_labels',
input_parameters=SimpleTaskInputParameters(
labels=workflow_inputs.labels.wf_input
root=dict(
labels=workflow_inputs.labels.wf_input
)
)
)

get_pages_cursors = SimpleTask(
name=InventoryService.InventoryGetPagesCursors,
task_reference_name='get_pages_cursors',
input_parameters=SimpleTaskInputParameters(
labels=get_labels.output_ref('labels_id')
root=dict(
labels=get_labels.output_ref('labels_id')
)
)
)

Expand All @@ -203,8 +215,10 @@ def workflow_builder(self, workflow_inputs: WorkflowInput) -> None:
name=InventoryService.InventoryGetPagesCursorsForkTasks,
task_reference_name='get_pages_cursors_fork_task',
input_parameters=SimpleTaskInputParameters(
task='INVENTORY_uninstall_in_batch',
cursors_groups=convert_to_string.output_ref('result'),
root=dict(
task='INVENTORY_uninstall_in_batch',
cursors_groups=convert_to_string.output_ref('result')
)
)
)

Expand Down Expand Up @@ -257,14 +271,14 @@ def workflow_builder(self, workflow_inputs: WorkflowInput) -> None:

self.output_parameters = self.WorkflowOutput(
response_body=join_results.output_ref('result.output')
).dict()
).model_dump()

class UninstallInBatch(WorkflowImpl):
name: str = 'INVENTORY_uninstall_in_batch'
version: int = 1
description: str = 'Uninstall devices in batch'
labels: list[str] = ['INVENTORY']
timeout_seconds = 3600
timeout_seconds: int = 3600

class WorkflowInput(WorkflowImpl.WorkflowInput):
devices: WorkflowInputField = WorkflowInputField(
Expand All @@ -283,7 +297,9 @@ def workflow_builder(self, workflow_inputs: WorkflowInput) -> None:
name=InventoryService.InventoryUninstallInBatch,
task_reference_name='uninstall_in_batch',
input_parameters=SimpleTaskInputParameters(
devices=workflow_inputs.devices.wf_input
root=dict(
devices=workflow_inputs.devices.wf_input
)
)
)
)
Loading

0 comments on commit 9d67c1c

Please sign in to comment.