def _initialize(hg_obj = None, argv=None, ): """ Initialize the simulation parameters, setting ``sim_var`` and reverting sources, if necessary. The simulation output directory is also set. :param hg_obj: :class:`neuronpy.util.hgutil` object to retrieve source control information from. :param argv: List of strings, which correlate to the optional commands that would be listed on the command line when launching the program. """ global replace_output, use_tip, use_hg sim_var.clear() # In case non-empty util.load_sim_var(sim_var) # Load from params.py # Process args, loading them into local_dict. local_dict = {} param_files, cmds = paraminit.parse_args(argv, globals(), local_dict) if 'sim_var' in local_dict: # Replace default values with those in the local_dict sim_var.update(local_dict['sim_var']) if use_hg: if use_tip == False and 'hg' in sim_var: # Note that while this will revert sources, any already code loaded # into program memory will leave the revert inconsequential. hg_obj.revert_to_changeset(str(sim_var['hg']['node'])) else: sim_var['hg'] = hg_obj.get_changeset_dict() if replace_output is False: util.set_sim_dir_id(prj_tmp, sim_var)
def _initialize(argv): """ Load the ``sim_var`` dict and process arguments. :param argv: List of strings, each of which are arguments that would be specified on the command line. """ local_dict = {} sim_var.clear() util.load_sim_var(sim_var) param_files, cmds = paraminit.parse_args(argv, globals(), local_dict) if "sim_var" in local_dict: # Replace default values with those in the local_dict sim_var.update(local_dict["sim_var"]) if "prj_tmp" in local_dict: prj_tmp.update(local_dict["prj_tmp"]) # Check that the ``prj_tmp`` and ``sim_var`` dicts are complete and fill in # anything missing that wasn't already accounted for. if not "prj_path" in prj_tmp: (project_path, path_to_src) = util.get_project_and_src_paths() prj_tmp["prj_path"] = project_path prj_tmp["src_path"] = path_to_src if not "sim_dir_id" in sim_var: util.set_sim_dir_id(prj_tmp, sim_var) prj_tmp["sim_out"] = os.path.join(prj_tmp["prj_path"], sim_var["sim_path"], sim_var["sim_dir_id"])