• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Clinical-Genomics / trailblazer / 10403778022

15 Aug 2024 12:29PM UTC coverage: 86.292%. First build
10403778022

Pull #463

github

seallard
Add integration test
Pull Request #463: Clean up tower and slurm interactions

156 of 221 new or added lines in 20 files covered. (70.59%)

2027 of 2349 relevant lines covered (86.29%)

0.86 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

58.06
/trailblazer/clients/slurm_api_client/slurm_api_client.py
1
import logging
1✔
2
from pydantic import ValidationError
1✔
3
import requests
1✔
4

5
from trailblazer.clients.slurm_api_client.dto import SlurmJobResponse
1✔
6
from trailblazer.exc import ResponseDeserializationError, SlurmAPIClientError
1✔
7

8

9
LOG = logging.getLogger(__name__)
1✔
10

11

12
class SlurmAPIClient:
1✔
13
    def __init__(self, base_url: str, access_token: str, user_name: str) -> None:
1✔
14
        self.base_url = base_url
1✔
15
        self.headers = {"X-SLURM-USER-NAME": user_name, "X-SLURM-USER-TOKEN": access_token}
1✔
16

17
    def get_job(self, job_id: str) -> SlurmJobResponse:
1✔
18
        endpoint: str = f"{self.base_url}/slurm/v0.0.40/job/{job_id}"
1✔
19
        try:
1✔
20
            response = requests.get(endpoint, headers=self.headers)
1✔
21
            response.raise_for_status()
1✔
22
        except requests.exceptions.HTTPError as e:
×
23
            LOG.error(f"Error getting job {job_id}: {e.response.content}")
×
24
            raise SlurmAPIClientError(e)
×
25

26
        try:
1✔
27
            return SlurmJobResponse.model_validate(response.json())
1✔
28
        except ValidationError as e:
×
29
            LOG.error(f"Error deserializing job response: {e}")
×
30
            raise ResponseDeserializationError(e)
×
31

32
    def cancel_job(self, job_id: str) -> None:
1✔
NEW
33
        endpoint: str = f"{self.base_url}/slurm/v0.0.40/job/{job_id}"
×
NEW
34
        try:
×
NEW
35
            response = requests.delete(endpoint, headers=self.headers)
×
NEW
36
            response.raise_for_status()
×
NEW
37
        except requests.exceptions.HTTPError as e:
×
NEW
38
            LOG.error(f"Error cancelling job {job_id}: {e.response.content}")
×
NEW
39
            raise SlurmAPIClientError(e)
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc