Skip to content

Commit

Permalink
fix: change example to examples
Browse files Browse the repository at this point in the history
  • Loading branch information
JaeAeich committed Feb 10, 2024
1 parent 3b9419b commit 50fc8c0
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 45 deletions.
95 changes: 51 additions & 44 deletions pro_tes/ga4gh/tes/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
[""],
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -109,20 +109,20 @@ 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"}],
)


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,
Expand Down Expand Up @@ -171,15 +171,15 @@ 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(
...,
description=(
"Path of the file inside the container.\nMust be an "
" absolute path."
),
example="/data/file1",
examples=["/data/file1"],
)
type: TesFileType
content: Optional[str] = Field(
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -278,7 +282,7 @@ class TesResources(CustomBaseModel):
" define\npriorty queue to which the job is "
" assigned."
),
example="us-west-1",
examples=["us-west-1"],
)


Expand All @@ -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(
...,
Expand All @@ -307,28 +311,28 @@ 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(
...,
description=(
"Version of the API or specification. GA4GH specifications "
" use semantic versioning."
),
example="1.0.0",
examples=["1.0.0"],
)


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"],
)


Expand All @@ -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(
Expand All @@ -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"
Expand All @@ -368,7 +372,7 @@ class Service(CustomBaseModel):
" a link to a contact form (RFC 3986 format), or an email "
" (RFC 2368 format)."
),
example="mailto:[email protected]",
examples=["mailto:[email protected]"],
)
documentationUrl: Optional[AnyUrl] = Field(
None,
Expand All @@ -378,23 +382,23 @@ 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,
description=(
"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,
description=(
"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,
Expand All @@ -405,7 +409,7 @@ class Service(CustomBaseModel):
" dev, staging. However this is advised and not"
" enforced."
),
example="test",
examples=["test"],
)
version: str = Field(
...,
Expand All @@ -416,7 +420,7 @@ class Service(CustomBaseModel):
" should be changed whenever the service is"
" updated."
),
example="1.0.0",
examples=["1.0.0"],
)


Expand All @@ -438,15 +442,15 @@ 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(
...,
description=(
"Task identifier assigned by the "
"TES server to which the task was forwarded."
),
example="job-0012345",
examples=["job-0012345"],
)
forwarded_to: Optional[TesNextTes] = None

Expand All @@ -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(
...,
Expand All @@ -505,7 +509,7 @@ class TesTaskLog(CustomBaseModel):


class TesServiceType(ServiceType):
artifact: Artifact = Field(..., example="tes")
artifact: Artifact = Field(..., examples=["tes"])


class TesServiceInfo(Service):
Expand All @@ -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",
],
Expand All @@ -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.")
Expand All @@ -545,15 +549,18 @@ 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,
description=(
"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",
Expand Down Expand Up @@ -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,
Expand All @@ -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(
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pro_tes/plugins/middlewares/task_distribution/distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down

0 comments on commit 50fc8c0

Please sign in to comment.