Skip to content

CachedVariables

Methods

workflows.CachedVariables.__init__(self, **kwargs) special

Handle file and ram representation of user selected current working variables that needs to be saved to later execution sessions, to improve work efficiency and user experience, mainly intended to use with GUI work variables.

Parameters:

Name Type Description Default
**kwargs optionnal
  • description (str):

  • cache_dir_path (str): path to the .ini file if you wish to save it in a custom location. By default, it will be saved in the LabUtils package, inside the varcache folder.

  • distinguisher (str): Warning : Advanced user

    If you wish to have the ability to have several variables caches configurations for a class implementing a CachedVariables object, and if that class is called from several functions, you will need to disambiguate the .ini file with such distinguisher.

    Question: TODO Add the ability to simply roll back the caller to the top, so the user doesn't have to specify itself subjective distinguisher strings in the code depending on if it has been called from here or there.

{}

Returns:

Type Description
CachedVariables

An instance of the class

Info

how to use inspect:

import inspect

inspect.stack first index content :
inspect.stack()[0] #callee
inspect.stack()[1] #caller
inspect.stack()[2] #caller's caller etc

#inspect.stack second index content, for the caller in that case
frame,filename,line_number,function_name,lines,index = inspect.stack()[1][1]

workflows.CachedVariables.retrieve(self, date)

Question

TODO Retrieve function to load previous values by putting the section named by date if existing, into current section.

Returns:

Type Description

None.

workflows.CachedVariables.save(self)

Question

TODO Save function to save current values by putting them into a section named by date. Could be usefull to make sets of parameters that have been saved and can be easily switched to X or Y config, for user interfaces in particular.

Returns:

Type Description

None.

Back to top