Skip to content

Commit fc3156d

Browse files
committed
Delete the ui sub-package
and move the two modules up to the main level
1 parent 7eb55dc commit fc3156d

6 files changed

Lines changed: 32 additions & 48 deletions

File tree

‎bin/run_one_script‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
# You should have received a copy of the GNU General Public License
2121
# along with this program. If not, see <https://www.gnu.org/licenses/>.
2222

23-
from lsst.ts.scriptqueue.ui import run_one_script_cli
23+
from lsst.ts.scriptqueue import run_one_script_cli
2424

2525

2626
run_one_script_cli()

‎python/lsst/ts/scriptqueue/__init__.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@
2828
from .script_info import *
2929
from .script_queue import *
3030
from .utils import *
31-
from . import ui
31+
from .run_one_script import *
32+
from .script_queue_commander import *

python/lsst/ts/scriptqueue/ui/run_one_script.py renamed to python/lsst/ts/scriptqueue/run_one_script.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import astropy
3232

3333
from lsst.ts import salobj
34-
from lsst.ts import scriptqueue
34+
from .script_queue import SCRIPT_INDEX_MULT, ScriptInfo
3535

3636
STD_TIMEOUT = 5 # timeout for fast commands
3737

@@ -126,7 +126,7 @@ def parse_run_one_script_cmd(args=None):
126126

