Skip to content

Commit b312180

Browse files
authored
Merge pull request labscript-suite#53 from rpanderson/apparatus_name
Resolves labscript-suite#52
2 parents 22237f2 + 3fdaa2c commit b312180

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

labscript_profile/default_profile/labconfig/example.ini

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[DEFAULT]
2-
experiment_name = default_experiment
2+
apparatus_name = example_apparatus
33
shared_drive = C:
4-
experiment_shot_storage = %(shared_drive)s\Experiments\%(experiment_name)s
5-
userlib=%(labscript_suite)s\userlib
4+
experiment_shot_storage = %(shared_drive)s\Experiments\%(apparatus_name)s
5+
userlib= %(labscript_suite)s\userlib
66
pythonlib = %(userlib)s\pythonlib
7-
labscriptlib = %(userlib)s\labscriptlib\%(experiment_name)s
8-
analysislib = %(userlib)s\analysislib\%(experiment_name)s
9-
app_saved_configs = %(labscript_suite)s\app_saved_configs\%(experiment_name)s
7+
labscriptlib = %(userlib)s\labscriptlib\%(apparatus_name)s
8+
analysislib = %(userlib)s\analysislib\%(apparatus_name)s
9+
app_saved_configs = %(labscript_suite)s\app_saved_configs\%(apparatus_name)s
1010
user_devices = user_devices
1111

1212
[paths]

labscript_utils/labconfig.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from ast import literal_eval
1616
from pprint import pformat
1717
from pathlib import Path
18+
import warnings
1819

1920
from labscript_utils import dedent
2021
from labscript_profile import default_labconfig_path, LABSCRIPT_SUITE_PROFILE
@@ -62,13 +63,28 @@ def __init__(
6263
# contains one string):
6364
self.read(config_path)
6465

66+
# Rename experiment_name to apparatus_name and raise a DeprectionWarning
67+
experiment_name = self.get("DEFAULT", "experiment_name", fallback=None)
68+
if experiment_name:
69+
msg = """The experiment_name keyword has been renamed apparatus_name in
70+
labscript_utils 3.0, and will be removed in a future version. Please
71+
update your labconfig to use the apparatus_name keyword."""
72+
warnings.warn(dedent(msg), FutureWarning)
73+
if self.get("DEFAULT", "apparatus_name", fallback=None):
74+
msg = """You have defined both experiment_name and apparatus_name in
75+
your labconfig. Please omit the deprecate experiment_name
76+
keyword."""
77+
raise Exception(dedent(msg))
78+
else:
79+
self.set("DEFAULT", "apparatus_name", experiment_name)
80+
6581
try:
6682
for section, options in required_params.items():
6783
for option in options:
6884
self.get(section, option)
6985
except configparser.NoOptionError:
7086
msg = f"""The experiment configuration file located at {config_path} does
71-
not have the required keys. Make sure the config file containes the
87+
not have the required keys. Make sure the config file contains the
7288
following structure:\n{self.file_format}"""
7389
raise Exception(dedent(msg))
7490

@@ -93,7 +109,7 @@ def save_appconfig(filename, data):
93109
for section_name, section in data.items()
94110
}
95111
c = configparser.ConfigParser(interpolation=None)
96-
c.optionxform = str # preserve case
112+
c.optionxform = str # preserve case
97113
c.read_dict(data)
98114
Path(filename).parent.mkdir(parents=True, exist_ok=True)
99115
with open(filename, 'w') as f:
@@ -105,7 +121,7 @@ def load_appconfig(filename):
105121
converted to Python objects with ast.literal_eval(). All keys will be lowercase
106122
regardless of the written contents on the .ini file."""
107123
c = configparser.ConfigParser(interpolation=None)
108-
c.optionxform = str # preserve case
124+
c.optionxform = str # preserve case
109125
# No file? No config - don't crash.
110126
if Path(filename).exists():
111127
c.read(filename)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy