Skip to content

Commit 2ca7e56

Browse files
authored
Merge pull request #431 from ExaWorks/fix_nodefile_test
Some testing fixes
2 parents 5bb7734 + fa4b671 commit 2ca7e56

File tree

6 files changed

+37
-15
lines changed

6 files changed

+37
-15
lines changed

docs/_static/extras.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ function detectAll(selectorType) {
6767
// simple_value_2. However, if either "B" or "C" are selected in either selector,
6868
// we want to change both.
6969

70-
console.log("type:" + selectorType);
7170
$("p." + selectorType + "-selector").addClass(selectorType + "-item");
7271
var prevSpans = [];
7372
$("span").each(function() {
@@ -91,6 +90,28 @@ function detectAll(selectorType) {
9190
$(this).text("PROJECT_NAME");
9291
}
9392
}
93+
if (text == '_get_executor_instance') {
94+
// replace _get_executor_instance(execparams, job) with selector value
95+
// the spans are: "_get_executor_instance", "(", "execparams", ",", "job", ")"
96+
// we need: "JobExecutor", ".", "get_instance", "(", selector, ")"
97+
// the classes happen to match, so just replace the text
98+
// also, remove the space after the comma, which is rendered by sphinx as a text
99+
// node rather than span like everything else
100+
var crt = $(this);
101+
var space = $(this).next().next().next().get(0).nextSibling;
102+
if (space.nodeType == 3) {
103+
space.nodeValue = "";
104+
}
105+
else {
106+
console.log("Expected a text node: ", space);
107+
}
108+
var newText = ["JobExecutor", ".", "get_instance", "("];
109+
for (var i = 0; i < 4; i++) {
110+
crt.text(newText[i]);
111+
crt = crt.next();
112+
}
113+
crt.addClass(selectorType + "-item").addClass("psij-selector-value");
114+
}
94115
prevSpans.push($(this));
95116
if (prevSpans.length > 2) {
96117
prevSpans.shift();

docs/user_guide.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ processes on each node, for a total of 8 processes:
254254
.. literalinclude:: ../tests/user_guide/test_resourcespec.py
255255
:language: python
256256
:dedent: 4
257-
:lines: 9-17
257+
:lines: 8-16
258258

259259
.. note::
260260
All processes of a job will share at most one MPI communicator
@@ -332,7 +332,7 @@ and an instance of the
332332
.. literalinclude:: ../tests/user_guide/test_scheduling_information.py
333333
:language: python
334334
:dedent: 4
335-
:lines: 11-19
335+
:lines: 10-18,21-22
336336

337337
where `QUEUE_NAME` is the LRM queue where the job should be sent and
338338
`PROJECT_NAME` is a project/account that may need to be specified for

tests/getting_started/test_simple_example.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
from executor_test_params import ExecutorTestParams
22

3-
from _test_tools import assert_completed
3+
from _test_tools import assert_completed, _get_executor_instance
44

55

66
def test_getting_started_single_job(execparams: ExecutorTestParams) -> None:
7-
from psij import Job, JobSpec, JobExecutor
7+
from psij import Job, JobSpec
88

9-
ex = JobExecutor.get_instance(execparams.executor)
109
job = Job(JobSpec(executable="/bin/date"))
10+
ex = _get_executor_instance(execparams, job)
1111
ex.submit(job)
1212

1313
status = job.wait()

tests/test_nodefile.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
import pytest
66

7-
from _test_tools import assert_completed
7+
from _test_tools import assert_completed, _get_executor_instance
88
from executor_test_params import ExecutorTestParams
9-
from psij import Job, JobSpec, JobExecutor, ResourceSpecV1
9+
from psij import Job, JobSpec, ResourceSpecV1
1010

1111
NOT_TESTED = set(['rp', 'flux'])
1212

@@ -24,7 +24,7 @@ def test_nodefile(execparams: ExecutorTestParams) -> None:
2424
stdout_path=outp)
2525
job = Job(spec)
2626
spec.resources = ResourceSpecV1(process_count=N_PROC)
27-
ex = JobExecutor.get_instance(execparams.executor)
27+
ex = _get_executor_instance(execparams, job)
2828
ex.submit(job)
2929
status = job.wait()
3030
assert_completed(job, status)
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
from psij import Job, JobSpec, JobExecutor, ResourceSpecV1
1+
from psij import Job, JobSpec, ResourceSpecV1
22
from executor_test_params import ExecutorTestParams
33

4-
from _test_tools import assert_completed
4+
from _test_tools import assert_completed, _get_executor_instance
55

66

77
def test_user_guide_resourcespec(execparams: ExecutorTestParams) -> None:
8-
ex = JobExecutor.get_instance(execparams.executor)
98
job = Job(
109
JobSpec(
1110
executable='/bin/date',
@@ -15,6 +14,7 @@ def test_user_guide_resourcespec(execparams: ExecutorTestParams) -> None:
1514
)
1615
)
1716
)
17+
ex = _get_executor_instance(execparams, job)
1818
ex.submit(job)
1919
status = job.wait()
2020
assert_completed(job, status)

tests/user_guide/test_scheduling_information.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
from psij import Job, JobSpec, JobExecutor, JobAttributes
1+
from psij import Job, JobSpec, JobAttributes
22
# from psij import JobAttributes
33
from executor_test_params import ExecutorTestParams
44

5-
from _test_tools import assert_completed
5+
from _test_tools import assert_completed, _get_executor_instance
66

77

88
def test_user_guide_scheduling_info(execparams: ExecutorTestParams) -> None:
9-
executor = JobExecutor.get_instance(execparams.executor)
109

1110
job = Job(
1211
JobSpec(
@@ -18,6 +17,8 @@ def test_user_guide_scheduling_info(execparams: ExecutorTestParams) -> None:
1817
)
1918
)
2019

20+
executor = _get_executor_instance(execparams, job)
21+
2122
executor.submit(job)
2223
status = job.wait()
2324
assert_completed(job, status)

0 commit comments

Comments
 (0)