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

PrincetonUniversity / slurmise / 17078564745

19 Aug 2025 06:33PM UTC coverage: 92.755% (-0.6%) from 93.337%
17078564745

push

github

web-flow
Refactoring and low hanging fruits (#49)

* feat: add from_dict contructors for job data objects

* chore: pass linter

* fix: several issues

* fix: linting

* fix: fully linted and sorted

* fix: tests after linting

* Apply suggestion from @troycomi

Co-authored-by: Troy Comi <troycomi@gmail.com>

* fix: removing unused functions

* addressing Tryoy's comments

* fix: final linting

---------

Co-authored-by: Troy Comi <troycomi@gmail.com>

136 of 150 branches covered (90.67%)

Branch coverage included in aggregate %.

314 of 355 new or added lines in 20 files covered. (88.45%)

4 existing lines in 3 files now uncovered.

1490 of 1603 relevant lines covered (92.95%)

1.86 hits per line

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

56.41
/tests/test_api.py
1
import multiprocessing
2✔
2
import time
2✔
3
from unittest import mock
2✔
4

5
import pytest
2✔
6

7
from slurmise.api import Slurmise
2✔
8

9

10
def slurmise_record(toml, process_id, error_queue):
2✔
11
    def mock_metadata(kwargs):
×
NEW
12
        return {
×
13
            "slurm_id": kwargs["slurm_id"],
14
            "job_name": "nupack",
15
            "state": "COMPLETED",
16
            "partition": "",
17
            "elapsed_seconds": 97201,
18
            "CPUs": 1,
19
            "memory_per_cpu": 0,
20
            "memory_per_node": 0,
21
            "max_rss": 232,
22
            "step_id": "external",
23
        }
24

UNCOV
25
    try:
×
26
        time.sleep(process_id * 0.1)
×
27
        with mock.patch(
×
28
            "slurmise.slurm.parse_slurm_job_metadata",
29
            side_effect=lambda *args, **kwargs: mock_metadata(kwargs),
30
        ):
31
            slurmise = Slurmise(toml)
×
32
            time.sleep(process_id * 0.1)
×
33
            for i in range(10):
×
NEW
34
                slurmise.record("nupack monomer -T 2 -C simple", slurm_id=str(process_id * 100 + i))
×
UNCOV
35
                time.sleep(process_id * 0.1)
×
NEW
36
    except Exception as e:  # noqa: BLE001
×
37
        error_queue.put(f"PID {process_id}: {e}")
×
38

39

40
def test_multiple_slurmise_instances(simple_toml):
2✔
41
    processes = []
2✔
42
    error_queue = multiprocessing.Queue()
2✔
43
    for i in range(10):
2✔
44
        p = multiprocessing.Process(target=slurmise_record, args=(simple_toml.toml, i, error_queue))
2✔
45
        processes.append(p)
2✔
46
        p.start()
2✔
47

48
    [p.join() for p in processes]
2✔
49

50
    if not error_queue.empty():
2✔
51
        while not error_queue.empty():
×
52
            print(error_queue.get())
×
53
        pytest.fail("Child prcess had error")
×
54

55

56
def test_job_data_from_dict(simple_toml):
2✔
57
    slurmise = Slurmise(simple_toml.toml)
2✔
58
    result = slurmise.job_data_from_dict(
2✔
59
        {"threads": 3, "complexity": "simple"},
60
        "nupack",
61
    )
62
    assert result.categorical == {"complexity": "simple"}
2✔
63
    assert result.numerical == {"threads": 3}
2✔
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

© 2026 Coveralls, Inc