Skip to content
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
22 changes: 8 additions & 14 deletions flame_hub/_core_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
from flame_hub._auth_flows import PasswordAuth, RobotAuth
from flame_hub._storage_client import BucketFile


RegistryCommand = t.Literal["setup", "cleanup"]


Expand Down Expand Up @@ -215,7 +214,8 @@ class Log(BaseModel):
labels: dict[str, str | None]


ProcessStatus = t.Literal["starting", "started", "stopping", "stopped", "finished", "failed"]
AnalysisBuildStatus = t.Literal["starting", "started", "stopping", "stopped", "finished", "failed"]
AnalysisRunStatus = t.Literal["starting", "started", "running", "stopping", "stopped", "finished", "failed"]


class CreateAnalysis(BaseModel):
Expand All @@ -240,10 +240,8 @@ class Analysis(CreateAnalysis):
configuration_node_aggregator_valid: bool
configuration_node_default_valid: bool
configuration_nodes_valid: bool
build_status: ProcessStatus | None
execution_status: ProcessStatus | None
distribution_status: ProcessStatus | None
execution_progress: int | None
build_status: AnalysisBuildStatus | None
run_status: AnalysisRunStatus | None
created_at: datetime
updated_at: datetime
registry: t.Annotated[Registry | None, IsIncludable] = None
Expand Down Expand Up @@ -290,8 +288,7 @@ class CreateAnalysisNode(BaseModel):
class AnalysisNode(CreateAnalysisNode):
id: uuid.UUID
approval_status: AnalysisNodeApprovalStatus | None
execution_status: ProcessStatus | None
execution_progress: int | None
run_status: AnalysisNodeRunStatus | None
comment: str | None
artifact_tag: str | None
artifact_digest: str | None
Expand All @@ -306,8 +303,7 @@ class AnalysisNode(CreateAnalysisNode):
class UpdateAnalysisNode(BaseModel):
comment: str | None | UNSET_T = UNSET
approval_status: AnalysisNodeApprovalStatus | None | UNSET_T = UNSET
execution_status: ProcessStatus | None | UNSET_T = UNSET
execution_progress: int | None | UNSET_T = UNSET
run_status: AnalysisNodeRunStatus | None | UNSET_T = UNSET


class CreateAnalysisNodeLog(BaseModel):
Expand Down Expand Up @@ -624,16 +620,14 @@ def update_analysis_node(
analysis_node_id: AnalysisNode | uuid.UUID | str,
comment: str | None | UNSET_T = UNSET,
approval_status: AnalysisNodeApprovalStatus | None | UNSET_T = UNSET,
execution_status: ProcessStatus | None | UNSET_T = UNSET,
execution_progress: int | None | UNSET_T = UNSET,
run_status: AnalysisNodeRunStatus | None | UNSET_T = UNSET,
) -> AnalysisNode:
return self._update_resource(
AnalysisNode,
UpdateAnalysisNode(
comment=comment,
approval_status=approval_status,
execution_status=execution_status,
execution_progress=execution_progress,
run_status=run_status,
),
"analysis-nodes",
analysis_node_id,
Expand Down
6 changes: 4 additions & 2 deletions flame_hub/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"RegistryProjectType",
"MasterImageCommandArgument",
"ProjectNodeApprovalStatus",
"ProcessStatus",
"AnalysisRunStatus",
"AnalysisBuildStatus",
"AnalysisCommand",
"AnalysisNodeApprovalStatus",
"AnalysisNodeRunStatus",
Expand Down Expand Up @@ -43,7 +44,8 @@
RegistryProjectType,
MasterImageCommandArgument,
ProjectNodeApprovalStatus,
ProcessStatus,
AnalysisRunStatus,
AnalysisBuildStatus,
AnalysisCommand,
AnalysisNodeApprovalStatus,
AnalysisNodeRunStatus,
Expand Down
7 changes: 0 additions & 7 deletions tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,5 @@ def next_random_string(charset=string.ascii_letters, length: int = 20):
return "".join([random.choice(charset) for _ in range(length)])


def next_random_number(lower=0, upper=1, is_int=False):
if is_int:
return random.randint(lower, upper)
else:
return random.uniform(lower, upper)


def next_uuid():
return str(uuid.uuid4())
9 changes: 3 additions & 6 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
AnalysisBucket,
AnalysisBucketFile,
)
from tests.helpers import next_random_string, next_uuid, assert_eventually, next_random_number
from tests.helpers import next_random_string, next_uuid, assert_eventually

pytestmark = pytest.mark.integration

Expand Down Expand Up @@ -451,16 +451,13 @@ def _check_checking_event_in_logs():


def test_update_analysis_node(core_client, analysis_node):
progress = next_random_number(upper=100, is_int=True)
new_analysis_node = core_client.update_analysis_node(
analysis_node.id,
execution_status="starting",
execution_progress=progress,
run_status="starting",
)

assert analysis_node != new_analysis_node
assert new_analysis_node.execution_status == "starting"
assert new_analysis_node.execution_progress == progress
assert new_analysis_node.run_status == "starting"


def test_get_analysis_nodes(core_client, analysis_node, analysis_node_includables):
Expand Down