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
6 changes: 5 additions & 1 deletion orchestrator/api/state/actuators.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# Copyright (c) IBM Corporation
# SPDX-License-Identifier: MIT
import typing

import ray
from ray.actor import ActorHandle

from orchestrator.modules.actuators.measurement_queue import MeasurementQueue
from orchestrator.modules.actuators.registry import ActuatorRegistry

if typing.TYPE_CHECKING:
from orchestrator.modules.actuators.measurement_queue import MeasurementQueue


@ray.remote
class ActuatorDictionaryActor:
Expand Down
5 changes: 4 additions & 1 deletion orchestrator/cli/commands/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
# SPDX-License-Identifier: MIT

import pathlib
import typing
from typing import Annotated

import typer

import orchestrator.core.operation.config
import orchestrator.metastore.project
from orchestrator.cli.core.config import AdoConfiguration
from orchestrator.cli.models.choice import HiddenPluralChoice
from orchestrator.cli.models.parameters import AdoTemplateCommandParameters
from orchestrator.cli.models.types import AdoTemplateSupportedResourceTypes
Expand All @@ -23,6 +23,9 @@
from orchestrator.cli.utils.input.parsers import parse_key_value_pairs
from orchestrator.utilities.naming import get_random_name_extension

if typing.TYPE_CHECKING:
from orchestrator.cli.core.config import AdoConfiguration

TEMPLATE_OPERATION_PANEL_NAME = "Operation-specific options"
TEMPLATE_ACTUATORCONFIGURATION_PANEL_NAME = "ActuatorConfiguration-specific options"
TEMPLATE_SPACE_PANEL_NAME = "Space-specific options"
Expand Down
21 changes: 10 additions & 11 deletions orchestrator/cli/models/space.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
# Copyright (c) IBM Corporation
# SPDX-License-Identifier: MIT

from __future__ import annotations

import math
import typing
from io import StringIO

import rich.table

import orchestrator.metastore.project
import orchestrator.schema.property
from orchestrator.cli.utils.output.prints import console_print
from orchestrator.core.discoveryspace.resource import DiscoverySpaceResource
from orchestrator.core.discoveryspace.space import DiscoverySpace
from orchestrator.core.resources import CoreResourceKinds
from orchestrator.schema.entityspace import EntitySpaceRepresentation

if typing.TYPE_CHECKING:
import pandas as pd

from orchestrator.core.discoveryspace.resource import DiscoverySpaceResource
from orchestrator.metastore.project import ProjectContext


class SpaceDetails:

Expand Down Expand Up @@ -54,7 +53,7 @@ def __init__(
self.size_of_entity_space = size_of_entity_space

@classmethod
def from_space(cls, space: DiscoverySpace) -> SpaceDetails:
def from_space(cls, space: DiscoverySpace) -> "SpaceDetails":

import pandas as pd

Expand Down Expand Up @@ -201,11 +200,12 @@ class SpaceSummary:
def __init__(
self,
space_id: str,
project_context: orchestrator.metastore.project.ProjectContext,
project_context: "ProjectContext",
) -> None:
import orchestrator.metastore.sqlstore
from orchestrator.metastore.sqlstore import SQLStore
from orchestrator.schema.property import NonMeasuredPropertyTypeEnum

sql = orchestrator.metastore.sqlstore.SQLStore(project_context=project_context)
sql = SQLStore(project_context=project_context)

space_resource: DiscoverySpaceResource = sql.getResource(
identifier=space_id,
Expand Down Expand Up @@ -241,8 +241,7 @@ def __init__(
else p.propertyDomain.domainRange
)
for p in space_resource.config.entitySpace
if p.propertyType
== orchestrator.schema.property.NonMeasuredPropertyTypeEnum.CONSTITUTIVE_PROPERTY_TYPE
if p.propertyType == NonMeasuredPropertyTypeEnum.CONSTITUTIVE_PROPERTY_TYPE
}

self.id = space.resource.identifier
Expand Down Expand Up @@ -363,7 +362,7 @@ def to_dataframe(
self,
include_properties: list[str] | None = None,
columns_to_hide: list[str] | None = None,
) -> pd.DataFrame:
) -> "pd.DataFrame":

import pandas as pd

