Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
polyaxon-ci committed Jan 4, 2025
1 parent e0f92af commit 5e2ed07
Show file tree
Hide file tree
Showing 58 changed files with 756 additions and 1,020 deletions.
2 changes: 1 addition & 1 deletion cli/polyaxon/_cli/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1466,7 +1466,7 @@ def logs(ctx, project, uid, follow, hide_time, all_containers, all_info, offline
)

try:
from traceml.logging.streamer import get_logs_streamer, load_logs_from_path
from traceml.logging.streamer import load_logs_from_path

load_logs_from_path(
logs_path=logs_path,
Expand Down
4 changes: 2 additions & 2 deletions cli/polyaxon/_cli/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def project(ctx, _project): # pylint:disable=redefined-outer-name
@click.option(
*OPTIONS_NAME["args"],
type=str,
help="The project name, e.g. 'mnist' or 'acme/mnist'."
help="The project name, e.g. 'mnist' or 'acme/mnist'.",
)
@click.option("--description", type=str, help="Description of the project.")
@click.option("--tags", type=str, help="Tags of the project (comma separated values).")
Expand Down Expand Up @@ -287,7 +287,7 @@ def delete(ctx, _project, yes):
@click.option(
*OPTIONS_NAME["args"],
type=str,
help="Name of the project, must be unique for the same user."
help="Name of the project, must be unique for the same user.",
)
@click.option("--description", type=str, help="Description of the project.")
@click.option("--tags", type=str, help="Tags of the project (comma separated values).")
Expand Down
2 changes: 1 addition & 1 deletion cli/polyaxon/_compiler/resolver/runtime.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from datetime import datetime
from typing import Any, Dict, List, Optional
from typing import Dict, List, Optional

from polyaxon import settings
from polyaxon._compiler.contexts import resolve_contexts, resolve_globals_contexts
Expand Down
2 changes: 1 addition & 1 deletion cli/polyaxon/_docker/converter/base/env_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def _get_items_from_json_resource(

try:
secret_value = orjson_loads(resource.name)
except orjson.JSONDecodeError as e:
except orjson.JSONDecodeError:
return items_from

for item in resource.items:
Expand Down
2 changes: 1 addition & 1 deletion cli/polyaxon/_docker/converter/converters/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from polyaxon._docker import docker_types
from polyaxon._docker.converter.base import BaseConverter
from polyaxon._docker.converter.mixins import ServiceMixin
from polyaxon._flow import V1CompiledOperation, V1Plugins, V1Service
from polyaxon._flow import V1CompiledOperation, V1Plugins


class ServiceConverter(ServiceMixin, BaseConverter):
Expand Down
1 change: 0 additions & 1 deletion cli/polyaxon/_flow/operations/operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
field_validator,
model_validator,
validation_after,
validation_before,
)
from clipped.config.patch_strategy import PatchStrategy
from clipped.config.schema import skip_partial, to_partial
Expand Down
2 changes: 1 addition & 1 deletion cli/polyaxon/_flow/params/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ def validate_to_init(self) -> bool:
raise PolyaxonValidationError(
"Param `{}` with type `{}`, "
"cannot be turned to an init container automatically.".format(
self.name, self.type, self.param.ref
self.name, self.type
)
)

Expand Down
2 changes: 1 addition & 1 deletion cli/polyaxon/_fs/fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def _get_fs_from_connection(
connection: Optional[V1Connection],
asynchronous: bool = False,
use_listings_cache: bool = False,
**kwargs
**kwargs,
):
# We assume that `None` refers to local store as well
if not connection or connection.kind in {
Expand Down
2 changes: 1 addition & 1 deletion cli/polyaxon/_k8s/converter/base/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def sanitize_env_dict(d: Dict):

@staticmethod
def _sanitize_resources(
resources: Union[k8s_schemas.V1ResourceRequirements, Dict]
resources: Union[k8s_schemas.V1ResourceRequirements, Dict],
) -> Optional[k8s_schemas.V1ResourceRequirements]:
def validate_resources(r_field: Dict) -> Dict:
if not r_field:
Expand Down
1 change: 0 additions & 1 deletion cli/polyaxon/_k8s/converter/converters/ray_job.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from typing import Dict, Iterable, Optional

from clipped.utils.encoding import encode
from clipped.utils.json import orjson_dumps

from polyaxon import pkg
Expand Down
2 changes: 1 addition & 1 deletion cli/polyaxon/_k8s/converter/converters/service.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Dict, Iterable, Optional

from polyaxon._connections import V1Connection, V1ConnectionResource
from polyaxon._flow import V1CompiledOperation, V1Plugins, V1Service
from polyaxon._flow import V1CompiledOperation, V1Plugins
from polyaxon._k8s.converter.base import BaseConverter
from polyaxon._k8s.converter.mixins import ServiceMixin
from polyaxon._k8s.custom_resources.service import get_service_custom_resource
Expand Down
32 changes: 16 additions & 16 deletions cli/polyaxon/_k8s/k8s_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ def validate_k8s_affinity(value: Optional[Union[k8s_schemas.V1Affinity, Dict]]):


def validate_k8s_security_context(
value: Optional[Union[k8s_schemas.V1SecurityContext, Dict]]
value: Optional[Union[k8s_schemas.V1SecurityContext, Dict]],
):
return _validate_schema(value, k8s_schemas.V1SecurityContext)


def validate_k8s_pod_dns_config(
value: Optional[Union[k8s_schemas.V1PodDNSConfig, Dict]]
value: Optional[Union[k8s_schemas.V1PodDNSConfig, Dict]],
):
return _validate_schema(value, k8s_schemas.V1PodDNSConfig)

Expand All @@ -56,19 +56,19 @@ def validate_k8s_volume_mount(value: Optional[Union[k8s_schemas.V1VolumeMount, D


def validate_k8s_container_port(
value: Optional[Union[k8s_schemas.V1ContainerPort, Dict]]
value: Optional[Union[k8s_schemas.V1ContainerPort, Dict]],
):
return _validate_schema(value, k8s_schemas.V1ContainerPort)


def validate_k8s_resource_requirements(
value: Optional[Union[k8s_schemas.V1ResourceRequirements, Dict]]
value: Optional[Union[k8s_schemas.V1ResourceRequirements, Dict]],
):
return _validate_schema(value, k8s_schemas.V1ResourceRequirements)


def validate_k8s_env_from_source(
value: Optional[Union[k8s_schemas.V1EnvFromSource, Dict]]
value: Optional[Union[k8s_schemas.V1EnvFromSource, Dict]],
):
return _validate_schema(value, k8s_schemas.V1EnvFromSource)

Expand All @@ -78,25 +78,25 @@ def validate_k8s_volume(value: Optional[Union[k8s_schemas.V1Volume, Dict]]):


def validate_k8s_object_field_selector(
value: Optional[Union[k8s_schemas.V1ObjectFieldSelector, Dict]]
value: Optional[Union[k8s_schemas.V1ObjectFieldSelector, Dict]],
):
return _validate_schema(value, k8s_schemas.V1ObjectFieldSelector)


def validate_k8s_env_var_source(
value: Optional[Union[k8s_schemas.V1EnvVarSource, Dict]]
value: Optional[Union[k8s_schemas.V1EnvVarSource, Dict]],
):
return _validate_schema(value, k8s_schemas.V1EnvVarSource)


def validate_k8s_config_map_selector(
value: Optional[Union[k8s_schemas.V1ConfigMapKeySelector, Dict]]
value: Optional[Union[k8s_schemas.V1ConfigMapKeySelector, Dict]],
):
return _validate_schema(value, k8s_schemas.V1ConfigMapKeySelector)


def validate_k8s_secret_selector(
value: Optional[Union[k8s_schemas.V1SecretKeySelector, Dict]]
value: Optional[Union[k8s_schemas.V1SecretKeySelector, Dict]],
):
return _validate_schema(value, k8s_schemas.V1SecretKeySelector)

Expand All @@ -110,42 +110,42 @@ def validate_k8s_object_meta(value: Optional[Union[k8s_schemas.V1ObjectMeta, Dic


def validate_k8s_pod_template_spec(
value: Optional[Union[k8s_schemas.V1PodTemplateSpec, Dict]]
value: Optional[Union[k8s_schemas.V1PodTemplateSpec, Dict]],
):
return _validate_schema(value, k8s_schemas.V1PodTemplateSpec)


def validate_k8s_host_path_volume_source(
value: Optional[Union[k8s_schemas.V1HostPathVolumeSource, Dict]]
value: Optional[Union[k8s_schemas.V1HostPathVolumeSource, Dict]],
):
return _validate_schema(value, k8s_schemas.V1HostPathVolumeSource)


def validate_k8s_empty_dir_volume_source(
value: Optional[Union[k8s_schemas.V1EmptyDirVolumeSource, Dict]]
value: Optional[Union[k8s_schemas.V1EmptyDirVolumeSource, Dict]],
):
return _validate_schema(value, k8s_schemas.V1EmptyDirVolumeSource)


def validate_k8s_persistent_volume_claim_volume_source(
value: Optional[Union[k8s_schemas.V1PersistentVolumeClaimVolumeSource, Dict]]
value: Optional[Union[k8s_schemas.V1PersistentVolumeClaimVolumeSource, Dict]],
):
return _validate_schema(value, k8s_schemas.V1PersistentVolumeClaimVolumeSource)


def validate_k8s_secret_volume_source(
value: Optional[Union[k8s_schemas.V1SecretVolumeSource, Dict]]
value: Optional[Union[k8s_schemas.V1SecretVolumeSource, Dict]],
):
return _validate_schema(value, k8s_schemas.V1SecretVolumeSource)


def validate_k8s_config_map_volume_source(
value: Optional[Union[k8s_schemas.V1ConfigMapVolumeSource, Dict]]
value: Optional[Union[k8s_schemas.V1ConfigMapVolumeSource, Dict]],
):
return _validate_schema(value, k8s_schemas.V1ConfigMapVolumeSource)


def validate_k8s_local_object_reference(
value: Optional[Union[k8s_schemas.V1LocalObjectReference, Dict]]
value: Optional[Union[k8s_schemas.V1LocalObjectReference, Dict]],
):
return _validate_schema(value, k8s_schemas.V1LocalObjectReference)
8 changes: 5 additions & 3 deletions cli/polyaxon/_k8s/manager/async_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ async def get_pod(
async def is_pod_running(
self, pod_id: str, container_id: str, namespace: str = None
) -> bool:
event = await self.k8s_api.read_namespaced_pod_status(pod_id, namespace=namespace or self.namespace) # type: ignore[attr-defined]
event = await self.k8s_api.read_namespaced_pod_status(
pod_id, namespace=namespace or self.namespace
) # type: ignore[attr-defined]
return is_pod_running(event, container_id)

async def _list_namespace_resource(
Expand Down Expand Up @@ -108,7 +110,7 @@ async def list_custom_objects(
plural,
reraise: bool = False,
namespace: str = None,
**kwargs
**kwargs,
) -> List:
return await self._list_namespace_resource(
resource_api=self.k8s_custom_object_api.list_namespaced_custom_object, # type: ignore[attr-defined]
Expand Down Expand Up @@ -273,7 +275,7 @@ async def list_namespaced_events(
field_selector: str = None,
namespace: str = None,
reraise: bool = False,
**kwargs
**kwargs,
) -> List[client.CoreV1EventList]:
return await self._list_namespace_resource(
resource_api=self.k8s_api.list_namespaced_event, # type: ignore[attr-defined]
Expand Down
12 changes: 6 additions & 6 deletions cli/polyaxon/_k8s/manager/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def list_pods(
include_uninitialized=True,
reraise: bool = False,
namespace: str = None,
**kwargs
**kwargs,
):
return self._list_namespace_resource(
resource_api=self.k8s_api.list_namespaced_pod,
Expand All @@ -89,7 +89,7 @@ def list_jobs(
include_uninitialized=True,
reraise: bool = False,
namespace: str = None,
**kwargs
**kwargs,
):
return self._list_namespace_resource(
resource_api=self.k8s_batch_api.list_namespaced_job,
Expand All @@ -105,7 +105,7 @@ def list_custom_objects(
plural,
reraise: bool = False,
namespace: str = None,
**kwargs
**kwargs,
):
return self._list_namespace_resource(
resource_api=self.k8s_custom_object_api.list_namespaced_custom_object,
Expand Down Expand Up @@ -747,7 +747,7 @@ def delete_pods(
include_uninitialized=True,
reraise: bool = False,
namespace: str = None,
**kwargs
**kwargs,
):
objs = self.list_pods(
include_uninitialized=include_uninitialized,
Expand All @@ -765,7 +765,7 @@ def delete_jobs(
include_uninitialized=True,
reraise: bool = False,
namespace: str = None,
**kwargs
**kwargs,
):
objs = self.list_jobs(
include_uninitialized=include_uninitialized,
Expand Down Expand Up @@ -812,7 +812,7 @@ def list_namespaced_events(
field_selector: str = None,
namespace: str = None,
reraise: bool = False,
**kwargs
**kwargs,
) -> List[client.CoreV1EventList]:
return self._list_namespace_resource(
resource_api=self.k8s_api.list_namespaced_event, # type: ignore[attr-defined]
Expand Down
2 changes: 1 addition & 1 deletion cli/polyaxon/_local_process/converter/base/env_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def _get_items_from_json_resource(

try:
secret_value = orjson_loads(resource.name)
except orjson.JSONDecodeError as e:
except orjson.JSONDecodeError:
return items_from

for item in resource.items:
Expand Down
2 changes: 1 addition & 1 deletion cli/polyaxon/_local_process/converter/base/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def _get_base_store_container(
env_from: List[Any],
args: List[str],
command: Optional[List[str]] = None,
**kwargs
**kwargs,
) -> Optional[process_types.V1Container]:
env = env or []

Expand Down
2 changes: 0 additions & 2 deletions cli/polyaxon/_local_process/converter/base/mounts.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from typing import List, Optional

from polyaxon._connections import V1Connection, V1ConnectionResource
from polyaxon._contexts import paths as ctx_paths
from polyaxon._local_process import process_types
from polyaxon._runner.converter import BaseConverter


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Dict, Iterable, List, Optional

from polyaxon._connections import V1Connection, V1ConnectionResource
from polyaxon._flow import V1CompiledOperation, V1Plugins, V1Service
from polyaxon._flow import V1CompiledOperation, V1Plugins
from polyaxon._local_process import process_types
from polyaxon._local_process.converter.base import BaseConverter
from polyaxon._local_process.converter.mixins import ServiceMixin
Expand Down
5 changes: 3 additions & 2 deletions cli/polyaxon/_managers/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ def get_config_or_raise(cls) -> V1Project:
project = cls.get_config()
if not project:
Printer.error(
"No project was found, please initialize a project."
" {}".format(cli_constants.INIT_COMMAND)
"No project was found, please initialize a project." " {}".format(
cli_constants.INIT_COMMAND
)
)
sys.exit(1)

Expand Down
8 changes: 4 additions & 4 deletions cli/polyaxon/_polyaxonfile/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ def check_polyaxonfile(
):
if sum([1 for i in [python_module, url, hub] if i]) > 1:
message = (
"You can only use one and only one option: "
"hub, url, or a python module.".format(hub)
"You can only use one and only one option: hub, url, or a python module."
)
if is_cli:
Printer.error(message, sys_exit=True)
Expand Down Expand Up @@ -213,8 +212,9 @@ def check_polyaxonfile(
def check_polyaxonfile_kind(specification, kind):
if specification.kind != kind:
Printer.error(
"Your polyaxonfile must be of kind: `{}`, "
"received: `{}`.".format(kind, specification.kind),
"Your polyaxonfile must be of kind: `{}`, " "received: `{}`.".format(
kind, specification.kind
),
sys_exit=True,
)

Expand Down
4 changes: 1 addition & 3 deletions cli/polyaxon/_polyaxonfile/specs/compiled_operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,7 @@ def apply_preset(
) -> V1CompiledOperation:
if not preset:
return config
preset = OperationSpecification.read(
preset, is_preset=True
) # type: V1Operation
preset = OperationSpecification.read(preset, is_preset=True) # type: V1Operation
if preset.run_patch:
config.run = config.run.patch(
validate_run_patch(preset.run_patch, config.run.kind),
Expand Down
4 changes: 1 addition & 3 deletions cli/polyaxon/_polyaxonfile/specs/libs/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ def get_parsed_params(param_spec: Dict[str, ParamSpec]) -> Dict:
return parsed_params

@classmethod
def parse_operation(
cls, config, param_spec: Dict[str, ParamSpec]
): # pylint:disable=too-many-branches
def parse_operation(cls, config, param_spec: Dict[str, ParamSpec]): # pylint:disable=too-many-branches
parsed_params = cls.get_parsed_params(param_spec)

parsed_data = {Sections.VERSION: config.version, Sections.KIND: config.kind}
Expand Down
Loading

0 comments on commit 5e2ed07

Please sign in to comment.