Skip to content

Commit

Permalink
feat: add TES models with unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Karanjot786 committed Oct 12, 2024
1 parent ed91033 commit 7adf65b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 23 deletions.
34 changes: 12 additions & 22 deletions crategen/models/tes_models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""
Each model in this module conforms to the corresponding TES model names as specified by the GA4GH schema (https://ga4gh.github.io/task-execution-schemas/docs/).
"""
"""Each model in this module conforms to the corresponding TES model names as specified by the GA4GH schema (https://ga4gh.github.io/task-execution-schemas/docs/)."""

import os
from datetime import datetime
Expand Down Expand Up @@ -30,8 +28,7 @@ class TESState(str, Enum):


class TESOutputFileLog(BaseModel):
"""
Information about all output files. Directory outputs are flattened into separate items.
"""Information about all output files. Directory outputs are flattened into separate items.
**Attributes:**
Expand All @@ -48,8 +45,7 @@ class TESOutputFileLog(BaseModel):


class TESExecutorLog(BaseModel):
"""
Logs for each executor
"""Logs for each executor.
**Attributes:**
Expand All @@ -74,8 +70,7 @@ def validate_datetime(cls, value):


class TESExecutor(BaseModel):
"""
An array of executors to be run
"""An array of executors to be run
**Attributes:**
- **image** (`str`): Name of the container image.
Expand Down Expand Up @@ -106,8 +101,7 @@ def validate_stdin_stdin(cls, value, field):


class TESResources(BaseModel):
"""
Represents the resources required by a TES task.
"""Represents the resources required by a TES task.
**Attributes:**
Expand All @@ -128,8 +122,7 @@ class TESResources(BaseModel):


class TESInput(BaseModel):
"""
Input files that will be used by the task. Inputs will be downloaded and mounted into the executor container as defined by the task request document.
"""Input files that will be used by the task. Inputs will be downloaded and mounted into the executor container as defined by the task request document.
**Attributes:**
Expand All @@ -152,9 +145,9 @@ class TESInput(BaseModel):

@root_validator()
def validate_content_and_url(cls, values):
"""
- If content is set url should be ignored
- If content is not set then url should be present
"""- If content is set url should be ignored.
- If content is not set then url should be present.
"""
content_is_set = (
values.get("content") and len(values.get("content").strip()) > 0
Expand All @@ -177,8 +170,7 @@ def validate_path(cls, value):


class TESOutput(BaseModel):
"""
Output files. Outputs will be uploaded from the executor container to long-term storage.
"""Output files. Outputs will be uploaded from the executor container to long-term storage.
**Attributes:**
Expand All @@ -205,8 +197,7 @@ def validate_path(cls, value):


class TESTaskLog(BaseModel):
"""
Task logging information. Normally, this will contain only one entry, but in the case where a task fails and is retried, an entry will be appended to this list.
"""Task logging information. Normally, this will contain only one entry, but in the case where a task fails and is retried, an entry will be appended to this list.
**Attributes:**
Expand Down Expand Up @@ -234,8 +225,7 @@ def validate_datetime(cls, value):


class TESData(BaseModel):
"""
Represents a TES task.
"""Represents a TES task.
**Attributes:**
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/test_tes_models.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""Unit tests for the TES models."""

from datetime import datetime, timezone

import pytest
from pydantic import ValidationError
from datetime import datetime, timezone

from crategen.models.tes_models import (
TESInput,
Expand Down

0 comments on commit 7adf65b

Please sign in to comment.