pytwd.workflow_2 package

Submodules

pytwd.workflow_2.components module

class Calculation(code, file, relative_path)

Bases: tuple

code

Alias for field number 0

file

Alias for field number 1

relative_path

Alias for field number 2

class Connection(from_calc, object, to_calc, found)

Bases: tuple

found

Alias for field number 3

from_calc

Alias for field number 0

object

Alias for field number 1

to_calc

Alias for field number 2

pytwd.workflow_2.database module

pytwd.workflow_2.drawing module

pytwd.workflow_2.execution module

get_user_confirmation(prompt)

Prompts the user for confirmation with a yes or no question.

Parameters:

prompt (str) -- The message displayed to prompt the user.

Return type:

bool

Returns:

True if the user confirms with 'yes' or 'y', False if the user responds with 'no' or 'n'.

run_notebooks(notebook_files, relative_paths=None, log_file_path=None, pause_points=())

Executes a sequence of Jupyter notebooks in a specified order, optionally pausing for user confirmation at designated points, and logs warnings as needed.

Parameters:
  • notebook_files (Sequence[Union[str, Path]]) -- Sequence of paths to notebook files to be executed in order.

  • relative_paths (Optional[Sequence[Union[str, Path]]]) -- Optional sequence of paths relative to the current working directory for each notebook file. If provided, must match the order and length of notebook_files. These are there to allow sub-folders in the workflow

  • log_file_path (Union[str, Path, None]) -- Optional path to store logs. If not specified, logs will be stored in a default directory based on the calculation code.

  • pause_points (Sequence[str]) -- Sequence of calculation codes where execution should pause, prompting the user to confirm whether to continue.

Execution Workflow:

  • Creates directories to store executed notebooks and generated PDFs.

  • Deletes any existing notebooks in the execution directory to ensure fresh runs.

  • Processes each notebook, inserting a logger setup cell at the start to capture warnings, and executes it within the specified directory.

  • Copies the final executed notebook and its generated PDF output to designated directories.

  • If a notebook’s calculation code matches a code in pause_points, pauses execution until user confirmation.

pytwd.workflow_2.get_connections module

get_connections(wf_calc_to_nb, folder='.database')
get_warning_logs(wf_calc_to_nb, folder='.database')

Retrieves warning logs for a list of calculations from JSON files in the specified folder.

Parameters:
  • wf_calc_to_nb (List[Calculation]) -- List of Calculation objects, each containing a code and file attribute representing the calculation code and the file associated with it.

  • folder (str) -- Path to the folder where warning log JSON files are stored.

Return type:

Dict

Returns:

Dictionary mapping each calculation code to its warning log entries, structured as

{calc_code: {'filename': str, 'logs': list}} for each entry found in folder/warning_logs.

pytwd.workflow_2.graph module

pytwd.workflow_2.quality_sheet module

pytwd.workflow_2.utils module

delete_pdfs_for_writing(list_calcs)

pytwd.workflow_2.workflow module

Module contents