127127
cmd = parser.parse_args(args=args)
128128
if cmd.index is None:
129-
cmd.index = random.randint(1, scriptqueue.script_queue.SCRIPT_INDEX_MULT - 1)
129+
cmd.index = random.randint(1, SCRIPT_INDEX_MULT - 1)
130130
elif not 0 < cmd.index <= salobj.MAX_SAL_INDEX:
131131
parser.error(
132132
f"index={cmd.index} must be in the range [1, {salobj.MAX_SAL_INDEX}], inclusive"
@@ -174,7 +174,7 @@ def log_callback(data):
174174
remote.evt_logMessage.callback = log_callback
175175

176176
print("starting the script process")
177-
script_info = scriptqueue.ScriptInfo(
177+
script_info = ScriptInfo(
178178
log=remote.salinfo.log,
179179
remote=remote,
180180
index=index,

python/lsst/ts/scriptqueue/ui/script_queue_commander.py renamed to python/lsst/ts/scriptqueue/script_queue_commander.py

File renamed without changes.

‎python/lsst/ts/scriptqueue/ui/__init__.py‎

Lines changed: 0 additions & 23 deletions
This file was deleted.

‎tests/test_run_one_script.py‎

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
from lsst.ts.idl.enums.Script import ScriptState
3232
from lsst.ts import salobj
33-
from lsst.ts.scriptqueue import ui
33+
from lsst.ts import scriptqueue
3434

3535
# Long enough to perform any reasonable operation
3636
# including starting a CSC or loading a script (seconds)
@@ -42,7 +42,7 @@
4242
class ParseRunOneScriptTestCase(unittest.IsolatedAsyncioTestCase):
4343
def test_basics(self):
4444
script = DATA_DIR / "standard" / "subdir" / "script3"
45-
cmd = ui.parse_run_one_script_cmd(args=[str(script)])
45+
cmd = scriptqueue.parse_run_one_script_cmd(args=[str(script)])
4646
assert script.samefile(cmd.script)
4747
assert cmd.config == ""
4848

@@ -51,7 +51,7 @@ def test_config_arg(self):
5151
config_path = DATA_DIR / "config1.yaml"
5252
with open(config_path, "r") as f:
5353
expected_config = f.read()
54-
cmd = ui.parse_run_one_script_cmd(
54+
cmd = scriptqueue.parse_run_one_script_cmd(
5555
args=[str(script), "--config", config_path.as_posix()]
5656
)
5757
assert script.samefile(cmd.script)
@@ -61,7 +61,7 @@ def test_parameters_arg(self):
6161
script = DATA_DIR / "external" / "script1"
6262
config_dict = dict(abool=True, anint=47, afloat=0.2, astr="string_value")
6363
config_arg_list = [f"{key}={value}" for key, value in config_dict.items()]
64-
cmd = ui.parse_run_one_script_cmd(
64+
cmd = scriptqueue.parse_run_one_script_cmd(
6565
args=[str(script), "--parameters"] + config_arg_list
6666
)
6767
assert script.samefile(cmd.script)
@@ -70,17 +70,19 @@ def test_parameters_arg(self):
7070

7171
def test_loglevel(self):
7272
script = DATA_DIR / "external" / "script1"
73-
cmd = ui.parse_run_one_script_cmd(args=[str(script)])
73+
cmd = scriptqueue.parse_run_one_script_cmd(args=[str(script)])
7474
assert cmd.loglevel is None
7575

7676
loglevel = 15
77-
cmd = ui.parse_run_one_script_cmd(
77+
cmd = scriptqueue.parse_run_one_script_cmd(
7878
args=[str(script), "--loglevel", str(loglevel)]
7979
)
8080
assert cmd.loglevel == loglevel
8181

8282
loglevel = 21
83-
cmd = ui.parse_run_one_script_cmd(args=[str(script), "-l", str(loglevel)])
83+
cmd = scriptqueue.parse_run_one_script_cmd(
84+
args=[str(script), "-l", str(loglevel)]
85+
)
8486
assert cmd.loglevel == loglevel
8587

8688
def test_invalid_arguments(self):
@@ -89,49 +91,51 @@ def test_invalid_arguments(self):
8991

9092
with pytest.raises(SystemExit):
9193
# need type and path
92-
ui.parse_run_one_script_cmd(args=[])
94+
scriptqueue.parse_run_one_script_cmd(args=[])
9395
with pytest.raises(SystemExit):
9496
# there is only one allowed positional arguments
95-
ui.parse_run_one_script_cmd(args=[str(script), "extra_argument"])
97+
scriptqueue.parse_run_one_script_cmd(args=[str(script), "extra_argument"])
9698
with pytest.raises(SystemExit):
9799
# invalid option
98-
ui.parse_run_one_script_cmd(args=[str(script), "--invalid"])
100+
scriptqueue.parse_run_one_script_cmd(args=[str(script), "--invalid"])
99101
with pytest.raises(SystemExit):
100102
# nonexistent config file
101-
ui.parse_run_one_script_cmd(
103+
scriptqueue.parse_run_one_script_cmd(
102104
args=[str(script), "--config", "nonexistent_config_file.yaml"]
103105
)
104106
with pytest.raises(SystemExit):
105107
# --index must have a value if specified
106-
ui.parse_run_one_script_cmd(args=[str(script), "--index"])
108+
scriptqueue.parse_run_one_script_cmd(args=[str(script), "--index"])
107109
with pytest.raises(SystemExit):
108110
# --index must be > 0
109-
ui.parse_run_one_script_cmd(args=[str(script), "--index", "0"])
111+
scriptqueue.parse_run_one_script_cmd(args=[str(script), "--index", "0"])
110112
with pytest.raises(SystemExit):
111113
# --index must be <= salobj.MAX_SAL_INDEX
112114
too_large_index = salobj.MAX_SAL_INDEX + 1
113-
ui.parse_run_one_script_cmd(
115+
scriptqueue.parse_run_one_script_cmd(
114116
args=[str(script), "--index", str(too_large_index)]
115117
)
116118
with pytest.raises(SystemExit):
117119
# --index must be an integer
118-
ui.parse_run_one_script_cmd(args=[str(script), "--index", "not_an_integer"])
120+
scriptqueue.parse_run_one_script_cmd(
121+
args=[str(script), "--index", "not_an_integer"]
122+
)
119123
with pytest.raises(SystemExit):
120124
# --parameters requires data
121-
ui.parse_run_one_script_cmd(args=[str(script), "--parameters"])
125+
scriptqueue.parse_run_one_script_cmd(args=[str(script), "--parameters"])
122126
with pytest.raises(SystemExit):
123127
# invalid data for --parameters; no =
124-
ui.parse_run_one_script_cmd(
128+
scriptqueue.parse_run_one_script_cmd(
125129
args=[str(script), "--parameters", "invalid_parameter"]
126130
)
127131
with pytest.raises(SystemExit):
128132
# invalid data for --parameters; space
129-
ui.parse_run_one_script_cmd(
133+
scriptqueue.parse_run_one_script_cmd(
130134
args=[str(script), "--parameters", "wait_time", "=", "0.1"]
131135
)
132136
with pytest.raises(SystemExit):
133137
# cannot specify both --config and --parameters
134-
ui.parse_run_one_script_cmd(
138+
scriptqueue.parse_run_one_script_cmd(
135139
args=[
136140
str(script),
137141
"--config",
@@ -151,7 +155,9 @@ async def test_run_one_script(self):
151155
config_path = DATA_DIR / "config1.yaml"
152156
with open(config_path, "r") as f:
153157
config = f.read()
154-
await ui.run_one_script(index=1, script=script, config=config, loglevel=10)
158+
await scriptqueue.run_one_script(
159+
index=1, script=script, config=config, loglevel=10
160+
)
155161

156162
async def test_run_command_line(self):
157163
exe_name = "run_one_script"

0 commit comments

Comments
 (0)