kernelcontract 0.1.0a3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 KernelContract contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,188 @@
1
+ Metadata-Version: 2.4
2
+ Name: kernelcontract
3
+ Version: 0.1.0a3
4
+ Summary: Read-only diagnostics for Jupyter kernels and Python environments
5
+ Author: KernelContract contributors
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 KernelContract contributors
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Keywords: jupyter,notebook,kernel,diagnostics,python-environments
29
+ Classifier: Development Status :: 3 - Alpha
30
+ Classifier: Environment :: Console
31
+ Classifier: Intended Audience :: Developers
32
+ Classifier: License :: OSI Approved :: MIT License
33
+ Classifier: Operating System :: OS Independent
34
+ Classifier: Programming Language :: Python :: 3
35
+ Classifier: Programming Language :: Python :: 3.10
36
+ Classifier: Programming Language :: Python :: 3.11
37
+ Classifier: Programming Language :: Python :: 3.12
38
+ Classifier: Programming Language :: Python :: 3.13
39
+ Classifier: Topic :: Scientific/Engineering
40
+ Classifier: Topic :: Software Development :: Debuggers
41
+ Classifier: Topic :: Utilities
42
+ Requires-Python: >=3.10
43
+ Description-Content-Type: text/markdown
44
+ License-File: LICENSE
45
+ Provides-Extra: test
46
+ Requires-Dist: pytest>=8.0; extra == "test"
47
+ Dynamic: license-file
48
+
49
+ # KernelContract
50
+
51
+ **Local-first, read-only diagnostics for Jupyter kernels, kernelspecs, and notebook environments.**
52
+
53
+ KernelContract inspects registered Jupyter kernelspecs, checks whether their configured executables resolve, probes Python kernel environments, and compares notebook kernel metadata with the kernels available to the current Jupyter CLI. It reports likely configuration mismatches, missing interpreters, and safe next steps without modifying the machine.
54
+
55
+ > **Alpha Software — Candidate 0.1.0a3 (Latest tagged pre-release: [v0.1.0a2](https://github.com/Ayushxsingh100/kernelcontract/releases/tag/v0.1.0a2)).** KernelContract is an early-stage diagnostic tool under active development. The latest published GitHub pre-release is `v0.1.0a2`, and the current default branch is preparing candidate `0.1.0a3` for PyPI Trusted Publishing. It has **not** yet been published to PyPI. The project name is provisional and has not been trademark- or registry-cleared.
56
+
57
+ ---
58
+
59
+ ## Quick start
60
+
61
+ ### Prerequisites
62
+
63
+ * **Python 3.10 or newer.**
64
+ * **Jupyter CLI on PATH:** KernelContract has zero external runtime dependencies (it uses the Python standard library only), but it requires that the `jupyter` command is available on your `PATH` (such as via `jupyter-core`) to discover registered kernels via `jupyter kernelspec list --json`.
65
+
66
+ ### End-user installation (pre-release)
67
+
68
+ Install the tagged alpha pre-release directly from GitHub using `pip`:
69
+
70
+ ```bash
71
+ python -m pip install "git+https://github.com/Ayushxsingh100/kernelcontract.git@v0.1.0a3"
72
+ ```
73
+
74
+ Or install the latest development snapshot from the default `master` branch:
75
+
76
+ ```bash
77
+ python -m pip install "git+https://github.com/Ayushxsingh100/kernelcontract.git"
78
+ ```
79
+
80
+ > **Note on PyPI:** The command `pip install kernelcontract` is reserved for future distribution once the package is officially published to the Python Package Index.
81
+
82
+ ---
83
+
84
+ ## Core usage
85
+
86
+ ### 1. Diagnose registered Jupyter kernels
87
+
88
+ Run the `doctor` command to inspect all discovered kernelspecs, verify their executables, and check the active Python environment:
89
+
90
+ ```bash
91
+ kernelcontract doctor
92
+ ```
93
+
94
+ ### 2. Validate notebook kernel metadata
95
+
96
+ Inspect whether a `.ipynb` file's declared kernel exists and matches currently registered kernelspecs:
97
+
98
+ ```bash
99
+ kernelcontract notebook path/to/notebook.ipynb
100
+ ```
101
+
102
+ If the notebook requests an unavailable kernel or if the kernel's stored display name has drifted from disk, KernelContract reports the issue with actionable next steps.
103
+
104
+ ### 3. Machine-readable JSON output
105
+
106
+ Produce structured, versioned JSON suitable for automated tooling, pre-commit hooks, or CI pipelines:
107
+
108
+ ```bash
109
+ kernelcontract doctor --json
110
+ kernelcontract notebook path/to/notebook.ipynb --json
111
+ ```
112
+
113
+ The JSON schema output includes `schema_version`, `status` (`PASS`, `WARN`, `FAIL`), check details, and specific remediation suggestions.
114
+
115
+ ### 4. Strict CI mode
116
+
117
+ By default, `FAIL` makes the command exit with status 1, while warnings exit with status 0. To fail CI on warnings as well as failures, pass `--strict`:
118
+
119
+ ```bash
120
+ kernelcontract doctor --strict
121
+ ```
122
+
123
+ ### 5. Probing external Python kernels (opt-in)
124
+
125
+ ```bash
126
+ kernelcontract doctor --probe-python
127
+ ```
128
+
129
+ * **Security Note:** By default, KernelContract only executes package inspection on the current control interpreter and kernels that resolve to the exact same executable. Interpreters outside the current environment are **not** executed unless you pass `--probe-python`. Use `--probe-python` only with kernelspecs and environments you trust.
130
+
131
+ ---
132
+
133
+ ## What it checks
134
+
135
+ * **CLI Discovery:** Whether the Jupyter CLI can enumerate kernelspecs using `jupyter kernelspec list --json`.
136
+ * **JSON Structure Safety:** Whether kernelspec outputs have valid root structures and dictionary objects.
137
+ * **Executable Resolution:** Whether each registered kernelspec has a resolvable `argv[0]` executable (including Windows `PATHEXT` resolution for `.exe`, `.cmd`, `.bat`, quoted paths with spaces, and environment variable expansion).
138
+ * **Environment Integrity:** Whether the control Python (and, when opted in, external Python kernels) can start and whether `ipykernel` is installed in that interpreter.
139
+ * **Environment Drift:** Whether a probed kernel's Python prefix differs from the control interpreter.
140
+ * **Widget Companion Check:** A narrow check for presence of `jupyterlab_widgets` when the control environment contains JupyterLab and a probed kernel contains `ipywidgets`.
141
+ * **Notebook Metadata Check:** Whether a notebook file declares a kernel name that is currently registered and whether the recorded display name matches the kernelspec on disk.
142
+
143
+ ---
144
+
145
+ ## Server vs. kernel environments
146
+
147
+ KernelContract cannot reliably infer which Python interpreter belongs to an already-running Jupyter server across diverse setups (e.g. systemd services, Docker containers, remote SSH tunnels, JupyterHub). By default, it uses the Python interpreter launching KernelContract as its **control environment**.
148
+
149
+ If you know the specific Python interpreter running the Jupyter server, pass it explicitly:
150
+
151
+ ```bash
152
+ kernelcontract doctor --server-python /absolute/path/to/server/python
153
+ ```
154
+
155
+ ---
156
+
157
+ ## Safety and privacy guarantees
158
+
159
+ * **Strictly Read-Only:** KernelContract modifies no packages, rewrites no files, and changes no configuration.
160
+ * **No Telemetry:** Zero analytics, telemetry, or network calls are made by KernelContract.
161
+ * **Bounded Subprocesses:** Subprocess probes use strict execution timeouts to avoid hanging indefinitely.
162
+ * **No Shell Execution:** Commands are executed directly with argument lists (`shell=False`).
163
+
164
+ ---
165
+
166
+ ## Development
167
+
168
+ To contribute or run the test suite locally from source:
169
+
170
+ ```bash
171
+ git clone https://github.com/Ayushxsingh100/kernelcontract.git
172
+ cd kernelcontract
173
+ python -m venv .venv
174
+ # Activate .venv (Windows: .venv\Scripts\activate | Unix: source .venv/bin/activate)
175
+ python -m pip install -e ".[test]"
176
+ python -m unittest discover -s tests -v
177
+ python -m pytest -q
178
+ ```
179
+
180
+ ---
181
+
182
+ ## Status
183
+
184
+ * **Version:** `0.1.0a3` (alpha candidate; latest tagged pre-release: [`v0.1.0a2`](https://github.com/Ayushxsingh100/kernelcontract/releases/tag/v0.1.0a2))
185
+ * **Repository:** [https://github.com/Ayushxsingh100/kernelcontract](https://github.com/Ayushxsingh100/kernelcontract)
186
+ * **Pre-release Notes:** [v0.1.0a2 Release](https://github.com/Ayushxsingh100/kernelcontract/releases/tag/v0.1.0a2)
187
+ * **License:** [MIT](LICENSE)
188
+ * **Stability:** Alpha
@@ -0,0 +1,140 @@
1
+ # KernelContract
2
+
3
+ **Local-first, read-only diagnostics for Jupyter kernels, kernelspecs, and notebook environments.**
4
+
5
+ KernelContract inspects registered Jupyter kernelspecs, checks whether their configured executables resolve, probes Python kernel environments, and compares notebook kernel metadata with the kernels available to the current Jupyter CLI. It reports likely configuration mismatches, missing interpreters, and safe next steps without modifying the machine.
6
+
7
+ > **Alpha Software — Candidate 0.1.0a3 (Latest tagged pre-release: [v0.1.0a2](https://github.com/Ayushxsingh100/kernelcontract/releases/tag/v0.1.0a2)).** KernelContract is an early-stage diagnostic tool under active development. The latest published GitHub pre-release is `v0.1.0a2`, and the current default branch is preparing candidate `0.1.0a3` for PyPI Trusted Publishing. It has **not** yet been published to PyPI. The project name is provisional and has not been trademark- or registry-cleared.
8
+
9
+ ---
10
+
11
+ ## Quick start
12
+
13
+ ### Prerequisites
14
+
15
+ * **Python 3.10 or newer.**
16
+ * **Jupyter CLI on PATH:** KernelContract has zero external runtime dependencies (it uses the Python standard library only), but it requires that the `jupyter` command is available on your `PATH` (such as via `jupyter-core`) to discover registered kernels via `jupyter kernelspec list --json`.
17
+
18
+ ### End-user installation (pre-release)
19
+
20
+ Install the tagged alpha pre-release directly from GitHub using `pip`:
21
+
22
+ ```bash
23
+ python -m pip install "git+https://github.com/Ayushxsingh100/kernelcontract.git@v0.1.0a3"
24
+ ```
25
+
26
+ Or install the latest development snapshot from the default `master` branch:
27
+
28
+ ```bash
29
+ python -m pip install "git+https://github.com/Ayushxsingh100/kernelcontract.git"
30
+ ```
31
+
32
+ > **Note on PyPI:** The command `pip install kernelcontract` is reserved for future distribution once the package is officially published to the Python Package Index.
33
+
34
+ ---
35
+
36
+ ## Core usage
37
+
38
+ ### 1. Diagnose registered Jupyter kernels
39
+
40
+ Run the `doctor` command to inspect all discovered kernelspecs, verify their executables, and check the active Python environment:
41
+
42
+ ```bash
43
+ kernelcontract doctor
44
+ ```
45
+
46
+ ### 2. Validate notebook kernel metadata
47
+
48
+ Inspect whether a `.ipynb` file's declared kernel exists and matches currently registered kernelspecs:
49
+
50
+ ```bash
51
+ kernelcontract notebook path/to/notebook.ipynb
52
+ ```
53
+
54
+ If the notebook requests an unavailable kernel or if the kernel's stored display name has drifted from disk, KernelContract reports the issue with actionable next steps.
55
+
56
+ ### 3. Machine-readable JSON output
57
+
58
+ Produce structured, versioned JSON suitable for automated tooling, pre-commit hooks, or CI pipelines:
59
+
60
+ ```bash
61
+ kernelcontract doctor --json
62
+ kernelcontract notebook path/to/notebook.ipynb --json
63
+ ```
64
+
65
+ The JSON schema output includes `schema_version`, `status` (`PASS`, `WARN`, `FAIL`), check details, and specific remediation suggestions.
66
+
67
+ ### 4. Strict CI mode
68
+
69
+ By default, `FAIL` makes the command exit with status 1, while warnings exit with status 0. To fail CI on warnings as well as failures, pass `--strict`:
70
+
71
+ ```bash
72
+ kernelcontract doctor --strict
73
+ ```
74
+
75
+ ### 5. Probing external Python kernels (opt-in)
76
+
77
+ ```bash
78
+ kernelcontract doctor --probe-python
79
+ ```
80
+
81
+ * **Security Note:** By default, KernelContract only executes package inspection on the current control interpreter and kernels that resolve to the exact same executable. Interpreters outside the current environment are **not** executed unless you pass `--probe-python`. Use `--probe-python` only with kernelspecs and environments you trust.
82
+
83
+ ---
84
+
85
+ ## What it checks
86
+
87
+ * **CLI Discovery:** Whether the Jupyter CLI can enumerate kernelspecs using `jupyter kernelspec list --json`.
88
+ * **JSON Structure Safety:** Whether kernelspec outputs have valid root structures and dictionary objects.
89
+ * **Executable Resolution:** Whether each registered kernelspec has a resolvable `argv[0]` executable (including Windows `PATHEXT` resolution for `.exe`, `.cmd`, `.bat`, quoted paths with spaces, and environment variable expansion).
90
+ * **Environment Integrity:** Whether the control Python (and, when opted in, external Python kernels) can start and whether `ipykernel` is installed in that interpreter.
91
+ * **Environment Drift:** Whether a probed kernel's Python prefix differs from the control interpreter.
92
+ * **Widget Companion Check:** A narrow check for presence of `jupyterlab_widgets` when the control environment contains JupyterLab and a probed kernel contains `ipywidgets`.
93
+ * **Notebook Metadata Check:** Whether a notebook file declares a kernel name that is currently registered and whether the recorded display name matches the kernelspec on disk.
94
+
95
+ ---
96
+
97
+ ## Server vs. kernel environments
98
+
99
+ KernelContract cannot reliably infer which Python interpreter belongs to an already-running Jupyter server across diverse setups (e.g. systemd services, Docker containers, remote SSH tunnels, JupyterHub). By default, it uses the Python interpreter launching KernelContract as its **control environment**.
100
+
101
+ If you know the specific Python interpreter running the Jupyter server, pass it explicitly:
102
+
103
+ ```bash
104
+ kernelcontract doctor --server-python /absolute/path/to/server/python
105
+ ```
106
+
107
+ ---
108
+
109
+ ## Safety and privacy guarantees
110
+
111
+ * **Strictly Read-Only:** KernelContract modifies no packages, rewrites no files, and changes no configuration.
112
+ * **No Telemetry:** Zero analytics, telemetry, or network calls are made by KernelContract.
113
+ * **Bounded Subprocesses:** Subprocess probes use strict execution timeouts to avoid hanging indefinitely.
114
+ * **No Shell Execution:** Commands are executed directly with argument lists (`shell=False`).
115
+
116
+ ---
117
+
118
+ ## Development
119
+
120
+ To contribute or run the test suite locally from source:
121
+
122
+ ```bash
123
+ git clone https://github.com/Ayushxsingh100/kernelcontract.git
124
+ cd kernelcontract
125
+ python -m venv .venv
126
+ # Activate .venv (Windows: .venv\Scripts\activate | Unix: source .venv/bin/activate)
127
+ python -m pip install -e ".[test]"
128
+ python -m unittest discover -s tests -v
129
+ python -m pytest -q
130
+ ```
131
+
132
+ ---
133
+
134
+ ## Status
135
+
136
+ * **Version:** `0.1.0a3` (alpha candidate; latest tagged pre-release: [`v0.1.0a2`](https://github.com/Ayushxsingh100/kernelcontract/releases/tag/v0.1.0a2))
137
+ * **Repository:** [https://github.com/Ayushxsingh100/kernelcontract](https://github.com/Ayushxsingh100/kernelcontract)
138
+ * **Pre-release Notes:** [v0.1.0a2 Release](https://github.com/Ayushxsingh100/kernelcontract/releases/tag/v0.1.0a2)
139
+ * **License:** [MIT](LICENSE)
140
+ * **Stability:** Alpha
@@ -0,0 +1,42 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "kernelcontract"
7
+ version = "0.1.0a3"
8
+ description = "Read-only diagnostics for Jupyter kernels and Python environments"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = { file = "LICENSE" }
12
+ authors = [{ name = "KernelContract contributors" }]
13
+ keywords = ["jupyter", "notebook", "kernel", "diagnostics", "python-environments"]
14
+ classifiers = [
15
+ "Development Status :: 3 - Alpha",
16
+ "Environment :: Console",
17
+ "Intended Audience :: Developers",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Operating System :: OS Independent",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.10",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Programming Language :: Python :: 3.13",
25
+ "Topic :: Scientific/Engineering",
26
+ "Topic :: Software Development :: Debuggers",
27
+ "Topic :: Utilities",
28
+ ]
29
+ dependencies = []
30
+
31
+ [project.optional-dependencies]
32
+ test = ["pytest>=8.0"]
33
+
34
+ [project.scripts]
35
+ kernelcontract = "kernelcontract.cli:entrypoint"
36
+
37
+ [tool.setuptools.packages.find]
38
+ where = ["src"]
39
+
40
+ [tool.pytest.ini_options]
41
+ addopts = "-q"
42
+ testpaths = ["tests"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,3 @@
1
+ """KernelContract: read-only diagnostics for Jupyter kernels and Python environments."""
2
+
3
+ __version__ = "0.1.0a3"
@@ -0,0 +1,4 @@
1
+ from .cli import entrypoint
2
+
3
+ if __name__ == "__main__":
4
+ entrypoint()
@@ -0,0 +1,87 @@
1
+ """Command-line interface for KernelContract."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ import json
7
+ import sys
8
+ from typing import Optional, Sequence
9
+
10
+ from . import __version__
11
+ from .diagnostics import run_diagnostics
12
+ from .models import Report
13
+
14
+
15
+ def _parser() -> argparse.ArgumentParser:
16
+ parser = argparse.ArgumentParser(
17
+ prog="kernelcontract",
18
+ description="Read-only diagnostics for Jupyter kernels and Python environments.",
19
+ epilog="No packages are installed, removed, or modified by this tool.",
20
+ )
21
+ parser.add_argument("--version", action="version", version="%(prog)s {}".format(__version__))
22
+ subparsers = parser.add_subparsers(dest="command", required=True)
23
+
24
+ doctor = subparsers.add_parser("doctor", help="check registered Jupyter kernels and environment drift")
25
+ doctor.add_argument("--server-python", help="path to the Python interpreter used by the Jupyter server (optional)")
26
+ doctor.add_argument("--json", action="store_true", dest="json_output", help="print machine-readable JSON")
27
+ doctor.add_argument("--strict", action="store_true", help="exit non-zero for warnings as well as failures")
28
+ doctor.add_argument("--probe-python", action="store_true", help="execute each registered Python kernel's argv[0] for package checks; use only with trusted kernelspecs")
29
+
30
+ notebook = subparsers.add_parser("notebook", help="check a notebook's declared kernel against registered kernels")
31
+ notebook.add_argument("path", help="path to a .ipynb file")
32
+ notebook.add_argument("--server-python", help="path to the Python interpreter used by the Jupyter server (optional)")
33
+ notebook.add_argument("--json", action="store_true", dest="json_output", help="print machine-readable JSON")
34
+ notebook.add_argument("--strict", action="store_true", help="exit non-zero for warnings as well as failures")
35
+ notebook.add_argument("--probe-python", action="store_true", help="execute each registered Python kernel's argv[0] for package checks; use only with trusted kernelspecs")
36
+ return parser
37
+
38
+
39
+ def render_text(report: Report) -> str:
40
+ lines = ["KernelContract {} - {}".format(__version__, report.command), "=" * 44]
41
+ for check in report.checks:
42
+ lines.append("{:<5} {}".format(check.status, check.title))
43
+ lines.append(" {}".format(check.message))
44
+ for suggestion in check.suggestions:
45
+ lines.append(" Next: {}".format(suggestion))
46
+ counts = report.counts
47
+ lines.extend([
48
+ "",
49
+ "Summary: {pass_count} pass, {info_count} info, {warn_count} warning(s), {fail_count} failure(s).".format(
50
+ pass_count=counts["pass"], info_count=counts["info"], warn_count=counts["warn"], fail_count=counts["fail"]
51
+ ),
52
+ "Overall status: {}".format(report.overall_status),
53
+ "KernelContract did not modify packages or environments.",
54
+ ])
55
+ return "\n".join(lines)
56
+
57
+
58
+ def exit_code(report: Report, strict: bool = False) -> int:
59
+ if any(check.status == "FAIL" for check in report.checks):
60
+ return 1
61
+ if strict and any(check.status == "WARN" for check in report.checks):
62
+ return 1
63
+ return 0
64
+
65
+
66
+ def main(argv: Optional[Sequence[str]] = None) -> int:
67
+ args = _parser().parse_args(argv)
68
+ notebook_path = args.path if args.command == "notebook" else None
69
+ report = run_diagnostics(
70
+ command=args.command,
71
+ notebook_path=notebook_path,
72
+ server_python=args.server_python,
73
+ probe_python_kernels=args.probe_python,
74
+ )
75
+ if args.json_output:
76
+ print(json.dumps(report.to_dict(), indent=2, sort_keys=True))
77
+ else:
78
+ print(render_text(report))
79
+ return exit_code(report, strict=args.strict)
80
+
81
+
82
+ def entrypoint() -> None:
83
+ raise SystemExit(main())
84
+
85
+
86
+ if __name__ == "__main__":
87
+ entrypoint()