From 38463401dfab0832115e03d5be6dca73f226651e Mon Sep 17 00:00:00 2001 From: Joshua Fraustro Date: Mon, 18 Dec 2023 12:49:46 -0500 Subject: [PATCH 1/4] update parameter to accept all primitive types --- vo_models/uws/models.py | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) 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 From c5b01a485557cdb48c6f568b25a7181c3d852427 Mon Sep 17 00:00:00 2001 From: Joshua Fraustro <36318163+jwfraustro@users.noreply.github.com> Date: Mon, 18 Dec 2023 12:51:18 -0500 Subject: [PATCH 2/4] fix defaults for availability model (#10) --- vo_models/vosi/availability/models.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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) From f54adca5a1cc0d2769a44c0111d2e5a8897484ed Mon Sep 17 00:00:00 2001 From: Joshua Fraustro Date: Mon, 18 Dec 2023 16:30:48 -0500 Subject: [PATCH 3/4] update version number to dev --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c6f2fb2..c67dfda 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.dev" authors = [ {name = "Joshua Fraustro", email="jfraustro@stsci.edu"}, {name = "MAST Archive Developers", email="archive@stsci.edu"} From 58fd1f4e049acbedf1763b59940f0be8666f34a0 Mon Sep 17 00:00:00 2001 From: Joshua Fraustro Date: Mon, 18 Dec 2023 18:28:26 -0500 Subject: [PATCH 4/4] update version to 0.2.2 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c67dfda..e751509 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "vo-models" -version = "0.2.2.dev" +version = "0.2.2" authors = [ {name = "Joshua Fraustro", email="jfraustro@stsci.edu"}, {name = "MAST Archive Developers", email="archive@stsci.edu"}