Module src.runtime.iruntime

Expand source code
from abc import ABC, abstractmethod
from typing import Union


class IRuntime(ABC):
    """
    Class representing the analysis process.
    It takes the code snippets and allows to run them.
    Except the code itself, it also keeps the comments describing the whole process.

    Each separate input (both code and description blocks) is stored with the index, so that it can be easily referenced.
    Those blocks will be called cells.
    It is based on Jupyter Notebook design.
    """

    @abstractmethod
    def set_report_title(self, title: str) -> None:
        """
        Sets the title of the report.
        """
        pass

    @abstractmethod
    def add_description(self, description: str) -> int:
        """
        Adds a cell with the description of the process.

        Returns:
            The index of the cell.
        """
        pass

    @abstractmethod
    def add_code(self, code: str) -> int:
        """
        Adds a cell with the code.

        Returns:
            The index of the cell.
        """
        pass

    @abstractmethod
    def remove_cell(self, cell_index: int = -1) -> None:
        """
        Removes the cell with the given index.
        """
        pass

    @abstractmethod
    def execute_cell(self, cell_index: int = -1) -> None:
        """
        Executes a cell with the given index, if it is a code cell. Otherwise, does nothing.
        Errors are also written to the output.
        """
        pass

    @abstractmethod
    def get_content(self, cell_index: int = -1) -> str:
        """
        Returns the content of the cell with the given index.
        """
        pass

    @abstractmethod
    def get_cell_output_stream(self, cell_index: int = -1) -> Union[str, None]:
        """
        Returns the output (only stdout and stderr, no media) of the cell with the given index, if it is a code cell. Otherwise, returns None.
        """
        pass

    @abstractmethod
    def check_if_plot_in_output(self, cell_index: int = -1) -> bool:
        """
        Returns true if the output of the cell with the given index contains a plot.
        """
        pass

    @abstractmethod
    def upload_file(self, local_path: str, dest_file_path: str) -> None:
        """
        Uploads the data files for further use by runtime.

        Parameters:
            local_path: The path to the dataset on the local machine.
            dest_file_path: The path to the dataset on the remote machine.

        Returns:
            The absolute path to the uploaded file on the remote machine.
        """
        pass

    @abstractmethod
    def generate_report(self, dest_dir: str, filename: str) -> str:
        """
        Generates the report representing the analysis so far (including the code and the output it cell was executed).
        The typo of the file is determined by the runtime.

        Parameters:
            dest_dir: The directory where the report will be saved.
            filename: The name of the report file (without extension).
        """
        pass

Classes

class IRuntime

Class representing the analysis process. It takes the code snippets and allows to run them. Except the code itself, it also keeps the comments describing the whole process.

Each separate input (both code and description blocks) is stored with the index, so that it can be easily referenced. Those blocks will be called cells. It is based on Jupyter Notebook design.

Expand source code
class IRuntime(ABC):
    """
    Class representing the analysis process.
    It takes the code snippets and allows to run them.
    Except the code itself, it also keeps the comments describing the whole process.

    Each separate input (both code and description blocks) is stored with the index, so that it can be easily referenced.
    Those blocks will be called cells.
    It is based on Jupyter Notebook design.
    """

    @abstractmethod
    def set_report_title(self, title: str) -> None:
        """
        Sets the title of the report.
        """
        pass

    @abstractmethod
    def add_description(self, description: str) -> int:
        """
        Adds a cell with the description of the process.

        Returns:
            The index of the cell.
        """
        pass

    @abstractmethod
    def add_code(self, code: str) -> int:
        """
        Adds a cell with the code.

        Returns:
            The index of the cell.
        """
        pass

    @abstractmethod
    def remove_cell(self, cell_index: int = -1) -> None:
        """
        Removes the cell with the given index.
        """
        pass

    @abstractmethod
    def execute_cell(self, cell_index: int = -1) -> None:
        """
        Executes a cell with the given index, if it is a code cell. Otherwise, does nothing.
        Errors are also written to the output.
        """
        pass

    @abstractmethod
    def get_content(self, cell_index: int = -1) -> str:
        """
        Returns the content of the cell with the given index.
        """
        pass

    @abstractmethod
    def get_cell_output_stream(self, cell_index: int = -1) -> Union[str, None]:
        """
        Returns the output (only stdout and stderr, no media) of the cell with the given index, if it is a code cell. Otherwise, returns None.
        """
        pass

    @abstractmethod
    def check_if_plot_in_output(self, cell_index: int = -1) -> bool:
        """
        Returns true if the output of the cell with the given index contains a plot.
        """
        pass

    @abstractmethod
    def upload_file(self, local_path: str, dest_file_path: str) -> None:
        """
        Uploads the data files for further use by runtime.

        Parameters:
            local_path: The path to the dataset on the local machine.
            dest_file_path: The path to the dataset on the remote machine.

        Returns:
            The absolute path to the uploaded file on the remote machine.
        """
        pass

    @abstractmethod
    def generate_report(self, dest_dir: str, filename: str) -> str:
        """
        Generates the report representing the analysis so far (including the code and the output it cell was executed).
        The typo of the file is determined by the runtime.

        Parameters:
            dest_dir: The directory where the report will be saved.
            filename: The name of the report file (without extension).
        """
        pass

