Exemplo n.º 1
0
def send(file_name: str):
    J_LOGGER.info(f"Executing all cells in file: {file_name}...")
    file_name = str(Path(file_name).absolute())

    request_obj = ExecuteAllRequest(file_name=file_name)
    jupyter_server.request_notebook_command(request_obj)

    J_LOGGER.info("... Complete")
Exemplo n.º 2
0
def send(file_name: str):
    if f".{SYNC_EXTENSION}.py" not in file_name:
        return

    J_LOGGER.info(f"Syncing File: {file_name}...")
    file_name = str(Path(file_name).absolute())

    with open(file_name, "r") as reader:
        raw_result = reader.read()

    request_obj = SyncRequest(file_name=file_name, contents=raw_result)
    jupyter_server.request_notebook_command(request_obj)

    J_LOGGER.info("... Complete")
Exemplo n.º 3
0
def send(file_name: str, line_number: int, *args, **kwargs):
    J_LOGGER.debug("Starting execute request")

    # Always pass absolute path
    file_name = str(Path(file_name).absolute())

    request_obj = partial(ExecuteRequest, file_name=file_name, contents="")

    with open(file_name, "r") as reader:
        lines = reader.readlines()

    cell_index = _find_cell_number(lines, line_number)

    final_request = request_obj(cell_index=cell_index)
    J_LOGGER.info(f"Sending request with {final_request}")
    jupyter_server.request_notebook_command(final_request)
    J_LOGGER.info("... Complete")
Exemplo n.º 4
0
def send(file_name: str, line_number: int, *args, **kwargs):
    # Always pass absolute path
    file_name = str(Path(file_name).absolute())

    request_obj = partial(ExecuteRequest, file_name=file_name, contents="")

    cell_index = -1
    with open(arguments.filename, "r") as reader:
        for index, line in enumerate(reader):
            if line.startswith("# %%"):
                print("Incing", line)
                cell_index += 1

            # No need to loop through the whole file, just execute when we get there
            if index == int(arguments.linenumber):
                jupyter_server.request_notebook_command(request_obj(cell_index=cell_index))

                return

    jupyter_server.request_notebook_command(request_obj(cell_index=cell_index))
Exemplo n.º 5
0
def send(file_name: str):
    file_name = str(Path(file_name).absolute())

    request_obj = GetStatusRequest(file_name=file_name)
    jupyter_server.request_notebook_command(request_obj)