text
stringlengths
81
112k
Substitute a string with the indented :attr:`params` Parameters ---------- s: str The string in which to substitute indent: int The number of spaces that the substitution should be indented stacklevel: int The stacklevel for the warning raised...
Method to delete a parameter from a parameter documentation. This method deletes the given `param` from the `base_key` item in the :attr:`params` dictionary and creates a new item with the original documentation without the description of the param. This method works for the ``'Paramete...
Delete the given parameters from a string Same as :meth:`delete_params` but does not use the :attr:`params` dictionary Parameters ---------- s: str The string of the parameters section params: list of str The names of the parameters to delete ...
Deletes the ``*args`` or ``**kwargs`` part from the parameters section Either `args` or `kwargs` must not be None. The resulting key will be stored in ``base_key + 'no_args'`` if `args` is not None and `kwargs` is None ``base_key + 'no_kwargs'`` if `args` is Non...
Deletes the ``*args`` or ``**kwargs`` part from the parameters section Either `args` or `kwargs` must not be None. Parameters ---------- s: str The string to delete the args and kwargs from args: None or str The string for the args to delete kwar...
Method to delete a parameter from a parameter documentation. This method deletes the given `param` from the `base_key` item in the :attr:`params` dictionary and creates a new item with the original documentation without the description of the param. This method works for ``'Results'`` l...
Delete the given types from a string Same as :meth:`delete_types` but does not use the :attr:`params` dictionary Parameters ---------- s: str The string of the returns like section types: list of str The type identifiers to delete Return...
Method to keep only specific parameters from a parameter documentation. This method extracts the given `param` from the `base_key` item in the :attr:`params` dictionary and creates a new item with the original documentation with only the description of the param. This method works for `...
Keep the given parameters from a string Same as :meth:`keep_params` but does not use the :attr:`params` dictionary Parameters ---------- s: str The string of the parameters like section params: list of str The parameter names to keep Ret...
Method to keep only specific parameters from a parameter documentation. This method extracts the given `type` from the `base_key` item in the :attr:`params` dictionary and creates a new item with the original documentation with only the description of the type. This method works for the...
Keep the given types from a string Same as :meth:`keep_types` but does not use the :attr:`params` dictionary Parameters ---------- s: str The string of the returns like section types: list of str The type identifiers to keep Returns ...
Descriptor method to save a docstring from a function Like the :meth:`get_sectionsf` method this method serves as a descriptor for functions but saves the entire docstring def save_docstring(self, key): """ Descriptor method to save a docstring from a function Like the :meth:`...
Get the summary of the given docstring This method extracts the summary from the given docstring `s` which is basicly the part until two newlines appear Parameters ---------- s: str The docstring to use base: str or None A key under which the sum...
Extract the summary from a function docstring Parameters ---------- ``*args`` and ``**kwargs`` See the :meth:`get_summary` method. Note, that the first argument will be the docstring of the specified function Returns ------- function ...
Get the extended summary from a docstring This here is the extended summary Parameters ---------- s: str The docstring to use base: str or None A key under which the summary shall be stored in the :attr:`params` attribute. If not None, the su...
Extract the extended summary from a function docstring This function can be used as a decorator to extract the extended summary of a function docstring (similar to :meth:`get_sectionsf`). Parameters ---------- ``*args`` and ``**kwargs`` See the :meth:`get_extended_s...
Get the full description from a docstring This here and the line above is the full description (i.e. the combination of the :meth:`get_summary` and the :meth:`get_extended_summary`) output Parameters ---------- s: str The docstring to use base: str o...
Extract the full description from a function docstring This function can be used as a decorator to extract the full descriptions of a function docstring (similar to :meth:`get_sectionsf`). Parameters ---------- ``*args`` and ``**kwargs`` See the :meth:`get_f...
Makes an object mergable if possible. Returns the virgin object if cannot convert it to a mergable instance. :returns: :class:`.Mergable` or type(data) def make_mergable_if_possible(cls, data, context): """ Makes an object mergable if possible. Returns the virgin object if cann...
Merges this instance with new instances, in-place. :param \\*args: Configuration values to merge with current instance. :type \\*args: iterable def merge(self, *args): """ Merges this instance with new instances, in-place. :param \\*args: Configuration values to merge with cur...
load file which contains yaml configuration entries.and merge it by current instance :param files: files to load and merge into existing configuration instance :type files: list def load_file(self, filename): """ load file which contains yaml configuration...
Initialize the configuration manager :param force: force initialization even if it's already initialized :return: def initialize(self, init_value, context=None, force=False): """ Initialize the configuration manager :param force: force initialization even if it's already initi...
Extracts the name, which may be embedded, for a Jinja2 filter node def grok_filter_name(element): """Extracts the name, which may be embedded, for a Jinja2 filter node""" e_name = None if element.name == 'default': if isinstance(element.node, jinja2.nodes.Getattr): e_name = elem...
Properly parses a For loop element def grok_for_node(element, default_vars): """Properly parses a For loop element""" if isinstance(element.iter, jinja2.nodes.Filter): if element.iter.name == 'default' \ and element.iter.node.name not in default_vars: default_vars.append(element....
Properly parses a If element def grok_if_node(element, default_vars): """Properly parses a If element""" if isinstance(element.test, jinja2.nodes.Filter) and \ element.test.name == 'default': default_vars.append(element.test.node.name) return default_vars + grok_vars(element)
Returns a list of vars for which the value is being appropriately set This currently includes the default filter, for-based iterators, and the explicit use of set def grok_vars(elements): """Returns a list of vars for which the value is being appropriately set This currently includes the default filter...
Sets up our Jinja environment, loading the few filters we have def jinja_env(template_path): """Sets up our Jinja environment, loading the few filters we have""" fs_loader = FileSystemLoader(os.path.dirname(template_path)) env = Environment(loader=fs_loader, autoescape=True, ...
If we find missing variables when rendering a template we want to give the user a friendly error def missing_vars(template_vars, parsed_content, obj): """If we find missing variables when rendering a template we want to give the user a friendly error""" missing = [] default_vars = grok_vars(parsed_...
Render a template, maybe mixing in extra variables def render(filename, obj): """Render a template, maybe mixing in extra variables""" template_path = abspath(filename) env = jinja_env(template_path) template_base = os.path.basename(template_path) try: parsed_content = env.parse(env ...
Loads variable from cli and var files, passing in cli options as a seed (although they can be overwritten!). Note, turn this into an object so it's a nicer "cache". def load_vars(opt): """Loads variable from cli and var files, passing in cli options as a seed (although they can be overwritten!). No...
Load variable files, merge, return contents def load_var_files(opt, p_obj=None): """Load variable files, merge, return contents""" obj = {} if p_obj: obj = p_obj for var_file in opt.extra_vars_file: LOG.debug("loading vars from %s", var_file) obj = merge_dicts(obj.copy(), load_...
Loads a varible file, processing it as a template def load_var_file(filename, obj): """Loads a varible file, processing it as a template""" rendered = render(filename, obj) ext = os.path.splitext(filename)[1][1:] v_obj = dict() if ext == 'json': v_obj = json.loads(rendered) elif ext == ...
Loads the help for a given template def load_template_help(builtin): """Loads the help for a given template""" help_file = "templates/%s-help.yml" % builtin help_file = resource_filename(__name__, help_file) help_obj = {} if os.path.exists(help_file): help_data = yaml.safe_load(open(help_f...
Show a listing of all our builtin templates def builtin_list(): """Show a listing of all our builtin templates""" for template in resource_listdir(__name__, "templates"): builtin, ext = os.path.splitext(os.path.basename(abspath(template))) if ext == '.yml': continue help_ob...
Show information on a particular builtin template def builtin_info(builtin): """Show information on a particular builtin template""" help_obj = load_template_help(builtin) if help_obj.get('name') and help_obj.get('help'): print("The %s template" % (help_obj['name'])) print(help_obj['help'])...
Renders and returns the Secretfile construct def render_secretfile(opt): """Renders and returns the Secretfile construct""" LOG.debug("Using Secretfile %s", opt.secretfile) secretfile_path = abspath(opt.secretfile) obj = load_vars(opt) return render(secretfile_path, obj)
Will update the password for a userpass user def update_user_password(client, userpass): """Will update the password for a userpass user""" vault_path = '' user = '' user_path_bits = userpass.split('/') if len(user_path_bits) == 1: user = user_path_bits[0] vault_path = "auth/userpas...
Will update a single key in a generic secret backend as thought it were a password def update_generic_password(client, path): """Will update a single key in a generic secret backend as thought it were a password""" vault_path, key = path_pieces(path) mount = mount_for_path(vault_path, client) i...
Will attempt to contextually update a password in Vault def password(client, path): """Will attempt to contextually update a password in Vault""" if path.startswith('user:'): update_user_password(client, path[5:]) else: update_generic_password(client, path)
The path to a misc Vault file This function will check for the env override on a file path, compute a fully qualified OS appropriate path to the desired file and return it if it exists. Otherwise returns None def vault_file(env, default): """The path to a misc Vault file This function will chec...
Will convert a time string, as recognized by other Vault tooling, into an integer representation of seconds def vault_time_to_s(time_string): """Will convert a time string, as recognized by other Vault tooling, into an integer representation of seconds""" if not time_string or len(time_string) < 2: ...
Execute a command. Command can be passed as several arguments, each being a string or a list of strings; lists are flattened. If opts.verbose is True, output of the command is shown. If the command exits with non-zero, print an error message and exit. If keyward argument get_output is True, output ...
Toggle whether or not the current thread is executing a step file. This will only apply when the current thread is a CauldronThread. This function has no effect when run on a Main thread. :param on: Whether or not the thread should be annotated as executing a step file. def set_executing(on: bool)...
Loads the contents of the source into a string for execution using multiple loading methods to handle cross-platform encoding edge cases. If none of the load methods work, a string is returned that contains an error function response that will be displayed when the step is run alert the user to the erro...
Loads the source for a step file at the given path location and then renders it in a template to add additional footer data. The footer is used to force the display to flush the print buffer and breathe the step to open things up for resolution. This shouldn't be necessary, but it seems there's an asyn...
Creates an artificial module that will encompass the code execution for the specified step. The target module is populated with the standard dunder attributes like __file__ to simulate the normal way that Python populates values when loading a module. :param project: The currently open project....
Carries out the execution of the step python source file by loading it into an artificially created module and then executing that module and returning the result. :param project: The currently open project. :param step: The project step for which the run execution will take place. ...
Renders a SyntaxError, which has a shallow, custom stack trace derived from the data included in the error, instead of the standard stack trace pulled from the exception frames. :param project: Currently open project. :param error: The SyntaxError to be rendered to html and text for dis...
Renders an Exception to an error response that includes rendered text and html error messages for display. :param project: Currently open project. :param error: The SyntaxError to be rendered to html and text for display. :param stack: Optionally specify a parsed stack. If this ...
:param asynchronous: Whether or not to allow asynchronous command execution that returns before the command is complete with a run_uid that can be used to track the continued execution of the command until completion. def execute(asynchronous: bool = False): """ :param asynchronous: ...
... def abort(): """...""" uid_list = list(server_runner.active_execution_responses.keys()) while len(uid_list) > 0: uid = uid_list.pop() response = server_runner.active_execution_responses.get(uid) if not response: continue try: del server_runner....
Removes the specified key from the cauldron configs if the key exists :param key: The key in the cauldron configs object to remove :param persists: def remove_key(key: str, persists: bool = True): """ Removes the specified key from the cauldron configs if the key exists :param key: ...
Removes the specified key from the cauldron configs if the key exists :param key: The key in the cauldron configs object to remove :param value: :param persists: def set_key(key: str, value: typing.List[str], persists: bool = True): """ Removes the specified key from the cauldron configs i...
Saves the configuration settings object to the current user's home directory :return: def save(self) -> 'Configuration': """ Saves the configuration settings object to the current user's home directory :return: """ data = self.load().persistent ...
Get a dictionary that pulls together information about the poster safely for both authenticated and non-authenticated comments. This dict will have ``name``, ``email``, and ``url`` fields. def _get_userinfo(self): """ Get a dictionary that pulls together information about the poster ...
Return this comment as plain text. Useful for emails. def get_as_text(self): """ Return this comment as plain text. Useful for emails. """ d = { 'user': self.user or self.name, 'date': self.submit_date, 'comment': self.comment, 'domain':...
Converts the given data dictionary into either a file write or file copy entry depending on the keys in the dictionary. The dictionary should contain either ('path', 'contents') keys for file write entries or ('source', 'destination') keys for file copy entries. def entry_from_dict( data: dict ) ->...
Iterates through the specified files_list and copies or writes each entry depending on whether its a file copy entry or a file write entry. :param files_list: A list of file write entries and file copy entries def deploy(files_list: typing.List[tuple]): """ Iterates through the specified files...
Creates the parent directory or directories for the specified output path if they do not already exist to prevent incomplete directory path errors during copying/writing operations. :param output_path: The path of the destination file or directory that will be written. :return: The abso...
Copies the specified file from its source location to its destination location. def copy(copy_entry: FILE_COPY_ENTRY): """ Copies the specified file from its source location to its destination location. """ source_path = environ.paths.clean(copy_entry.source) output_path = environ.paths.cle...
Writes the contents of the specified file entry to its destination path. def write(write_entry: FILE_WRITE_ENTRY): """ Writes the contents of the specified file entry to its destination path. """ output_path = environ.paths.clean(write_entry.path) make_output_directory(output_path) writer.write...
Create a print equivalent function that also writes the output to the project page. The write_through is enabled so that the TextIOWrapper immediately writes all of its input data directly to the underlying BytesIO buffer. This is needed so that we can safely access the buffer data in a multi-threaded e...
Restores the sys.stdout and the sys.stderr buffer streams to their default values without regard to what step has currently overridden their values. This is useful during cleanup outside of the running execution block def restore_default_configuration(): """ Restores the sys.stdout and the sys.stderr b...
Creates a FILE_WRITE_ENTRY for the rendered HTML file for the given project that will be saved in the destination directory with the given filename. :param project: The project for which the rendered HTML file will be created :param destination_directory: The absolute path to the folder...
Runs an interactive container def run_container(): """Runs an interactive container""" os.chdir(my_directory) cmd = [ 'docker', 'run', '-it', '--rm', '-v', '{}:/cauldron'.format(my_directory), '-p', '5010:5010', 'cauldron_app', '/bin/bash' ] return...
Execute the Cauldron container command def run(): """Execute the Cauldron container command""" command = sys.argv[1].strip().lower() print('[COMMAND]:', command) if command == 'test': return run_test() elif command == 'build': return run_build() elif command == 'up': r...
This function is used to handle authorization code authentication of protected endpoints. This form of authentication is not recommended because it's not very secure, but can be used in places where SSH tunneling or similar strong connection security is not possible. The function looks for a spe...
Inspects the data and structure of the source dictionary object and adds the results to the display for viewing. :param source: A dictionary object to be inspected. :return: def inspect(source: dict): """ Inspects the data and structure of the source dictionary object and adds the resu...
Adds a text header to the display with the specified level. :param header_text: The text to display in the header. :param level: The level of the header, which corresponds to the html header levels, such as <h1>, <h2>, ... :param expand_full: Whether or not the header will e...
Adds text to the display. If the text is not preformatted, it will be displayed in paragraph format. Preformatted text will be displayed inside a pre tag with a monospace font. :param value: The text to display. :param preformatted: Whether or not to preserve the whitespace display of t...
Renders the specified source string or source file using markdown and adds the resulting HTML to the notebook display. :param source: A markdown formatted string. :param source_path: A file containing markdown text. :param preserve_lines: If True, all line breaks will be treate...
Adds the specified data to the the output display window with the specified key. This allows the user to make available arbitrary JSON-compatible data to the display for runtime use. :param kwargs: Each keyword argument is added to the CD.data object with the specified key and value. def j...
Creates a Plotly plot in the display with the specified data and layout. :param data: The Plotly trace data to be plotted. :param layout: The layout data used for the plot. :param scale: The display scale with units of fractional screen height. A value of 0.5 constrains ...
Adds the specified data frame to the display in a nicely formatted scrolling table. :param data_frame: The pandas data frame to be rendered to a table. :param scale: The display scale with units of fractional screen height. A value of 0.5 constrains the output to a maximum height eq...
Adds the specified SVG string to the display. If a filename is included, the SVG data will also be saved to that filename within the project results folder. :param svg_dom: The SVG string data to add to the display. :param filename: An optional filename where the SVG data should be save...
Renders the specified Jinja2 template to HTML and adds the output to the display. :param path: The fully-qualified path to the template to be rendered. :param kwargs: Any keyword arguments that will be use as variable replacements within the template. def jinja(path: str, **kwargs)...
Adds the specified number of lines of whitespace. :param lines: The number of lines of whitespace to show. def whitespace(lines: float = 1.0): """ Adds the specified number of lines of whitespace. :param lines: The number of lines of whitespace to show. """ r = _get_report() ...
Adds an image to the display. The image must be located within the assets directory of the Cauldron notebook's folder. :param filename: Name of the file within the assets directory, :param width: Optional width in pixels for the image. :param height: Optional height in pixels fo...
A string containing a valid HTML snippet. :param dom: The HTML string to add to the display. def html(dom: str): """ A string containing a valid HTML snippet. :param dom: The HTML string to add to the display. """ r = _get_report() r.append_body(render.html(dom)) r.std...
Adds a list of the shared variables currently stored in the project workspace. :param show_values: When true the values for each variable will be shown in addition to their name. :param show_types: When true the data types for each shared variable will be shown in addition t...
Creates a matplotlib plot in the display for the specified figure. The size of the plot is determined automatically to best fit the notebook. :param figure: The matplotlib figure to plot. If omitted, the currently active figure will be used. :param scale: The display scale with unit...
Adds a Bokeh plot object to the notebook display. :param model: The plot object to be added to the notebook display. :param scale: How tall the plot should be in the notebook as a fraction of screen height. A number between 0.1 and 1.0. The default value is 0.7. :param responsive: ...
An unordered or ordered list of the specified *source* iterable where each element is converted to a string representation for display. :param source: The iterable to display as a list. :param ordered: Whether or not the list should be ordered. If False, which is the default, an uno...
An multi-column list of the specified *source* iterable where each element is converted to a string representation for display. :param source: The iterable to display as a list. :param expand_full: Whether or not the list should expand to fill the screen horizontally. When defaulted...
Add a mathematical equation in latex math-mode syntax to the display. Instead of the traditional backslash escape character, the @ character is used instead to prevent backslash conflicts with Python strings. For example, \\delta would be @delta. :param source: The string representing the latex...
Displays a specified number of elements in a source object of many different possible types. :param source: DataFrames will show *count* rows of that DataFrame. A list, tuple or other iterable, will show the first *count* rows. Dictionaries will show *count* keys from the dictionary, wh...
Updates the status display, which is only visible while a step is running. This is useful for providing feedback and information during long-running steps. A section progress is also available for cases where long running tasks consist of multiple tasks and you want to display sub-progress messages ...
Adds a block of syntax highlighted code to the display from either the supplied code argument, or from the code file specified by the path argument. :param code: A string containing the code to be added to the display :param path: A path to a file containing code to be added to the disp...
Displays the elapsed time since the step started running. def elapsed(): """ Displays the elapsed time since the step started running. """ environ.abort_thread() step = _cd.project.get_internal_project().current_step r = _get_report() r.append_body(render.elapsed_time(step.elapsed_time)) ...
Retrieves the loaded module for the given module name or returns None if no such module has been loaded. :param name: The name of the module to be retrieved :return: Either the loaded module with the specified name, or None if no such module has been imported. def get_module(name: ...
Returns the name of the specified module by looking up its name in multiple ways to prevent incompatibility issues. :param module: A module object for which to retrieve the name. def get_module_name(module: types.ModuleType) -> str: """ Returns the name of the specified module by looking up it...
Executes the reload of the specified module if the source file that it was loaded from was updated more recently than the specified time :param module: A module object to be reloaded :param newer_than: The time in seconds since epoch that should be used to determine if the module ne...
Reloads all imported children of the specified parent module object :param parent_module: A module object whose children should be refreshed if their currently loaded versions are out of date. :param newer_than: An integer time in seconds for comparison. Any children modules that ...
Reloads the specified module, which can either be a module object or a string name of a module. Will not reload a module that has not been imported :param module: A module object or string module name that should be refreshed if its currently loaded version is out of date or the action is f...
Checks the specified module or modules for changes and reloads them if they have been changed since the module was first imported or last refreshed. :param modules: One or more module objects that should be refreshed if they the currently loaded versions are out of date. The package name fo...
Returns the index of the "*args" parameter if such a parameter exists in the function arguments or -1 otherwise. :param target: The target function for which the args index should be determined :return: The arguments index if it exists or -1 if not def get_args_index(target) -> int: ""...
Returns the index of the "**kwargs" parameter if such a parameter exists in the function arguments or -1 otherwise. :param target: The target function for which the kwargs index should be determined :return: The keyword arguments index if it exists or -1 if not def get_kwargs_index(target)...
Gets the list of named arguments for the target function :param target: Function for which the argument names will be retrieved def get_arg_names(target) -> typing.List[str]: """ Gets the list of named arguments for the target function :param target: Function for which the argument na...
Creates a dictionary representation of the parameter :param target: The function object in which the parameter resides :param name: The name of the parameter :param description: The documentation description for the parameter def create_argument(target, name, description: str = '')...
Returns a tuple containing the parameter name and the description parsed from the given argument line def explode_line(argument_line: str) -> typing.Tuple[str, str]: """ Returns a tuple containing the parameter name and the description parsed from the given argument line """ parts = tuple(argu...