Skip to content

spark_on_k8s.cli.connect

Implementation reference. These symbols describe how the project works; their presence here does not make them supported application imports. Use the documented entry points and support policy.

check(file, profile, timeout, output)

Run a tiny remote query, then close only the check's session.

Source code in spark_on_k8s/cli/connect.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
@connect_cli.command(name="check")
@click.argument("file", type=click.Path(exists=True, dir_okay=False))
@click.option("--profile", default="default", show_default=True)
@click.option(
    "--timeout",
    type=click.FloatRange(min=0, min_open=True),
    callback=validate_timeout,
    default=15,
    show_default=True,
)
@click.option("--output", type=click.Choice(["text", "json"]), default="text", show_default=True)
def check(file, profile, timeout, output):
    """Run a tiny remote query, then close only the check's session."""
    # The check uses no Kubernetes namespace; the shared contract maps failures to exit codes.
    with execution("connect_check", "", output) as result:
        result.update(status="error", spark_version=None, client_version=None, warnings=[])
        probe = ConnectProfile.from_file(file, profile=profile).probe(timeout=timeout)
        result.update(
            status=probe["status"],
            spark_version=probe.get("spark_version"),
            client_version=probe.get("client_version"),
            warnings=probe.get("warnings", []),
        )
        if output == "text":
            click.echo(
                f"Connected to Spark {result['spark_version']} with client "
                f"{result['client_version'] or 'unknown'}; check session closed."
            )
        report_warnings(result["warnings"], output)