recipy.log module

recipy.log.add_dict(field, dict_of_values)

Add a given dict of values to a given array field.

recipy.log.add_file_diff_to_db(filename, tempfilename, db)
recipy.log.add_module_to_db(modulename, input_functions, output_functions, db_path='/home/docs/.recipy/recipyDB.json')
recipy.log.append(field, value, no_duplicates=False)

Append a given value to a given array field. Keep an eye on https://github.com/msiemens/tinydb/issues/66

recipy.log.dedupe_inputs()

Remove inputs that are logged muliple times.

Sometimes patched libraries use other patched libraries to open files. E.g., xarray internally uses netCDF4 to open netcdf files. If this happens, and recipy is configured to log file hashes, inputs are logged multiple times. Hashed inputs are stored as a list in the database, and tinydb does not automatically dedupe lists.

Outputs do not need to be deduped, because file hashed are added after the run is finished, and tinydb can automatically dedupe strings.

recipy.log.hash_outputs()
recipy.log.log_exception(typ, value, traceback)
recipy.log.log_exit()
recipy.log.log_flush()
recipy.log.log_init(notebookName=None)

Do the initial logging for a new run.

Works out what script has been run, creates a new unique run ID, and gets the basic metadata.

This is called when running import recipy.

recipy.log.log_input(filename, source)

Log input to the database.

Called by patched functions that do some sort of input (reading from a file etc) with the filename and some sort of information about the source.

Note: the source parameter is currently not stored in the database.

recipy.log.log_output(filename, source)

Log output to the database.

Called by patched functions that do some sort of output (writing to a file etc) with the filename and some sort of information about the source.

Note: the source parameter is currently not stored in the database.

recipy.log.log_values(custom_values=None, **kwargs)

Log a custom value-key pairs into the database e.g, >>> log_values(a=1, b=2) >>> log_values({‘c’: 3, ‘d’: 4}) >>> log_values({‘e’: 5, ‘f’: 6}, g=7, h=8)

recipy.log.log_warning(msg, typ, script, lineno, file=None, line=None)
recipy.log.new_run()

Just an alias for the log_init function

recipy.log.output_file_diffs()