Skip to content

Commit c91c839

Browse files
chore: rename commands to a verb_nouns format
1 parent 6089b09 commit c91c839

7 files changed

Lines changed: 51 additions & 49 deletions

src/dirac_cwl/commands/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
"""Command classes for workflow pre/post-processing operations."""
22

33
from .analyze_xml_summary import AnalyseXmlSummary
4-
from .bookkeeping_report import BookkeepingReport
54
from .core import PostProcessCommand, PreProcessCommand
6-
from .failover_request import FailoverRequest
5+
from .create_failover_request import CreateFailoverRequest
6+
from .register_accounting_report import RegisterAccountingReport
7+
from .report_bookkeeping import ReportBookkeeping
78
from .upload_log_file import UploadLogFile
89
from .upload_output_data import UploadOutputData
9-
from .workflow_accounting import WorkflowAccounting
1010

1111
__all__ = [
1212
"AnalyseXmlSummary",
1313
"PreProcessCommand",
1414
"PostProcessCommand",
1515
"UploadLogFile",
16-
"BookkeepingReport",
17-
"FailoverRequest",
16+
"ReportBookkeeping",
17+
"CreateFailoverRequest",
1818
"UploadOutputData",
19-
"WorkflowAccounting",
19+
"RegisterAccountingReport",
2020
]

src/dirac_cwl/commands/failover_request.py renamed to src/dirac_cwl/commands/create_failover_request.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
logger = logging.getLogger(__name__)
2121

2222

23-
class FailoverRequest(PostProcessCommand):
23+
class CreateFailoverRequest(PostProcessCommand):
2424
"""Commits the status of the files in the file report.
2525
2626
The status will be "Processed" if everything ended properly or "Unused" if it did not.

src/dirac_cwl/commands/workflow_accounting.py renamed to src/dirac_cwl/commands/register_accounting_report.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
logger = logging.getLogger(__name__)
2323

2424

25-
class WorkflowAccounting(PostProcessCommand):
25+
class RegisterAccountingReport(PostProcessCommand):
2626
"""Prepares and sends accounting information to the DIRAC Accounting system."""
2727

2828
def _execute(self, job_path: os.PathLike[str], workflow_commons: WorkflowCommons, **kwargs):

src/dirac_cwl/commands/bookkeeping_report.py renamed to src/dirac_cwl/commands/report_bookkeeping.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
logger = logging.getLogger(__name__)
2727

2828

29-
class BookkeepingReport(PostProcessCommand):
29+
class ReportBookkeeping(PostProcessCommand):
3030
"""Generates a bookkeeping report file based on the XMLSummary and the pool XML catalog."""
3131

3232
def _execute(self, job_path: os.PathLike[str], workflow_commons: WorkflowCommons, **kwargs):

test/test_command_bookkeeping_report.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Test for the BookkeepingReport command class."""
1+
"""Test for the ReportBookkeeping command class."""
22

33
import time
44
import xml.etree.ElementTree as ET
@@ -11,7 +11,7 @@
1111
from LHCbDIRAC.Core.Utilities.XMLSummaries import XMLSummary
1212
from pytest_mock import MockerFixture
1313

14-
from dirac_cwl.commands import BookkeepingReport
14+
from dirac_cwl.commands import ReportBookkeeping
1515
from dirac_cwl.commands.workflow_commons import StepStatus, WorkflowCommons
1616

1717

@@ -41,31 +41,31 @@ def get_output_file_details(output_file):
4141
return details
4242

4343

44-
class TestBookkeepingReport:
45-
"""Collection of tests for the BookkeepingReport command."""
44+
class TestReportBookkeeping:
45+
"""Collection of tests for the ReportBookkeeping command."""
4646

4747
number_of_processors = 1
4848