Ancestors

  • abc.ABC

Methods

def add_code(self, code: str) ‑> int

Adds a cell with the code.

Returns

The index of the cell.

Expand source code
@abstractmethod
def add_code(self, code: str) -> int:
    """
    Adds a cell with the code.

    Returns:
        The index of the cell.
    """
    pass
def add_description(self, description: str) ‑> int

Adds a cell with the description of the process.

Returns

The index of the cell.

Expand source code
@abstractmethod
def add_description(self, description: str) -> int:
    """
    Adds a cell with the description of the process.

    Returns:
        The index of the cell.
    """
    pass
def check_if_plot_in_output(self, cell_index: int = -1) ‑> bool

Returns true if the output of the cell with the given index contains a plot.

Expand source code
@abstractmethod
def check_if_plot_in_output(self, cell_index: int = -1) -> bool:
    """
    Returns true if the output of the cell with the given index contains a plot.
    """
    pass
def execute_cell(self, cell_index: int = -1) ‑> None

Executes a cell with the given index, if it is a code cell. Otherwise, does nothing. Errors are also written to the output.

Expand source code
@abstractmethod
def execute_cell(self, cell_index: int = -1) -> None:
    """
    Executes a cell with the given index, if it is a code cell. Otherwise, does nothing.
    Errors are also written to the output.
    """
    pass
def generate_report(self, dest_dir: str, filename: str) ‑> str

Generates the report representing the analysis so far (including the code and the output it cell was executed). The typo of the file is determined by the runtime.

Parameters

dest_dir: The directory where the report will be saved. filename: The name of the report file (without extension).

Expand source code
@abstractmethod
def generate_report(self, dest_dir: str, filename: str) -> str:
    """
    Generates the report representing the analysis so far (including the code and the output it cell was executed).
    The typo of the file is determined by the runtime.

    Parameters:
        dest_dir: The directory where the report will be saved.
        filename: The name of the report file (without extension).
    """
    pass
def get_cell_output_stream(self, cell_index: int = -1) ‑> Optional[str]

Returns the output (only stdout and stderr, no media) of the cell with the given index, if it is a code cell. Otherwise, returns None.

Expand source code
@abstractmethod
def get_cell_output_stream(self, cell_index: int = -1) -> Union[str, None]:
    """
    Returns the output (only stdout and stderr, no media) of the cell with the given index, if it is a code cell. Otherwise, returns None.
    """
    pass
def get_content(self, cell_index: int = -1) ‑> str

Returns the content of the cell with the given index.

Expand source code
@abstractmethod
def get_content(self, cell_index: int = -1) -> str:
    """
    Returns the content of the cell with the given index.
    """
    pass
def remove_cell(self, cell_index: int = -1) ‑> None

Removes the cell with the given index.

Expand source code
@abstractmethod
def remove_cell(self, cell_index: int = -1) -> None:
    """
    Removes the cell with the given index.
    """
    pass
def set_report_title(self, title: str) ‑> None

Sets the title of the report.

Expand source code
@abstractmethod
def set_report_title(self, title: str) -> None:
    """
    Sets the title of the report.
    """
    pass
def upload_file(self, local_path: str, dest_file_path: str) ‑> None

Uploads the data files for further use by runtime.

Parameters

local_path: The path to the dataset on the local machine. dest_file_path: The path to the dataset on the remote machine.

Returns

The absolute path to the uploaded file on the remote machine.

Expand source code
@abstractmethod
def upload_file(self, local_path: str, dest_file_path: str) -> None:
    """
    Uploads the data files for further use by runtime.

    Parameters:
        local_path: The path to the dataset on the local machine.
        dest_file_path: The path to the dataset on the remote machine.

    Returns:
        The absolute path to the uploaded file on the remote machine.
    """
    pass