Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function
from unittest import TestCase
from marshmallow import Schema, ValidationError, fields
from polyaxon.schemas.base import BaseConfig, BaseOneOfSchema, BaseSchema
REQUIRED_ERROR = u"Missing data for required field."
class FooSchema(BaseSchema):
value = fields.String(required=True)
@staticmethod
def schema_config():
return FooConfig
class FooConfig(BaseConfig):
SCHEMA = FooSchema
IDENTIFIER = "foo"
def __init__(self, value=None):
self.value = value
def __eq__(self, other):
return isinstance(other, self.__class__) and self.value == other.value
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# coding: utf-8
from __future__ import absolute_import, division, print_function
from marshmallow import fields, validate
from polyaxon_sdk import V1Dask
from polyaxon.schemas.base import BaseConfig, BaseSchema
from polyaxon.schemas.fields.ref_or_obj import RefOrObject
class DaskSchema(BaseSchema):
kind = fields.Str(allow_none=True, validate=validate.Equal("dask"))
spec = RefOrObject(fields.Raw(required=True))
@staticmethod
def schema_config():
return DaskConfig
class DaskConfig(BaseConfig, V1Dask):
SCHEMA = DaskSchema
IDENTIFIER = "dask"
IDENTIFIER_KIND = True
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# coding: utf-8
from __future__ import absolute_import, division, print_function
from marshmallow import fields
from polyaxon.schemas.base import BaseConfig, BaseSchema
class IngressSchema(BaseSchema):
enabled = fields.Bool(allow_none=True)
hostName = fields.Str(allow_none=True)
path = fields.Str(allow_none=True)
tls = fields.List(fields.Dict(allow_none=True), allow_none=True)
annotations = fields.Dict(allow_none=True)
@staticmethod
def schema_config():
return IngressConfig
class IngressConfig(BaseConfig):
SCHEMA = IngressSchema
REDUCED_ATTRIBUTES = ["enabled", "hostName", "tls", "annotations", "path"]
def __init__(
# limitations under the License.
# coding: utf-8
from __future__ import absolute_import, division, print_function
from marshmallow import fields
from polyaxon.schemas.base import BaseConfig, BaseSchema
from polyaxon.schemas.polyflow.environment.container_resources import (
ResourceRequirementsSchema,
)
from polyaxon.schemas.polyflow.environment.containers import ContainerEnvSchema
from polyaxon_sdk import V1Environment
class EnvironmentSchema(BaseSchema):
resources = fields.Nested(ResourceRequirementsSchema, allow_none=True)
labels = fields.Dict(values=fields.Str(), keys=fields.Str(), allow_none=True)
annotations = fields.Dict(values=fields.Str(), keys=fields.Str(), allow_none=True)
node_selector = fields.Dict(values=fields.Str(), keys=fields.Str(), allow_none=True)
affinity = fields.Dict(allow_none=True)
tolerations = fields.List(fields.Dict(), allow_none=True)
service_account = fields.Str(allow_none=True)
image_pull_secrets = fields.List(fields.Str(), allow_none=True)
env_vars = fields.Dict(values=fields.Str(), keys=fields.Str(), allow_none=True)
security_context = fields.Dict(allow_none=True)
log_level = fields.Str(allow_none=True)
auth = fields.Bool(allow_none=True)
docker = fields.Bool(allow_none=True)
shm = fields.Bool(allow_none=True)
outputs = fields.Bool(allow_none=True)
logs = fields.Bool(allow_none=True)
job,
created_at,
status,
message=None,
details=None,
):
self.id = id
self.uuid = uuid
self.job = job
self.created_at = self.localize_date(created_at)
self.status = status
self.message = message
self.details = details
class ContainerGPUResourcesSchema(BaseSchema):
index = fields.Int()
uuid = fields.Str()
name = fields.Str()
minor = fields.Int()
bus_id = fields.Str()
serial = fields.Str()
temperature_gpu = fields.Int()
utilization_gpu = fields.Int()
power_draw = fields.Int()
power_limit = fields.Int()
memory_free = fields.Int()
memory_used = fields.Int()
memory_total = fields.Int()
memory_utilization = fields.Int()
processes = fields.List(fields.Dict(), allow_none=True)
def __init__(
self,
id, # pylint:disable=redefined-builtin
uuid,
experiment,
created_at,
values,
):
self.id = id
self.uuid = uuid
self.experiment = experiment
self.created_at = self.localize_date(created_at)
self.values = values
class ExperimentJobStatusSchema(BaseSchema):
id = fields.Int()
uuid = UUID()
job = fields.Int()
created_at = fields.LocalDateTime()
status = fields.Str()
message = fields.Str(allow_none=True)
details = fields.Dict(allow_none=True)
@staticmethod
def schema_config():
return ExperimentJobStatusConfig
class ExperimentJobStatusConfig(BaseConfig):
SCHEMA = ExperimentJobStatusSchema
IDENTIFIER = "ExperimentJobStatus"
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function
from marshmallow import fields
from polyaxon.schemas.base import BaseConfig, BaseSchema
from polyaxon.schemas.fields import UUID
class NodeGPUSchema(BaseSchema):
index = fields.Int()
name = fields.Str()
uuid = UUID()
memory = fields.Int()
serial = fields.Str()
cluster_node = UUID()
@staticmethod
def schema_config():
return NodeGPUConfig
class NodeGPUConfig(BaseConfig):
"""
Node gpu config.
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# coding: utf-8
from __future__ import absolute_import, division, print_function
from marshmallow import fields, validate
from polyaxon_sdk import V1Mapping
from polyaxon.schemas.base import BaseConfig, BaseSchema
from polyaxon.schemas.fields.ref_or_obj import RefOrObject
from polyaxon.schemas.polyflow.early_stopping import EarlyStoppingSchema
class MappingSchema(BaseSchema):
kind = fields.Str(allow_none=True, validate=validate.Equal("mapping"))
values = RefOrObject(fields.List(fields.Dict(), required=True), required=True)
concurrency = fields.Int(allow_none=True)
early_stopping = fields.Nested(EarlyStoppingSchema, many=True, allow_none=True)
@staticmethod
def schema_config():
return MappingConfig
class MappingConfig(BaseConfig, V1Mapping):
SCHEMA = MappingSchema
IDENTIFIER = "mapping"
REDUCED_ATTRIBUTES = ["concurrency", "early_stopping"]
IDENTIFIER_KIND = True
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# coding: utf-8
from __future__ import absolute_import, division, print_function
from marshmallow import fields
from polyaxon_sdk import V1RepoInit
from polyaxon.schemas.base import BaseConfig, BaseSchema
class RepoInitSchema(BaseSchema):
name = fields.Str(allow_none=True)
commit = fields.Str(allow_none=True)
branch = fields.Str(allow_none=True)
@staticmethod
def schema_config():
return RepoInitConfig
class RepoInitConfig(BaseConfig, V1RepoInit):
IDENTIFIER = "repo_ref"
SCHEMA = RepoInitSchema
REDUCED_ATTRIBUTES = ["name", "commit", "branch"]
return True
@property
def is_range(self):
return True
@property
def is_categorical(self):
return False
@property
def is_uniform(self):
return False
class MatrixLinSpaceSchema(BaseSchema):
kind = fields.Str(allow_none=True, validate=validate.Equal("linspace"))
value = LinSpace(allow_none=True)
@staticmethod
def schema_config():
return MatrixLinSpaceConfig
class MatrixLinSpaceConfig(BaseConfig):
SCHEMA = MatrixLinSpaceSchema
IDENTIFIER = "linspace"
def __init__(self, value, kind=IDENTIFIER):
self.kind = kind
self.value = value