4949
@pytest.fixture
50-
def bk_report(self, mocker: MockerFixture, job_path):
51-
"""BookkeepingReport mocked command.
50+
def report_bk(self, mocker: MockerFixture, job_path):
51+
"""ReportBookkeeping mocked command.
5252
5353
Cleans created files after execution.
5454
"""
55-
mock_get_n_procs = mocker.patch("dirac_cwl.commands.bookkeeping_report.getNumberOfProcessorsToUse")
55+
mock_get_n_procs = mocker.patch("dirac_cwl.commands.report_bookkeeping.getNumberOfProcessorsToUse")
5656
mock_get_n_procs.return_value = self.number_of_processors
5757

58-
yield BookkeepingReport()
58+
yield ReportBookkeeping()
5959

6060
Path(job_path).joinpath("00209455_00001537_1").unlink(missing_ok=True)
6161
Path(job_path).joinpath("00209455_00001537_1.sim").unlink(missing_ok=True)
6262
Path(job_path).joinpath("application.log").unlink(missing_ok=True)
6363
Path(job_path).joinpath("workflow_commons.json").unlink(missing_ok=True)
6464

65-
def test_bkreport_prod_mcsimulation_success(
66-
self, bk_report, job_path, wf_commons, bookkeeping_file, xml_summary_file
65+
def test_report_bk_prod_mcsimulation_success(
66+
self, report_bk, job_path, wf_commons, bookkeeping_file, xml_summary_file
6767
):
68-
"""Test successful execution of BookkeepingReport module."""
68+
"""Test successful execution of ReportBookkeeping module."""
6969
wf_commons["steps"][0]["application_name"] = "Gauss"
7070
wf_commons["job_type"] = "MCSimulation"
7171

@@ -124,7 +124,7 @@ def test_bkreport_prod_mcsimulation_success(
124124

125125
WorkflowCommons(**wf_commons).save(job_path)
126126

127-
bk_report.execute(job_path)
127+
report_bk.execute(job_path)
128128

129129
updated_wf_commons = WorkflowCommons.load(job_path)
130130

@@ -187,17 +187,17 @@ def test_bkreport_prod_mcsimulation_success(
187187

188188
assert len(output_files) == 1
189189

190-
def test_bkreport_prod_mcsimulation_noinputoutput_success(
191-
self, bk_report, job_path, wf_commons, bookkeeping_file, xml_summary_file
190+
def test_report_bk_prod_mcsimulation_noinputoutput_success(
191+
self, report_bk, job_path, wf_commons, bookkeeping_file, xml_summary_file
192192
):
193-
"""Test successful execution of BookkeepingReport module.
193+
"""Test successful execution of ReportBookkeeping module.
194194
195195
* No input files because wf_commons["stepInputData is empty
196196
* No output files because wf_commons["stepOutputData is empty
197197
* No pool xml catalog
198198
* Simulation conditions because the application used is Gauss
199199
"""
200-
# Mock the BookkeepingReport module
200+
# Mock the ReportBookkeeping module
201201
wf_commons["steps"][0]["application_name"] = "Gauss"
202202
wf_commons["job_type"] = "MCSimulation"
203203

