5.5. Additional Functions#

basf2.find_file((str)filename[, (str)data_type=''[, (bool)silent=False]]) str :#

Try to find a file and return its full path

If data_type is empty this function will try to find the file

  1. in $BELLE2_LOCAL_DIR,

  2. in $BELLE2_RELEASE_DIR

  3. relative to the current working directory.

Other known data_type values are

examples

Example data for examples and tutorials. Will try to find the file

  1. in $BELLE2_EXAMPLES_DATA_DIR

  2. relative to the current working directory

validation

Data for Validation purposes. Will try to find the file in

  1. in $BELLE2_VALIDATION_DATA_DIR

  2. relative to the current working directory

Added in version release-03-00-00.

Parameters:
  • filename (str) – relative filename to look for, either in a central place or in the current working directory

  • data_type (str) – case insensitive data type to find. Either empty string or one of "examples" or "validation"

  • silent (bool) – If True don’t print any errors and just return an empty string if the file cannot be found

basf2.get_file_metadata((str)arg1) object :#

Return the FileMetaData object for the given output file.

basf2.get_random_seed() str :#

Return the current random seed

basf2.log_to_console(color=False)[source]#

Adds the standard output stream to the list of logging destinations. The shell logging destination is added to the list by the framework by default.

basf2.log_to_file(filename, append=False)[source]#

Adds a text file to the list of logging destinations.

Parameters:
  • filename – The path and filename of the text file

  • append – Should the logging system append the messages to the end of the file (True) or create a new file for each event processing session (False). Default is False.

basf2.reset_log()[source]#

Resets the logging by removing all logging destinations

basf2.set_nprocesses((int)arg1) None :#

Sets number of worker processes for parallel processing.

Can be overridden using the -p argument to basf2.

Note

Setting this to 1 will have one parallel worker job which is almost always slower than just running without parallel processing but is still provided to allow debugging of parallel execution.

Parameters:

nproc (int) – number of worker processes. 0 to disable parallel processing.

basf2.set_random_seed((object)seed) None :#

Set the random seed. The argument can be any object and will be converted to a string using the builtin str() function and will be used to initialize the random generator.

basf2.set_streamobjs((list)arg1) None :#

Set the names of all DataStore objects which should be sent between the parallel processes. This can be used to improve parallel processing performance by removing objects not required.