# flyteplugins.union.debug

SSH-into-task debug helpers.

`with_debugcontext(...)` is `flyte.with_runcontext(...)` preconfigured for
ssh-into-task debug: it creates/uses the auto-managed debug keypair and sets the
``_F_E_SSH`` / ``_F_SSH_PK`` / ``_F_E_VS`` env vars, then forwards everything
else to `flyte.with_runcontext`. After the run starts, resolve the connection
with `SSHDebug.connect(run.name)` (or the `flyte connect ssh <run>` CLI).

Example:
```python
import flyte
from flyteplugins.union.debug import with_debugcontext, SSHDebug

flyte.init_from_config()
run = with_debugcontext().run(my_task, x=1)
print(SSHDebug.connect(run.name).ssh_config)   # paste into ~/.ssh/config, then `ssh flyte-debug`
```
## Directory

### Classes

| Class | Description |
|-|-|
| [`SSHDebug`](https://www.union.ai/docs/v2/union/api-reference/union-plugin/packages/flyteplugins.union.debug/sshdebug/page.md) | Resolved SSH-into-task connect info for a running debug action. |

### Methods

| Method | Description |
|-|-|
| [`with_debugcontext()`](#with_debugcontext) | Like `flyte. |

## Methods

#### with_debugcontext()

```python
def with_debugcontext(
    mode: Any,
    env_vars: Optional[Dict[str, str]],
    kwargs,
)
```
Like `flyte.with_runcontext`, but preconfigured for ssh-into-task debug.

Ensures the auto-managed debug keypair exists and merges the ssh-debug env
(``_F_E_SSH`` / ``_F_SSH_PK`` / ``_F_E_VS``) into *env_vars*; all other
arguments are forwarded unchanged. Returns the same runner as
`with_runcontext`, so call ``.run(task, ...)`` on it.

| Parameter | Type | Description |
|-|-|-|
| `mode` | `Any` | |
| `env_vars` | `Optional[Dict[str, str]]` | |
| `kwargs` | `**kwargs` | |

## Subpages

- [SSHDebug](https://www.union.ai/docs/v2/union/api-reference/union-plugin/packages/flyteplugins.union.debug/sshdebug/page.md)
  - Parameters
  - Methods
  - connect()
  - ensure_api_key()
  - ensure_keypair()
  - launch_env()

---
**Source**: https://github.com/unionai/unionai-docs/blob/main/content/api-reference/union-plugin/packages/flyteplugins.union.debug/_index.md
**HTML**: https://www.union.ai/docs/v2/union/api-reference/union-plugin/packages/flyteplugins.union.debug/
