def create_experiment(self, experiment_name, experiment_id=None, suite_id=None): # Also create the experiment in COMPS to get the ID COMPS_login(SetupParser.get('server_endpoint')) experiment_name = self.clean_experiment_name(experiment_name) subdirectory = experiment_name[ 0:self.MAX_SUBDIRECTORY_LENGTH] + '_' + timestamp() config = Configuration( environment_name=SetupParser.get('environment'), simulation_input_args=self.commandline.Options, working_directory_root=os.path.join(SetupParser.get('sim_root'), subdirectory), executable_path=self.commandline.Executable, node_group_name=SetupParser.get('node_group'), maximum_number_of_retries=int(SetupParser.get('num_retries')), priority=Priority[SetupParser.get('priority')], min_cores=self.config_builder.get_param('Num_Cores', 1) if self.config_builder else 1, max_cores=self.config_builder.get_param('Num_Cores', 1) if self.config_builder else 1, exclusive=self.config_builder.get_param('Exclusive', False) if self.config_builder else False) e = Experiment(name=experiment_name, configuration=config, suite_id=suite_id) # Add tags if present if self.experiment_tags: e.set_tags(self.experiment_tags) e.save() # Store in our object self.comps_experiment = e # Also add it to the cache COMPSCache.add_experiment_to_cache(e) # Create experiment in the base class super(CompsExperimentManager, self).create_experiment(experiment_name, str(e.id), suite_id) # Set some extra stuff self.experiment.endpoint = self.endpoint
new_simulation.save(return_missing_files=False) if len(files_to_add_last) 0 for file_path, sf in files_to_add_last.items() new_simulation.add_file(sf, file_path=file_path) new_simulation.save(return_missing_files=False) print('new sim = ' + str(new_simulation.id)) return new_simulation def copy_experiment(experiment, to_suite) new_experiment = Experiment(name=experiment.name, suite_id=to_suite.id) new_experiment.set_tags({CopiedFromExperiment experiment.id}) new_experiment.save() return new_experiment if __name__ == __main__ from simtools.Utilities.COMPSUtilities import exps_for_suite_id, sims_from_experiment_id from simtools.Utilities.Experiments import retrieve_experiment from simtools.ExperimentManager.ExperimentManagerFactory import ExperimentManagerFactory from simtools.ExperimentManager.BaseExperimentManager import BaseExperimentManager SetupParser.init() # load the original stuff original_suite = Suite.get(id=original_suite_id) original_experiments = exps_for_suite_id(original_suite_id)
def copy_experiment(experiment, to_suite): new_experiment = Experiment(name=experiment.name, suite_id=to_suite.id) new_experiment.set_tags({"CopiedFromExperiment": experiment.id}) new_experiment.save() return new_experiment