15
15
from ast import literal_eval
16
16
from pprint import pformat
17
17
from pathlib import Path
18
+ import warnings
18
19
19
20
from labscript_utils import dedent
20
21
from labscript_profile import default_labconfig_path , LABSCRIPT_SUITE_PROFILE
@@ -62,13 +63,28 @@ def __init__(
62
63
# contains one string):
63
64
self .read (config_path )
64
65
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
+
65
81
try :
66
82
for section , options in required_params .items ():
67
83
for option in options :
68
84
self .get (section , option )
69
85
except configparser .NoOptionError :
70
86
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
72
88
following structure:\n { self .file_format } """
73
89
raise Exception (dedent (msg ))
74
90
@@ -93,7 +109,7 @@ def save_appconfig(filename, data):
93
109
for section_name , section in data .items ()
94
110
}
95
111
c = configparser .ConfigParser (interpolation = None )
96
- c .optionxform = str # preserve case
112
+ c .optionxform = str # preserve case
97
113
c .read_dict (data )
98
114
Path (filename ).parent .mkdir (parents = True , exist_ok = True )
99
115
with open (filename , 'w' ) as f :
@@ -105,7 +121,7 @@ def load_appconfig(filename):
105
121
converted to Python objects with ast.literal_eval(). All keys will be lowercase
106
122
regardless of the written contents on the .ini file."""
107
123
c = configparser .ConfigParser (interpolation = None )
108
- c .optionxform = str # preserve case
124
+ c .optionxform = str # preserve case
109
125
# No file? No config - don't crash.
110
126
if Path (filename ).exists ():
111
127
c .read (filename )
0 commit comments