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

Clinical-Genomics / trailblazer / 9448158538

10 Jun 2024 12:17PM UTC coverage: 89.047%. First build
9448158538

Pull #451

github

seallard
Fix service instantiation
Pull Request #451: Add slurm api service

43 of 72 new or added lines in 9 files covered. (59.72%)

2122 of 2383 relevant lines covered (89.05%)

0.89 hits per line

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

65.22
/trailblazer/clients/slurm_api_client/slurm_api_client.py
1
import logging
1✔
2
import requests
1✔
3

4
from trailblazer.clients.slurm_api_client.dto import (
1✔
5
    SlurmJobResponse,
6
    SlurmJobsResponse,
7
)
8
from trailblazer.exc import SlurmAPIClientError
1✔
9

10

11
LOG = logging.getLogger(__name__)
1✔
12

13

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

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

29
    def get_jobs(self) -> SlurmJobsResponse:
1✔
30
        endpoint: str = f"{self.base_url}/slurm/v0.0.40/jobs"
1✔
31
        response = requests.get(endpoint, headers=self.headers)
1✔
32
        response.raise_for_status()
1✔
33
        return SlurmJobsResponse.model_validate(response.json())
1✔
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