1515from ast import literal_eval
1616from pprint import pformat
1717from pathlib import Path
18+ import warnings
1819
1920from labscript_utils import dedent
2021from 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