Expand Down
2 changes: 0 additions & 2 deletions orchestrator/cli/models/types.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Copyright (c) IBM Corporation
# SPDX-License-Identifier: MIT

from __future__ import annotations

import enum
from enum import Enum

Expand Down
5 changes: 4 additions & 1 deletion orchestrator/cli/resources/discovery_space/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# SPDX-License-Identifier: MIT

import pathlib
import typing

from rich.status import Status

Expand All @@ -13,10 +14,12 @@
_ado_get_actuator_from_experiment_id,
)
from orchestrator.core.discoveryspace.config import DiscoverySpaceConfiguration
from orchestrator.schema.entityspace import EntitySpaceRepresentation
from orchestrator.schema.measurementspace import MeasurementSpace
from orchestrator.schema.reference import ExperimentReference

if typing.TYPE_CHECKING:
from orchestrator.schema.entityspace import EntitySpaceRepresentation


def template_discovery_space(parameters: AdoTemplateCommandParameters) -> None:
from orchestrator.cli.utils.pydantic.serializers import (
Expand Down
2 changes: 0 additions & 2 deletions orchestrator/cli/utils/generic/constants.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Copyright (c) IBM Corporation
# SPDX-License-Identifier: MIT

from __future__ import annotations

SECONDS_IN_A_MINUTE = 60
SECONDS_IN_AN_HOUR = 3600
SECONDS_IN_A_DAY = 86400
1 change: 0 additions & 1 deletion orchestrator/cli/utils/pydantic/constants.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Copyright (c) IBM Corporation
# SPDX-License-Identifier: MIT

from __future__ import annotations

from orchestrator.core.operation.resource import OperationResourceEventEnum
from orchestrator.core.resources import ADOResourceEventEnum
Expand Down
42 changes: 20 additions & 22 deletions orchestrator/cli/utils/resources/formatters.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,32 @@
# Copyright (c) IBM Corporation
# SPDX-License-Identifier: MIT

from __future__ import annotations

import datetime
import json
import math
import typing

import pydantic
import typer
import yaml

from orchestrator.cli.models.parameters import AdoGetCommandParameters
from orchestrator.cli.models.types import AdoGetSupportedOutputFormats
from orchestrator.cli.utils.generic.constants import (
SECONDS_IN_A_DAY,
SECONDS_IN_A_MINUTE,
SECONDS_IN_AN_HOUR,
)
from orchestrator.cli.utils.jsonpath.filters import remove_fields_from_dictionary
from orchestrator.cli.utils.pydantic.constants import (
event_importance_order,
minimize_output_context,
)

if typing.TYPE_CHECKING:
import pandas as pd
import pydantic
import typer

from orchestrator.cli.models.types import AdoGetSupportedOutputFormats
from orchestrator.cli.utils.output.prints import (
ADO_GET_CONFIG_ONLY_WHEN_SINGLE_RESOURCE,
ERROR,
WARN,
console_print,
)
from orchestrator.cli.utils.pydantic.constants import (
event_importance_order,
minimize_output_context,
)
from orchestrator.core import (
ADOResource,
CoreResourceKinds,
Expand All @@ -50,10 +43,15 @@
printable_pydantic_model,
)

if typing.TYPE_CHECKING:
import pandas as pd

from orchestrator.cli.models.parameters import AdoGetCommandParameters


def format_default_ado_get_single_resource(
resource: ADOResource, show_details: bool
) -> pd.DataFrame:
) -> "pd.DataFrame":
import json

import pandas as pd
Expand Down Expand Up @@ -103,8 +101,8 @@ def format_default_ado_get_single_resource(


def format_default_ado_get_multiple_resources(
resources: pd.DataFrame, resource_kind: CoreResourceKinds
) -> pd.DataFrame:
resources: "pd.DataFrame", resource_kind: CoreResourceKinds
) -> "pd.DataFrame":
if resources.empty:
return resources

Expand Down Expand Up @@ -160,7 +158,7 @@ def format_resource_for_ado_get_custom_format(
| list[pydantic.BaseModel]
| dict
),
parameters: AdoGetCommandParameters,
parameters: "AdoGetCommandParameters",
) -> str:
match parameters.output_format:
case AdoGetSupportedOutputFormats.CONFIG:
Expand Down Expand Up @@ -193,7 +191,7 @@ def _config_formatter_for_ado_resource(
| list[pydantic.BaseModel]
| dict
),
parameters: AdoGetCommandParameters,
parameters: "AdoGetCommandParameters",
) -> str:

