API#

Here: server classes#

async herethere.here.start_server(config: ~herethere.here.config.ServerConfig, namespace: dict = None, server_factory: type[~herethere.here.server.SSHServerHere] = <class 'herethere.here.server.SSHServerHere'>) RunningServer[source]#

Start SSH server.

Parameters:
  • config – server configuration options

  • namespace – dictionary in which Python code commands will be executed

  • server_factory – optional protocol handler class

class herethere.here.ServerConfig(username: str, password: str, *, host: str = '127.0.0.1', port: int = 8022, key_path: str = './key.rsa', sftp_root: str = '.', chroot: str | None = None)[source]#

Bases: ConnectionConfig

SSH server configuration.

property asdict: dict[str, Any]#

Dict represntation of the instance.

classmethod load(prefix: str = '', path: str = None) ConnectionConfig#

Load configuration from the environment, and file with configurations variables. If path is not specified, variables are loaded from a file named {prefix}.env in the current directory or any of its parents.

Parameters:
  • prefix – prefix for variables ({PREFIX}_HOST), and a configuration file name to search for: {prefix}.env

  • path – explicit configuration file location

classmethod load_from_dict(*, env: dict[str, str], prefix: str) ServerConfig[source]#

Load server config, accepting HERE_CHROOT as a deprecated alias.

save(path: str, prefix: str = '')#

Save config to the given location.

class herethere.here.server.RunningServer(server: AbstractServer, namespace, executor: ThreadPoolExecutor, connections: set[SSHServerConnection])[source]#

Wrapper for a running SSH server instance.

async stop(timeout: float = 1.0)[source]#

Stop SSH server.

class herethere.here.server.SSHServerHere(username: str, password: str, executor: ThreadPoolExecutor, connections: set[SSHServerConnection] | None = None)[source]#

Bases: SSHServer

SSH server protocol handler with username and password options.

There: client classes#

class herethere.there.Client[source]#

Client for remote interpreter.

async connect(config: ConnectionConfig)[source]#

Connect to remote.

async copy() Client[source]#

Return a copy of the configured connection.

async disconnect()[source]#

Disconnect from the remote.

async download(remotepaths: list[str], localpath) None[source]#

Download files and directories from remote via SFTP.

async get(expression: str)[source]#

Evaluate a Python expression remotely and return its Python value.

async runcode(code: str, stdout: TextIO | None = None, stderr: TextIO | None = None) str[source]#

Execute python code on the remote side.

async runcode_background(code: str, stdout: TextIO | None = None, stderr: TextIO | None = None) str[source]#

Execute Python code in a separate thread on the remote side.

sftp_progress_handler(srcpath, dstpath, copied, total)[source]#

Log SFTP transfer progress.

async shell(code: str, stdout: TextIO | None = None, stderr: TextIO | None = None) str[source]#

Execute shell command on the remote side.

async upload(localpaths: list[str], remotepath) None[source]#

Upload files and directories to remote via SFTP.

class herethere.everywhere.config.ConnectionConfig(host: str, port: int, username: str, password: str)[source]#

Remote connection configuration.

property asdict: dict[str, Any]#

Dict represntation of the instance.

classmethod load(prefix: str = '', path: str = None) ConnectionConfig[source]#

Load configuration from the environment, and file with configurations variables. If path is not specified, variables are loaded from a file named {prefix}.env in the current directory or any of its parents.

Parameters:
  • prefix – prefix for variables ({PREFIX}_HOST), and a configuration file name to search for: {prefix}.env

  • path – explicit configuration file location

classmethod load_from_dict(*, env: dict[str, str], prefix: str) ConnectionConfig[source]#

Load config from dictionary.

save(path: str, prefix: str = '')[source]#

Save config to the given location.

herethere.there.commands.there_code_shortcut(handler: Callable[[str], str]) Callable[[Context], None][source]#

Decorator to register %there subcommand to execute Python code.

Parameters:

handler – a function, that receives text from the Jupyter cell, and returns Python code to execute on the remote side

AI assisted cell generation helpers#

AI-assisted local generation of %%there notebook cells.

herethere.there.ai.build_ai_template(prompt_names: Iterable[str] | None = None, *, include_default: bool = True) str[source]#

Compose the named prompt sections into one system prompt.

herethere.there.ai.clear_ai_config_path() None[source]#

Clear the session AI config path and return to default discovery.

herethere.there.ai.clear_ai_prompts() None[source]#

Clear session-level %%there ai prompt overrides.

herethere.there.ai.get_ai_prompt(name: str) str[source]#

Return one registered or built-in prompt section.

herethere.there.ai.list_ai_prompts() tuple[str, ...][source]#

Return registered and built-in prompt section names.

herethere.there.ai.register_ai_prompt(name: str, prompt: str) None[source]#

Register or override a reusable prompt section.

herethere.there.ai.set_ai_config_path(path: str) None[source]#

Set the session AI config file path used by %%there ai.

herethere.there.ai.set_ai_prompts(*names: str, include_default: bool = True) None[source]#

Set the session prompt stack used by %%there ai.