|
22 | 22 | )
|
23 | 23 |
|
24 | 24 |
|
25 |
| -def test_proc_repr(): |
26 |
| - assert repr(SimpleProc) == "<Proc:SimpleProc>" |
27 |
| - |
28 |
| - |
29 |
| -def test_from_proc_no_name(): |
30 |
| - procs = [None] |
31 |
| - with pytest.raises(PipenOrProcNameError): |
32 |
| - procs[0] = Proc.from_proc(SimpleProc) |
33 |
| - |
34 |
| - |
35 |
| -def test_from_proc(): |
36 |
| - proc = Proc.from_proc( |
37 |
| - SimpleProc, |
38 |
| - name="new_proc", |
39 |
| - desc="new desc", |
40 |
| - envs={"a": 1}, |
41 |
| - cache=True, |
42 |
| - forks=2, |
43 |
| - plugin_opts={"p": 1}, |
44 |
| - scheduler="sge", |
45 |
| - scheduler_opts={"s": 1}, |
46 |
| - error_strategy="retry", |
47 |
| - num_retries=10, |
48 |
| - submission_batch=3, |
49 |
| - ) |
50 |
| - assert proc.name == "new_proc" |
51 |
| - assert proc.desc == "new desc" |
52 |
| - assert proc.envs == {"a": 1} |
53 |
| - assert proc.cache |
54 |
| - assert proc.forks == 2 |
55 |
| - assert proc.plugin_opts == {"p": 1} |
56 |
| - assert proc.scheduler == "sge" |
57 |
| - assert proc.scheduler_opts == {"s": 1} |
58 |
| - assert proc.error_strategy == "retry" |
59 |
| - assert proc.num_retries == 10 |
60 |
| - assert proc.submission_batch == 3 |
61 |
| - |
62 |
| - |
63 |
| -def test_cached_run(caplog, pipen): |
64 |
| - NormalProc.nexts = [] |
65 |
| - # force uncache NormalProc |
66 |
| - # shutil.rmtree(pipen.config.workdir) |
67 |
| - ret = pipen.set_start(NormalProc).run() |
68 |
| - assert ret |
69 |
| - |
70 |
| - # trigger caching |
71 |
| - ret = pipen.set_start(NormalProc).run() |
72 |
| - assert ret |
73 |
| - |
74 |
| - assert caplog.text.count("Cached jobs:") == 1 |
75 |
| - |
76 |
| - |
77 | 25 | @pytest.mark.forked
|
78 | 26 | def test_more_nexts(pipen):
|
79 | 27 | proc1 = Proc.from_proc(NormalProc)
|
@@ -112,14 +60,6 @@ def test_proc_with_input_callable(pipen):
|
112 | 60 | assert proc2.output_data.equals(pandas.DataFrame({"output": ["2"]}))
|
113 | 61 |
|
114 | 62 |
|
115 |
| -def test_proc_is_singleton(pipen): |
116 |
| - pipen.workdir = ".pipen/" |
117 |
| - os.makedirs(pipen.workdir, exist_ok=True) |
118 |
| - p1 = SimpleProc(pipen) |
119 |
| - p2 = SimpleProc(pipen) |
120 |
| - assert p1 is p2 |
121 |
| - |
122 |
| - |
123 | 63 | @pytest.mark.forked
|
124 | 64 | def test_ignore_input_data_of_start_proc(caplog, pipen):
|
125 | 65 | proc = Proc.from_proc(NormalProc, input_data=[1])
|
@@ -160,6 +100,66 @@ def test_script_file_exists(pipen):
|
160 | 100 | pipen.set_starts(ScriptNotExistsProc).run()
|
161 | 101 |
|
162 | 102 |
|
| 103 | +def test_proc_repr(): |
| 104 | + assert repr(SimpleProc) == "<Proc:SimpleProc>" |
| 105 | + |
| 106 | + |
| 107 | +def test_from_proc_no_name(): |
| 108 | + procs = [None] |
| 109 | + with pytest.raises(PipenOrProcNameError): |
| 110 | + procs[0] = Proc.from_proc(SimpleProc) |
| 111 | + |
| 112 | + |
| 113 | +def test_from_proc(): |
| 114 | + proc = Proc.from_proc( |
| 115 | + SimpleProc, |
| 116 | + name="new_proc", |
| 117 | + desc="new desc", |
| 118 | + envs={"a": 1}, |
| 119 | + cache=True, |
| 120 | + forks=2, |
| 121 | + plugin_opts={"p": 1}, |
| 122 | + scheduler="sge", |
| 123 | + scheduler_opts={"s": 1}, |
| 124 | + error_strategy="retry", |
| 125 | + num_retries=10, |
| 126 | + submission_batch=3, |
| 127 | + ) |
| 128 | + assert proc.name == "new_proc" |
| 129 | + assert proc.desc == "new desc" |
| 130 | + assert proc.envs == {"a": 1} |
| 131 | + assert proc.cache |
| 132 | + assert proc.forks == 2 |
| 133 | + assert proc.plugin_opts == {"p": 1} |
| 134 | + assert proc.scheduler == "sge" |
| 135 | + assert proc.scheduler_opts == {"s": 1} |
| 136 | + assert proc.error_strategy == "retry" |
| 137 | + assert proc.num_retries == 10 |
| 138 | + assert proc.submission_batch == 3 |
| 139 | + |
| 140 | + |
| 141 | +def test_cached_run(caplog, pipen): |
| 142 | + NormalProc.nexts = [] |
| 143 | + # force uncache NormalProc |
| 144 | + # shutil.rmtree(pipen.config.workdir) |
| 145 | + ret = pipen.set_start(NormalProc).run() |
| 146 | + assert ret |
| 147 | + |
| 148 | + # trigger caching |
| 149 | + ret = pipen.set_start(NormalProc).run() |
| 150 | + assert ret |
| 151 | + |
| 152 | + assert caplog.text.count("Cached jobs:") == 1 |
| 153 | + |
| 154 | + |
| 155 | +def test_proc_is_singleton(pipen): |
| 156 | + pipen.workdir = ".pipen/" |
| 157 | + os.makedirs(pipen.workdir, exist_ok=True) |
| 158 | + p1 = SimpleProc(pipen) |
| 159 | + p2 = SimpleProc(pipen) |
| 160 | + assert p1 is p2 |
| 161 | + |
| 162 | + |
163 | 163 | def test_invalid_name():
|
164 | 164 | with pytest.raises(PipenOrProcNameError):
|
165 | 165 | Proc.from_proc(SimpleProc, name="a b")
|
|
0 commit comments