if isinstance(to_print, list):
Expand Down Expand Up @@ -248,7 +246,7 @@ def _yaml_formatter_for_ado_resource(
| list[pydantic.BaseModel]
| dict
),
parameters: AdoGetCommandParameters,
parameters: "AdoGetCommandParameters",
) -> str:

if parameters.minimize_output:
Expand Down Expand Up @@ -289,7 +287,7 @@ def _json_formatter_for_ado_resource(
to_print: (
ADOResource | list[ADOResource] | pydantic.BaseModel | list[pydantic.BaseModel]
),
parameters: AdoGetCommandParameters,
parameters: "AdoGetCommandParameters",
) -> str:

if parameters.minimize_output:
Expand Down Expand Up @@ -363,7 +361,7 @@ def _raw_formatter_for_ado_resource(
| list[pydantic.BaseModel]
| dict
),
parameters: AdoGetCommandParameters,
parameters: "AdoGetCommandParameters",
) -> str:
import pprint

Expand Down
33 changes: 16 additions & 17 deletions orchestrator/cli/utils/resources/handlers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Copyright (c) IBM Corporation
# SPDX-License-Identifier: MIT

from __future__ import annotations

import pathlib
import typing
Expand All @@ -12,10 +11,6 @@
import yaml
from rich.status import Status

from orchestrator.cli.models.parameters import (
AdoGetCommandParameters,
AdoUpgradeCommandParameters,
)
from orchestrator.cli.models.types import (
AdoEditSupportedEditors,
AdoGetSupportedOutputFormats,
Expand All @@ -37,18 +32,22 @@
format_default_ado_get_single_resource,
format_resource_for_ado_get_custom_format,
)
from orchestrator.core import CoreResourceKinds
from orchestrator.core.metadata import ConfigurationMetadata
from orchestrator.metastore.base import ResourceDoesNotExistError
from orchestrator.metastore.project import ProjectContext

if typing.TYPE_CHECKING:
from orchestrator.cli.models.parameters import (
AdoGetCommandParameters,
AdoUpgradeCommandParameters,
)
from orchestrator.core import CoreResourceKinds
from orchestrator.metastore.project import ProjectContext
from orchestrator.metastore.sqlstore import SQLStore


def handle_ado_get_special_formats(
parameters: AdoGetCommandParameters,
resource_type: CoreResourceKinds,
parameters: "AdoGetCommandParameters",
resource_type: "CoreResourceKinds",
) -> None:

if (
Expand Down Expand Up @@ -102,8 +101,8 @@ def handle_ado_get_special_formats(


def handle_ado_get_default_format(
parameters: AdoGetCommandParameters,
resource_type: CoreResourceKinds,
parameters: "AdoGetCommandParameters",
resource_type: "CoreResourceKinds",
) -> None:

sql_store = get_sql_store(
Expand Down Expand Up @@ -150,8 +149,8 @@ def handle_ado_get_default_format(

def print_related_resources(
resource_id: str,
resource_type: CoreResourceKinds,
sql: SQLStore,
resource_type: "CoreResourceKinds",
sql: "SQLStore",
hide_banner: bool = False,
) -> None:
with Status(ADO_SPINNER_QUERYING_DB) as status:
Expand All @@ -178,8 +177,8 @@ def print_related_resources(

def handle_edit_resource_metadata(
resource_id: str,
resource_type: CoreResourceKinds,
project_context: ProjectContext,
resource_type: "CoreResourceKinds",
project_context: "ProjectContext",
editor: AdoEditSupportedEditors,
) -> None:
import subprocess # noqa: S404
Expand Down Expand Up @@ -224,8 +223,8 @@ def handle_edit_resource_metadata(


def handle_ado_upgrade(
parameters: AdoUpgradeCommandParameters,
resource_type: CoreResourceKinds,
parameters: "AdoUpgradeCommandParameters",
resource_type: "CoreResourceKinds",
) -> None:

sql_store = get_sql_store(
Expand Down
Loading