@@ -251,7 +251,7 @@ def test_bkreport_prod_mcsimulation_noinputoutput_success(
251251

252252
WorkflowCommons(**wf_commons).save(job_path)
253253

254-
bk_report.execute(job_path)
254+
report_bk.execute(job_path)
255255

256256
updated_wf_commons = WorkflowCommons.load(job_path)
257257

@@ -305,10 +305,10 @@ def test_bkreport_prod_mcsimulation_noinputoutput_success(
305305
output_file = root.find("OutputFile")
306306
assert output_file is None, "OutputFile element should not be present."
307307

308-
def test_bk_report_prod_mcreconstruction_success(
309-
self, bk_report, job_path, wf_commons, bookkeeping_file, xml_summary_file
308+
def test_report_bk_prod_mcreconstruction_success(
309+
self, report_bk, job_path, wf_commons, bookkeeping_file, xml_summary_file
310310
):
311-
"""Test successful execution of BookkeepingReport module."""
311+
"""Test successful execution of ReportBookkeeping module."""
312312
wf_commons["steps"][0]["application_name"] = "Boole"
313313
wf_commons["job_type"] = "MCReconstruction"
314314

@@ -359,7 +359,7 @@ def test_bk_report_prod_mcreconstruction_success(
359359

360360
WorkflowCommons(**wf_commons).save(job_path)
361361

362-
bk_report.execute(job_path)
362+
report_bk.execute(job_path)
363363

364364
updated_wf_commons = WorkflowCommons.load(job_path)
365365

@@ -427,7 +427,7 @@ def test_bk_report_prod_mcreconstruction_success(
427427
simulation_condition = root.find("SimulationCondition")
428428
assert simulation_condition is None, "SimulationCondition element should not be present."
429429

430-
def test_bkreport_previousError_success(self, bk_report, job_path, wf_commons, bookkeeping_file):
430+
def test_report_bk_previousError_success(self, report_bk, job_path, wf_commons, bookkeeping_file):
431431
"""Test previous command failure."""
432432
wf_commons["steps"][0]["application_name"] = "Gauss"
433433
wf_commons["steps"][0]["application_version"] = wf_commons["config_version"]
@@ -436,6 +436,6 @@ def test_bkreport_previousError_success(self, bk_report, job_path, wf_commons, b
436436

437437
WorkflowCommons(**wf_commons).save(job_path)
438438

439-
bk_report.execute(job_path)
439+
report_bk.execute(job_path)
440440

441441
assert not Path(bookkeeping_file).exists()

test/test_command_failover_request.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
from DIRACCommon.Core.Utilities.ReturnValues import S_ERROR, S_OK
1212
from pytest_mock import MockerFixture
1313

14-
from dirac_cwl.commands import FailoverRequest
14+
from dirac_cwl.commands import CreateFailoverRequest
1515
from dirac_cwl.commands.workflow_commons import WorkflowCommons
1616

1717

18-
class TestFailoverRequest:
18+
class TestCreateFailoverRequest:
1919
"""Collection of tests for the FailoverRequest command."""
2020

2121
@pytest.fixture
@@ -28,7 +28,7 @@ def failover_request(self, mocker: MockerFixture, wf_commons, job_path):
2828
"DIRAC.RequestManagementSystem.private.RequestValidator.RequestValidator.validate", return_value=S_OK()
2929
)
3030

31-
command = FailoverRequest()
31+
command = CreateFailoverRequest()
3232
command.request = Request()
3333
command.file_report = FileReport()
3434
command.failover_transfer = FailoverTransfer(command.request)
@@ -41,7 +41,9 @@ def failover_request(self, mocker: MockerFixture, wf_commons, job_path):
4141

4242
Path(job_path).joinpath("workflow_commons.json").unlink(missing_ok=True)
4343

44-
def test_failoverRequest_success(self, mocker: MockerFixture, failover_request, job_path, wf_commons, request_file):
44+
def test_failover_request_success(
45+
self, mocker: MockerFixture, failover_request, job_path, wf_commons, request_file
46+
):
4547
"""Test successful execution of FailoverRequest module."""
4648
problematic_files = [
4749
"/lhcb/data/2010/EW.DST/00008380/0000/00008380_00000287_1.ew.dst",
@@ -86,7 +88,7 @@ def test_failoverRequest_success(self, mocker: MockerFixture, failover_request,
8688
# Make sure the request json does not exists
8789
assert not Path(request_file).exists()
8890

89-
def test_failoverRequest_commitFailure1(
91+
def test_failover_request_commitFailure1(
9092
self, mocker: MockerFixture, failover_request, job_path, wf_commons, request_file
9193
):
9294
"""Test execution of FailoverRequest module when the fileReport.commit() fails.
@@ -139,7 +141,7 @@ def test_failoverRequest_commitFailure1(
139141
# Make sure the request json does not exists
140142
assert not Path(request_file).exists()
141143

142-
def test_failoverRequest_commitFailure2(
144+
def test_failover_request_commitFailure2(
143145
self, mocker: MockerFixture, failover_request, job_path, wf_commons, request_file
144146
):
145147
"""Test execution of FailoverRequest module when the fileReport.commit() fails.
@@ -196,7 +198,7 @@ def test_failoverRequest_commitFailure2(
196198
# Make sure the request json does not exists
197199
assert Path(request_file).exists()
198200

199-
def test_failoverRequest_previousError_fail(
201+
def test_failover_request_previousError_fail(
200202
self, mocker: MockerFixture, failover_request, job_path, wf_commons, request_file
201203
):
202204
"""Test FailoverRequest with an intentional failure."""

test/test_command_workflow_accounting.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Test for the WorkflowAccounting command class."""
1+
"""Test for the RegisterAccountingReport command class."""
22

33
from pathlib import Path
44
from textwrap import dedent
@@ -7,17 +7,17 @@
77
from DIRAC.AccountingSystem.Client.DataStoreClient import DataStoreClient
88
from pytest_mock import MockerFixture
99

10-
from dirac_cwl.commands import WorkflowAccounting
10+
from dirac_cwl.commands import RegisterAccountingReport
1111
from dirac_cwl.commands.workflow_commons import StepStatus, WorkflowCommons
1212

1313

14-
class TestWorkflowAccounting:
15-
"""Collection of tests for the WorkflowAccounting command."""
14+
class TestRegisterAccountingReport:
15+
"""Collection of tests for the RegisterAccountingReport command."""
1616

1717
@pytest.fixture
1818
def accounting(self, mocker: MockerFixture, job_path):
19-
"""Fixture for WorkflowAccounting module."""
20-
command = WorkflowAccounting()
19+
"""Fixture for RegisterAccountingReport module."""
20+
command = RegisterAccountingReport()
2121

2222
command.dsc = DataStoreClient()
2323
mocker.patch.object(command.dsc, "addRegister")
@@ -28,7 +28,7 @@ def accounting(self, mocker: MockerFixture, job_path):
2828

2929
# Test Scenarios
3030
def test_accounting_success(self, mocker: MockerFixture, job_path, accounting, wf_commons, xml_summary_file):
31-
"""Test successful execution of WorkflowAccounting module."""
31+
"""Test successful execution of RegisterAccountingReport module."""
3232
wf_commons["steps"][0]["application_name"] = "Gauss"
3333
xml_content = dedent("""<?xml version="1.0" encoding="UTF-8"?>
3434
<summary version="1.0" xsi:noNamespaceSchemaLocation="$XMLSUMMARYBASEROOT/xml/XMLSummary.xsd"
@@ -69,7 +69,7 @@ def test_accounting_success(self, mocker: MockerFixture, job_path, accounting, w
6969
def test_accounting_noApplicationName_fail(
7070
self, mocker: MockerFixture, job_path, accounting, wf_commons, xml_summary_file
7171
):
72-
"""Test WorkflowAccounting when there is no application name in step commons."""
72+
"""Test RegisterAccountingReport when there is no application name in step commons."""
7373
xml_content = dedent("""<?xml version="1.0" encoding="UTF-8"?>
7474
<summary version="1.0" xsi:noNamespaceSchemaLocation="$XMLSUMMARYBASEROOT/xml/XMLSummary.xsd"
7575
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
@@ -107,7 +107,7 @@ def test_accounting_noApplicationName_fail(
107107
def test_accounting_incompleteData_success(
108108
self, mocker: MockerFixture, job_path, accounting, wf_commons, xml_summary_file
109109
):
110-
"""Test successful execution of WorkflowAccounting module."""
110+
"""Test successful execution of RegisterAccountingReport module."""
111111
xml_content = dedent("""<?xml version="1.0" encoding="UTF-8"?>
112112
<summary version="1.0" xsi:noNamespaceSchemaLocation="$XMLSUMMARYBASEROOT/xml/XMLSummary.xsd"
113113
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
@@ -145,7 +145,7 @@ def test_accounting_incompleteData_success(
145145
def test_accounting_previousError_fail(
146146
self, mocker: MockerFixture, job_path, accounting, wf_commons, xml_summary_file
147147
):
148-
"""Test WorkflowAccounting with an intentional failure."""
148+
"""Test RegisterAccountingReport with an intentional failure."""
149149
xml_content = dedent("""<?xml version="1.0" encoding="UTF-8"?>
150150
<summary version="1.0" xsi:noNamespaceSchemaLocation="$XMLSUMMARYBASEROOT/xml/XMLSummary.xsd"
151151
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

0 commit comments

Comments
 (0)