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

simonsobs / so_campaign_manager / 16224615683

11 Jul 2025 04:13PM UTC coverage: 48.564% (-2.1%) from 50.63%
16224615683

Pull #46

github

web-flow
Merge be40794fd into 484f19548
Pull Request #46: Gp/feat/mission set

49 of 145 branches covered (33.79%)

Branch coverage included in aggregate %.

78 of 185 new or added lines in 13 files covered. (42.16%)

10 existing lines in 4 files now uncovered.

526 of 1039 relevant lines covered (50.63%)

0.51 hits per line

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

89.36
/tests/conftest.py
1
from pathlib import Path
1✔
2
from unittest import mock
1✔
3

4
import pytest
1✔
5

6

7
@pytest.fixture
1✔
8
def mock_filemd5():
1✔
9
    """Create a fixture that returns a mock Context class."""
10
    with mock.patch("socm.bookkeeper.bookkeeper.FileMD5") as mocked:
1✔
11
        # Create the mock context behavior
12
        class MockContextImpl:
1✔
13
            def __init__(self):
1✔
UNCOV
14
                pass
×
15

16
            def parse_file(self, path: Path, gzip_file: bool = False):
1✔
UNCOV
17
                return "efca7302276bceac49b8326a7b88f008"
×
18

19
        # Set the side effect to use our implementation
20
        mocked.side_effect = MockContextImpl
1✔
21
        yield mocked
1✔
22

23

24
@pytest.fixture
1✔
25
def mock_slurmise():
1✔
26
    """Create a fixture that returns a mock Context class."""
27
    with mock.patch("socm.bookkeeper.bookkeeper.Slurmise") as mocked:
1✔
28
        # Create the mock context behavior
29
        class MockContextImpl:
1✔
30
            def __init__(self, toml_path):
1✔
31
                self._toml_path = toml_path
×
32

33
            def raw_record(self, job_data):
1✔
34
                assert dict(job_data) == {
×
35
                    "job_name": "ml_mapmaking_workflow",
36
                    "slurm_id": "1181754.5",
37
                    "categorical": {
38
                        "subcommand": "make-ml-map",
39
                        "area": "efca7302276bceac49b8326a7b88f008",
40
                        "comps": "TQU",
41
                        "bands": "f090",
42
                        "nmat": "corr",
43
                        "site": "act",
44
                    },
45
                    "numerical": {
46
                        "ranks": 1,
47
                        "threads": 32,
48
                        "datasize": 259864,
49
                        "downsample": 1,
50
                        "maxiter": 10,
51
                        "tiled": 1,
52
                    },
53
                    "memory": 41669,
54
                    "runtime": 2.05,
55
                    "cmd": "srun --cpu_bind=cores --export=ALL --ntasks-per-node=1 --cpus-per-task=8 so-site-pipeline make-ml-map obs_id='1575600533.1575611468.ar5_1' /scratch/gpfs/SIMONSOBS/so/science-readiness/footprint/v20250306/so_geometry_v20250306_lat_f090.fits /scratch/gpfs/SIMONSOBS/users/ip8725/git/so_mapmaking_campaign_manager/output --bands=f090 --comps=TQU --context=/scratch/gpfs/ACT/data/context-so-fixed/context.yaml --maxiter=10 --site=act --tiled=1 --wafer=ws0",
56
                }
57

58
        # Set the side effect to use our implementation
59
        mocked.side_effect = MockContextImpl
1✔
60
        yield mocked
1✔
61

62

63
@pytest.fixture
1✔
64
def mock_parse_slurm_job_metadata():
1✔
65
    """Create a fixture that returns a mock Context class."""
66
    with mock.patch("socm.bookkeeper.bookkeeper.parse_slurm_job_metadata") as mocked:
1✔
67
        # Create the mock context behavior
68
        # Set the side effect to use our implementation
69
        mocked.return_value = {
1✔
70
            "slurm_id": 1181754,
71
            "step_id": "5",
72
            "job_name": "interactive",
73
            "state": "RUNNING",
74
            "partition": "cpu",
75
            "elapsed_seconds": 123,
76
            "CPUs": 112,
77
            "memory_per_cpu": {"set": True, "infinite": False, "number": 8000},
78
            "memory_per_node": {"set": False, "infinite": False, "number": 0},
79
            "max_rss": 41669,
80
        }
81

82
        yield mocked
1✔
83

84

85
@pytest.fixture
1✔
86
def mock_context():
1✔
87
    """Create a fixture that returns a mock Context class."""
88
    with mock.patch("socm.workflows.ml_mapmaking.Context") as mocked:
1✔
89
        # Create the mock context behavior
90
        class MockContextImpl:
1✔
91
            def __init__(self, context_file):
1✔
92
                self.obsdb = mock.Mock()
1✔
93
                self.obsdb.query = mock.Mock(
1✔
94
                    return_value=[{"obs_id": "1575600533.1575611468.ar5_1", "n_samples": 259584}]
95
                )
96

97
            def get_meta(self, obs_id):
1✔
UNCOV
98
                return mock.Mock(samps=mock.Mock(count=1000))
×
99

100
        # Set the side effect to use our implementation
101
        mocked.side_effect = MockContextImpl
1✔
102
        yield mocked
1✔
103

104

105
@pytest.fixture
1✔
106
def simple_config():
1✔
107
    """Return a dictionary with test configuration instead of a TOML file path."""
108
    config = {
1✔
109
        "campaign": {
110
            "ml-mapmaking": {
111
                "context": "context.yaml",
112
                "area": "so_geometry_v20250306_lat_f090.fits",
113
                "output_dir": "output",
114
                "bands": "f090",
115
                "wafer": "ws0",
116
                "comps": "TQU",
117
                "maxiter": 10,
118
                "query": "obs_id='1575600533.1575611468.ar5_1'",
119
                "tiled": 1,
120
                "site": "act",
121
                "environment": {
122
                    "MOBY2_TOD_STAGING_PATH": "/tmp/",
123
                    "DOT_MOBY2": "act_dot_moby2",
124
                    "SOTODLIB_SITECONFIG": "site.yaml",
125
                },
126
            }
127
        }
128
    }
129
    return config
1✔
130

131

132
@pytest.fixture
1✔
133
def lite_config():
1✔
134
    """
135
    A lightweight configuration for testing ML mapmaking workflows.
136
    """
137
    config = {
1✔
138
        "campaign": {
139
            "ml-mapmaking": {
140
                "context": "context.yaml",
141
                "area": "so_geometry_v20250306_lat_f090.fits",
142
                "output_dir": "output",
143
                "query": "obs_id='1575600533.1575611468.ar5_1'",
144
                "site": "act",
145
                "resources": {
146
                    "ranks": 8,
147
                    "threads": 1,
148
                },
149
            },
150
            "sat-sims": {
151
                "context": "context.yaml",
152
                "schedule": "schedule0002.txt",
153
                "output_dir": "output",
154
                "filterbin_name": "filterbin_01_schedule0002",
155
                "resources": {
156
                    "ranks": 8,
157
                    "threads": 1,
158
                },
159
            },
160
        }
161
    }
162

163
    return config
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