Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_session_is_passed_to_nested_field_in_list_field(
self, parent_model, child_model, child_schema, session
):
class ParentSchema(ModelSchema):
children = fields.List(Nested(child_schema))
class Meta:
model = parent_model
data = {"name": "Jorge", "children": [{"name": "Jose"}]}
ParentSchema().load(data, session=session)
values.pop("outputs")
class EnvironmentSchema(BaseSchema):
# To indicate which worker/ps index this session config belongs to
index = fields.Int(allow_none=True)
resources = fields.Nested(PodResourcesSchema, allow_none=True)
labels = fields.Dict(allow_none=True)
annotations = fields.Dict(allow_none=True)
node_selector = fields.Dict(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)
max_restarts = fields.Int(allow_none=True)
secret_refs = fields.List(fields.Str(), allow_none=True)
config_map_refs = fields.List(fields.Str(), allow_none=True)
configmap_refs = fields.List(fields.Str(), allow_none=True) # Deprecated
data_refs = fields.List(fields.Str(), allow_none=True)
artifact_refs = fields.List(fields.Str(), allow_none=True)
outputs = fields.Nested(OutputsSchema, allow_none=True) # Deprecated
persistence = fields.Nested(PersistenceSchema, allow_none=True)
@staticmethod
def schema_config():
return EnvironmentConfig
@validates_schema
def validate_configmap_refs(self, values):
validate_configmap_refs(values, is_schema=True)
@validates_schema
from marshmallow import Schema, fields
# pylint: disable=too-few-public-methods
class AnimalSchema(Schema):
name = fields.String(required=True)
age = fields.Integer()
breed = fields.List(fields.String())
description = fields.String()
arrived_date = fields.Date()
fields: Dict[str, ma.fields.Field] = dict_cls()
data_tuple_fields = [
dtype_to_field(dtype) for dtype in opts.dtypes.dtypes
]
fields["data"] = ma.fields.List(
ma.fields.Tuple(data_tuple_fields), required=True
)
index_field = (
ma.fields.Raw()
if index_dtype is None
else dtype_to_field(index_dtype)
)
fields["index"] = ma.fields.List(index_field, required=True)
fields["columns"] = ma.fields.List(
ma.fields.String,
required=True,
validate=ma.validate.Equal(opts.dtypes.columns),
)
return fields
return dict_cls()
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)
@staticmethod
def schema_config():
return ContainerGPUResourcesConfig
class ContainerGPUResourcesConfig(BaseConfig):
SCHEMA = ContainerGPUResourcesSchema
IDENTIFIER = "ContainerGPUResources"
MEM_SIZE_ATTRIBUTES = ["memory_free", "memory_used", "memory_total"]
def __init__(
self,
index,
uuid,
name,
# 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 V1ArtifactMount
from polyaxon.schemas.base import BaseConfig, BaseSchema
class ArtifactMountSchema(BaseSchema):
name = fields.Str(required=True)
paths = fields.List(fields.Str(), allow_none=True)
@staticmethod
def schema_config():
return ArtifactMountConfig
class ArtifactMountConfig(BaseConfig, V1ArtifactMount):
IDENTIFIER = "artifact_mount"
SCHEMA = ArtifactMountSchema
REDUCED_ATTRIBUTES = ["paths"]
IDENTIFIER_KIND = True
'room_ids': fields.List(fields.Int(), missing=None),
'start_dt': fields.DateTime(missing=None),
'last_reservation_id': fields.Int(missing=None),
'my_bookings': fields.Bool(missing=False),
'limit': fields.Int(missing=40),
'text': fields.String(missing=None)
})
def _process(self, room_ids, start_dt, last_reservation_id, my_bookings, limit, text):
start_dt = start_dt or datetime.combine(date.today(), time(0, 0))
booked_for_user = session.user if my_bookings else None
bookings, rows_left = get_active_bookings(limit=limit,
start_dt=start_dt,
last_reservation_id=last_reservation_id,
room_ids=room_ids,
booked_for_user=booked_for_user,
text=text)
return jsonify(bookings=serialize_occurrences(bookings), rows_left=rows_left)
equations = fields.List(fields.Dict())
ChargesSchema = type('ChargeSchema', (BaseSchema,), {element: FloatParameterField() for element in element_symbols})
class KspaceSchema(BaseSchema):
KSPACE_TYPES = {'ewald', 'pppm'}
type = fields.String(required=True, validate=validate.OneOf(KSPACE_TYPES))
tollerance = FloatParameterField(required=True, validate=validate.Range(min=1e-16))
class ParametersSchema(BaseSchema):
elements = fields.List(fields.String(validate=validate.OneOf(element_symbols)), required=True)
coefficients = fields.List(FloatParameterField(allow_none=True))
class PairPotentialSchema(BaseSchema):
PAIR_POTENTIALS = {
'python-function',
'lennard-jones',
'buckingham',
'zbl',
'beck',
'harmonic',
'tersoff',
'tersoff-2',
'stillinger-weber',
'gao-weber',
'vashishta',
'vashishta-mixing',
from marshmallow import fields, Schema
from ...holder.base import BaseHolder
from ...storage.error import StorageNotFoundError
from .manager import PresentationManager
from .models.presentation_exchange import (
PresentationExchange,
PresentationExchangeSchema,
)
class PresentationExchangeListSchema(Schema):
"""Result schema for a presentation exchange query."""
results = fields.List(fields.Nested(PresentationExchangeSchema()))
class PresentationRequestRequestSchema(Schema):
"""Request schema for sending a proof request."""
class RequestedAttribute(Schema):
"""RequestedAttribute model."""
name = fields.Str(required=True)
restrictions = fields.List(fields.Dict(), required=False)
class RequestedPredicate(Schema):
"""RequestedPredicate model."""
name = fields.Str(required=True)
p_type = fields.Str(required=True)
gravatar_id = fields.String()
id = fields.Integer()
login = fields.String()
url = fields.String()
class Gist(Schema):
comments = fields.Integer()
comments_url = fields.String()
created_at = fields.String(description='Timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.')
description = fields.String()
files = fields.Nested('GistFiles')
forks = fields.List(fields.Nested('GistForksItem', ))
git_pull_url = fields.String()
git_push_url = fields.String()
history = fields.List(fields.Nested('GistHistoryItem', ))
html_url = fields.String()
id = fields.String()
public = fields.Boolean()
url = fields.String()
user = fields.Nested('GistUser')
class GistUser(Schema):
avatar_url = fields.String()
gravatar_id = fields.String()
id = fields.Integer()
login = fields.String()
url = fields.String()
class GistHistoryItem(Schema):