From 50fc8c02535ead5537d31cff63061172378aa8c4 Mon Sep 17 00:00:00 2001 From: Jae Aeich Date: Sat, 10 Feb 2024 21:50:13 +0530 Subject: [PATCH] fix: change example to examples --- pro_tes/ga4gh/tes/models.py | 95 ++++++++++--------- .../middlewares/task_distribution/distance.py | 2 +- 2 files changed, 52 insertions(+), 45 deletions(-) diff --git a/pro_tes/ga4gh/tes/models.py b/pro_tes/ga4gh/tes/models.py index 0380b19..10990b3 100644 --- a/pro_tes/ga4gh/tes/models.py +++ b/pro_tes/ga4gh/tes/models.py @@ -46,7 +46,7 @@ class TesExecutor(CustomBaseModel): " - `gcr.io/my-org/my-image`\n - " " `myregistryhost:5000/fedora/httpd:version1.0`" ), - example="ubuntu:20.04", + examples=["ubuntu:20.04"], ) command: list[str] = Field( [""], @@ -56,7 +56,7 @@ class TesExecutor(CustomBaseModel): ' Example:\n```\n{\n "command" : ["/bin/md5",' ' "/data/file1"]\n}\n```' ), - example=["/bin/md5", "/data/file1"], + examples=["/bin/md5", "/data/file1"], ) workdir: Optional[str] = Field( None, @@ -65,7 +65,7 @@ class TesExecutor(CustomBaseModel): " in.\nIf not defined, the system will default to the directory" " set by\nthe container image." ), - example="/data/", + examples=["/data/"], ) stdin: Optional[str] = Field( None, @@ -79,7 +79,7 @@ class TesExecutor(CustomBaseModel): ' STDIN\n```\n{\n "command" : ["/bin/md5"],\n "stdin" ' ' : "/data/file1"\n}\n```' ), - example="/data/file1", + examples=["/data/file1"], ) stdout: Optional[str] = Field( None, @@ -89,7 +89,7 @@ class TesExecutor(CustomBaseModel): ' path. Example:\n```\n{\n "stdout" :' ' "/tmp/stdout.log"\n}\n```' ), - example="/tmp/stdout.log", + examples=["/tmp/stdout.log"], ) stderr: Optional[str] = Field( None, @@ -99,7 +99,7 @@ class TesExecutor(CustomBaseModel): ' path. Example:\n```\n{\n "stderr" :' ' "/tmp/stderr.log"\n}\n```' ), - example="/tmp/stderr.log", + examples=["/tmp/stderr.log"], ) env: Optional[dict[str, str]] = Field( None, @@ -109,7 +109,7 @@ class TesExecutor(CustomBaseModel): ' : "/data/config.file",\n "BLASTDB" : ' ' "/data/GRC38",\n "HMMERDB" : "/data/hmmer"\n }\n}\n```' ), - example={"BLASTDB": "/data/GRC38", "HMMERDB": "/data/hmmer"}, + examples=[{"BLASTDB": "/data/GRC38", "HMMERDB": "/data/hmmer"}], ) @@ -117,12 +117,12 @@ class TesExecutorLog(CustomBaseModel): start_time: Optional[str] = Field( None, description="Time the executor started, in RFC 3339 format.", - example="2020-10-02T10:00:00-05:00", + examples=["2020-10-02T10:00:00-05:00"], ) end_time: Optional[str] = Field( None, description="Time the executor ended, in RFC 3339 format.", - example="2020-10-02T11:00:00-05:00", + examples=["2020-10-02T11:00:00-05:00"], ) stdout: Optional[str] = Field( None, @@ -171,7 +171,7 @@ class TesInput(CustomBaseModel): " gs://my-bucket/file2\n - file:///path/to/my/file\n - " " /path/to/my/file" ), - example="s3://my-object-store/file1", + examples=["s3://my-object-store/file1"], ) path: str = Field( ..., @@ -179,7 +179,7 @@ class TesInput(CustomBaseModel): "Path of the file inside the container.\nMust be an " " absolute path." ), - example="/data/file1", + examples=["/data/file1"], ) type: TesFileType content: Optional[str] = Field( @@ -244,13 +244,13 @@ class TesOutputFileLog(CustomBaseModel): " as a string\nbecause official JSON doesn't support int64" " numbers." ), - example=["1024"], + examples=["1024"], ) class TesResources(CustomBaseModel): cpu_cores: Optional[int] = Field( - None, description="Requested number of CPUs", example=4 + None, description="Requested number of CPUs", examples=[4] ) preemptible: Optional[bool] = Field( None, @@ -260,13 +260,17 @@ class TesResources(CustomBaseModel): " no effect when utilized\non some backends that don't" " have the concept of preemptible jobs." ), - example=False, + examples=[False], ) ram_gb: Optional[float] = Field( - None, description="Requested RAM required in gigabytes (GB)", example=8 + None, + description="Requested RAM required in gigabytes (GB)", + examples=[8] ) disk_gb: Optional[float] = Field( - None, description="Requested disk size in gigabytes (GB)", example=40 + None, + description="Requested disk size in gigabytes (GB)", + examples=[40] ) zones: Optional[list[str]] = Field( None, @@ -278,7 +282,7 @@ class TesResources(CustomBaseModel): " define\npriorty queue to which the job is " " assigned." ), - example="us-west-1", + examples=["us-west-1"], ) @@ -298,7 +302,7 @@ class ServiceType(CustomBaseModel): " namespace (e.g. your organization's reverse domain " " name)." ), - example="org.ga4gh", + examples=["org.ga4gh"], ) artifact: Enum = Field( ..., @@ -307,7 +311,7 @@ class ServiceType(CustomBaseModel): " Official GA4GH types should be assigned as part of standards " " approval process. Custom artifacts are supported." ), - example="beacon", + examples=["beacon"], ) version: str = Field( ..., @@ -315,7 +319,7 @@ class ServiceType(CustomBaseModel): "Version of the API or specification. GA4GH specifications " " use semantic versioning." ), - example="1.0.0", + examples=["1.0.0"], ) @@ -323,12 +327,12 @@ class Organization(CustomBaseModel): name: str = Field( ..., description="Name of the organization responsible for the service", - example="My organization", + examples=["My organization"], ) url: AnyUrl = Field( ..., description="URL of the website of the organization (RFC 3986 format)", - example="https://example.com", + examples=["https://example.com"], ) @@ -342,12 +346,12 @@ class Service(CustomBaseModel): " downstream aggregator services e.g. Service" " Registry." ), - example="org.ga4gh.myservice", + examples=["org.ga4gh.myservice"], ) name: str = Field( ..., description="Name of this service. Should be human readable.", - example="My project", + examples=["My project"], ) type: Optional[ServiceType] description: Optional[str] = Field( @@ -356,7 +360,7 @@ class Service(CustomBaseModel): "Description of the service. Should be human readable and " " provide information about the service." ), - example="This service provides...", + examples=["This service provides..."], ) organization: Organization = Field( ..., description="Organization providing the service" @@ -368,7 +372,7 @@ class Service(CustomBaseModel): " a link to a contact form (RFC 3986 format), or an email " " (RFC 2368 format)." ), - example="mailto:support@example.com", + examples=["mailto:support@example.com"], ) documentationUrl: Optional[AnyUrl] = Field( None, @@ -378,7 +382,7 @@ class Service(CustomBaseModel): " your service, including any specifics required to " " access data, e.g. authentication." ), - example="https://docs.myservice.example.com", + examples=["https://docs.myservice.example.com"], ) createdAt: Optional[datetime] = Field( None, @@ -386,7 +390,7 @@ class Service(CustomBaseModel): "Timestamp describing when the service was first deployed " " and available (RFC 3339 format)" ), - example="2019-06-04T12:58:19Z", + examples=["2019-06-04T12:58:19Z"], ) updatedAt: Optional[datetime] = Field( None, @@ -394,7 +398,7 @@ class Service(CustomBaseModel): "Timestamp describing when the service was last updated " " (RFC 3339 format)" ), - example="2019-06-04T12:58:19Z", + examples=["2019-06-04T12:58:19Z"], ) environment: Optional[str] = Field( None, @@ -405,7 +409,7 @@ class Service(CustomBaseModel): " dev, staging. However this is advised and not" " enforced." ), - example="test", + examples=["test"], ) version: str = Field( ..., @@ -416,7 +420,7 @@ class Service(CustomBaseModel): " should be changed whenever the service is" " updated." ), - example="1.0.0", + examples=["1.0.0"], ) @@ -438,7 +442,7 @@ class TesNextTes(CustomBaseModel): url: str = Field( ..., description="TES server to which the task was forwarded.", - example="https://my.tes.instance/", + examples=["https://my.tes.instance/"], ) id: str = Field( ..., @@ -446,7 +450,7 @@ class TesNextTes(CustomBaseModel): "Task identifier assigned by the " "TES server to which the task was forwarded." ), - example="job-0012345", + examples=["job-0012345"], ) forwarded_to: Optional[TesNextTes] = None @@ -469,17 +473,17 @@ class TesTaskLog(CustomBaseModel): description=( "Arbitrary logging metadata included by the implementation." ), - example={"host": "worker-001", "slurmm_id": 123456}, + examples=[{"host": "worker-001", "slurmm_id": 123456}], ) start_time: Optional[str] = Field( None, description="When the task started, in RFC 3339 format.", - example="2020-10-02T10:00:00-05:00", + examples=["2020-10-02T10:00:00-05:00"], ) end_time: Optional[str] = Field( None, description="When the task ended, in RFC 3339 format.", - example="2020-10-02T11:00:00-05:00", + examples=["2020-10-02T11:00:00-05:00"], ) outputs: list[TesOutputFileLog] = Field( ..., @@ -505,7 +509,7 @@ class TesTaskLog(CustomBaseModel): class TesServiceType(ServiceType): - artifact: Artifact = Field(..., example="tes") + artifact: Artifact = Field(..., examples=["tes"]) class TesServiceInfo(Service): @@ -515,7 +519,7 @@ class TesServiceInfo(Service): "Lists some, but not necessarily all, storage locations " " supported\nby the service." ), - example=[ + examples=[ "file:///path/to/local/funnel-storage", "s3://ohsu-compbio-funnel/storage", ], @@ -527,7 +531,7 @@ class TesTask(CustomBaseModel): id: Optional[str] = Field( None, description="Task identifier assigned by the server.", - example="job-0012345", + examples=["job-0012345"], ) state: Optional[TesState] = None name: Optional[str] = Field(None, description="User-provided task name.") @@ -545,7 +549,10 @@ class TesTask(CustomBaseModel): " downloaded\nand mounted into the executor container as" " defined by the task request\ndocument." ), - example=[{"url": "s3://my-object-store/file1", "path": "/data/file1"}], + examples=[[{ + "url": "s3://my-object-store/file1", + "path": "/data/file1" + }]] ) outputs: Optional[list[TesOutput]] = Field( None, @@ -553,7 +560,7 @@ class TesTask(CustomBaseModel): "Output files.\nOutputs will be uploaded from the executor " " container to long-term storage." ), - example=[ + examples=[ { "path": "/data/outfile", "url": "s3://my-object-store/outfile-1", @@ -588,7 +595,7 @@ class TesTask(CustomBaseModel): " a `docker run -v` flag where\nthe container path is " " the same for each executor)." ), - example=["/vol/A/"], + examples=[["/vol/A/"]], ) tags: Optional[dict[str, str]] = Field( None, @@ -599,7 +606,7 @@ class TesTask(CustomBaseModel): ' "cwl-01234",\n "PROJECT_GROUP" : "alice-lab"\n ' " }\n}\n```" ), - example={"WORKFLOW_ID": "cwl-01234", "PROJECT_GROUP": "alice-lab"}, + examples=[{"WORKFLOW_ID": "cwl-01234", "PROJECT_GROUP": "alice-lab"}], ) logs: Optional[list[TesTaskLog]] = Field( @@ -616,7 +623,7 @@ class TesTask(CustomBaseModel): "Date + time the task was created, in RFC 3339 format.\n " " This is set by the system, not the client." ), - example="2020-10-02T10:00:00-05:00", + examples=["2020-10-02T10:00:00-05:00"], ) class Config: diff --git a/pro_tes/plugins/middlewares/task_distribution/distance.py b/pro_tes/plugins/middlewares/task_distribution/distance.py index 9f69b28..505a701 100644 --- a/pro_tes/plugins/middlewares/task_distribution/distance.py +++ b/pro_tes/plugins/middlewares/task_distribution/distance.py @@ -228,7 +228,7 @@ def _get_ips(*args: AnyUrl) -> dict[AnyUrl, str]: ips: dict[AnyUrl, str] = {} for uri in args: try: - ips[uri] = gethostbyname(urlparse(strip_auth(uri)).netloc) + ips[uri] = gethostbyname(urlparse(strip_auth(str(uri))).netloc) except gaierror as exc: raise MiddlewareException( f"Could not determine IP address for URI: {uri}"