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

PrincetonUniversity / slurmise / 20138832884

11 Dec 2025 03:45PM UTC coverage: 93.238% (+0.1%) from 93.142%
20138832884

Pull #58

github

web-flow
Merge ab5ef1f5d into 77a973b14
Pull Request #58: Bugfix job database.iterate jobs

139 of 152 branches covered (91.45%)

Branch coverage included in aggregate %.

40 of 44 new or added lines in 8 files covered. (90.91%)

1 existing line in 1 file now uncovered.

1557 of 1667 relevant lines covered (93.4%)

2.8 hits per line

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

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

5
import pytest
3✔
6

7
from slurmise.api import Slurmise
3✔
8

9

10
def slurmise_record(toml, process_id, error_queue):
3✔
11
    def mock_metadata(kwargs):
×
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

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):
×
34
                slurmise.record("nupack monomer -T 2 -C simple", slurm_id=str(process_id * 100 + i))
×
35
                time.sleep(process_id * 0.1)
×
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):
3✔
41
    processes = []
3✔
42
    error_queue = multiprocessing.Queue()
3✔
43
    for i in range(10):
3✔
44
        p = multiprocessing.Process(target=slurmise_record, args=(simple_toml.toml, i, error_queue))
3✔
45
        processes.append(p)
3✔
46
        p.start()
3✔
47

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

50
    if not error_queue.empty():
3✔
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):
3✔
57
    slurmise = Slurmise(simple_toml.toml)
3✔
58
    result = slurmise.job_data_from_dict(
3✔
59
        {"threads": 3, "complexity": "simple"},
60
        "nupack",
61
    )
62
    assert result.categories == {"complexity": "simple"}
3✔
63
    assert result.numerics == {"threads": 3}
3✔
64

65

66
@pytest.mark.parametrize(
3✔
67
    "toml_fixture",
68
    ["simple_toml", "nupackdefaults_toml", "small_db_toml"],
69
)
70
def test_update_all_models(toml_fixture, request):
3✔
71
    toml = request.getfixturevalue(toml_fixture)
3✔
72
    slurmise = Slurmise(toml.toml)
3✔
73
    try:
3✔
74
        slurmise.update_all_models()
3✔
75
    except ValueError as e:
3✔
76
        # If there is not enough data to fit a model, a ValueError is raised
77
        # by sklearn train_test_split. Currently happening with small_db_toml fixture
78
        # because there is only one job with "filesizes" numeric feature.
79
        if str(e).startswith("Cannot have number of splits n_splits="):
3✔
NEW
80
            pass
×
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