diff --git a/pyproject.toml b/pyproject.toml index c6f2fb2..e751509 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "vo-models" -version = "0.2.1" +version = "0.2.2" authors = [ {name = "Joshua Fraustro", email="jfraustro@stsci.edu"}, {name = "MAST Archive Developers", email="archive@stsci.edu"} diff --git a/vo_models/uws/models.py b/vo_models/uws/models.py index 68ce14f..f29110b 100644 --- a/vo_models/uws/models.py +++ b/vo_models/uws/models.py @@ -1,7 +1,6 @@ """UWS Job Schema using Pydantic-XML models""" from typing import Dict, Generic, Optional, TypeVar -from pydantic import field_validator from pydantic_xml import BaseXmlModel, attr, element from vo_models.uws.types import ErrorType, ExecutionPhase, UWSVersion @@ -21,10 +20,6 @@ class Parameter(BaseXmlModel, tag="parameter", ns="uws", nsmap=NSMAP): """A UWS Job parameter - The list of input parameters to the job - if the job description language does not naturally have - parameters, then this list should contain one element which is the content of the original POST that created the - job. - Attributes: byReference (bool): If this attribute is true then the content of the parameter represents a URL to retrieve the actual parameter value. @@ -39,22 +34,21 @@ class Parameter(BaseXmlModel, tag="parameter", ns="uws", nsmap=NSMAP): value (str): the value of the parameter. """ - value: Optional[str] = None + value: Optional[str | int | float | bool | bytes] = None # only primitive types are allowed by_reference: Optional[bool] = attr(name="byReference", default=False) id: str = attr() is_post: Optional[bool] = attr(name="isPost", default=False) - @field_validator("value", mode="before") - def validate_value(cls, value): # pylint: disable=no-self-argument - """Coerces value to a string""" - # TODO: Find better way to handle arbitrary types - if value is not None: - return str(value) - class Parameters(BaseXmlModel, tag="parameters", ns="uws", nsmap=NSMAP): - """An abstract holder of UWS parameters.""" + """ + An abstract holder of UWS parameters. + + The list of input parameters to the job - if the job description language does not naturally have + parameters, then this list should contain one element which is the content of the original POST that created the + job. + """ def __init__(__pydantic_self__, **data) -> None: # pylint: disable=no-self-argument # during init -- especially if reading from xml -- we may not get the parameters in the order @@ -170,10 +164,6 @@ class Jobs(BaseXmlModel, tag="jobs", ns="uws", nsmap=NSMAP): version: Optional[UWSVersion] = attr(default=UWSVersion.V1_1) -# pylint: disable=invalid-name -ParametersType = TypeVar("ParametersType", bound=Parameters) - - class JobSummary(BaseXmlModel, Generic[ParametersType], tag="job", ns="uws", nsmap=NSMAP): """The complete representation of the state of a job diff --git a/vo_models/vosi/availability/models.py b/vo_models/vosi/availability/models.py index be2b9b8..70d257e 100644 --- a/vo_models/vosi/availability/models.py +++ b/vo_models/vosi/availability/models.py @@ -13,7 +13,7 @@ } -class Availability(BaseXmlModel, tag="availability", nsmap=NSMAP): +class Availability(BaseXmlModel, tag="availability", nsmap=NSMAP, skip_empty=True): """VOSI Availability complex type. Elements: @@ -26,7 +26,7 @@ class Availability(BaseXmlModel, tag="availability", nsmap=NSMAP): """ available: bool = element(tag="available") - up_since: Optional[UTCTimestamp] = element(tag="upSince") - down_at: Optional[UTCTimestamp] = element(tag="downAt") - back_at: Optional[UTCTimestamp] = element(tag="backAt") - note: Optional[list[str]] = element(tag="note") + up_since: Optional[UTCTimestamp] = element(tag="upSince", default=None) + down_at: Optional[UTCTimestamp] = element(tag="downAt", default=None) + back_at: Optional[UTCTimestamp] = element(tag="backAt", default=None) + note: Optional[list[str]] = element(tag="note", default=None)