Command line interface for SciPyMasterPro.
Examples:
Launch the Streamlit app::
Regenerate the synthetic datasets::
scipymasterpro generate-data
Print the environment summary (Python, NumPy, SciPy, ... versions)::
cmd_info(_)
Print version information for the toolkit and its dependencies.
Source code in scipymasterpro/cli.py
| def cmd_info(_: argparse.Namespace) -> int:
"""Print version information for the toolkit and its dependencies."""
print(f"SciPyMasterPro {__version__}")
print(f"Python {platform.python_version()} on {platform.system()} {platform.machine()}")
print(f"Project root: {PROJECT_ROOT}")
print()
for name, ver in _library_versions().items():
print(f" {name:<12} {ver}")
return 0
|
cmd_app(args)
Run the Streamlit application.
Source code in scipymasterpro/cli.py
| def cmd_app(args: argparse.Namespace) -> int:
"""Run the Streamlit application."""
if not APP_PATH.exists():
print(f"Streamlit app not found at {APP_PATH}", file=sys.stderr)
return 1
cmd = [
sys.executable,
"-m",
"streamlit",
"run",
str(APP_PATH),
f"--server.port={args.port}",
f"--server.address={args.address}",
]
if args.headless:
cmd.append("--server.headless=true")
return subprocess.call(cmd) # nosec B603 - fixed argv, no shell, inputs are typed CLI options
|
cmd_generate_data(args)
Regenerate every synthetic dataset.
Source code in scipymasterpro/cli.py
| def cmd_generate_data(args: argparse.Namespace) -> int:
"""Regenerate every synthetic dataset."""
from synthetic_data.generate_synthetic_data import EXPORT_DIR, export_all_datasets
export_all_datasets(args.output or EXPORT_DIR)
return 0
|
build_parser()
Construct the argument parser for the scipymasterpro command.
Source code in scipymasterpro/cli.py
| def build_parser() -> argparse.ArgumentParser:
"""Construct the argument parser for the ``scipymasterpro`` command."""
parser = argparse.ArgumentParser(
prog="scipymasterpro",
description="SciPyMasterPro: notebooks, utilities and an interactive app for mastering SciPy.",
)
parser.add_argument("--version", action="version", version=f"%(prog)s {__version__}")
sub = parser.add_subparsers(dest="command", required=True)
p_info = sub.add_parser("info", help="show toolkit and dependency versions")
p_info.set_defaults(func=cmd_info)
p_app = sub.add_parser("app", help="launch the Streamlit application")
p_app.add_argument("--port", type=int, default=8501, help="port to serve on (default: 8501)")
p_app.add_argument(
"--address", default="localhost", help="address to bind (default: localhost)"
)
p_app.add_argument("--headless", action="store_true", help="do not open a browser window")
p_app.set_defaults(func=cmd_app)
p_gen = sub.add_parser("generate-data", help="regenerate the synthetic datasets")
p_gen.add_argument(
"-o", "--output", type=Path, default=None, help="directory to write CSV files to"
)
p_gen.set_defaults(func=cmd_generate_data)
return parser
|
main(argv=None)
Entry point for the scipymasterpro console script.
Source code in scipymasterpro/cli.py
| def main(argv: Sequence[str] | None = None) -> int:
"""Entry point for the ``scipymasterpro`` console script."""
parser = build_parser()
args = parser.parse_args(argv)
return int(args.func(args))
|
run_app()
Entry point for the legacy scipy-app console script.
Source code in scipymasterpro/cli.py
| def run_app() -> int:
"""Entry point for the legacy ``scipy-app`` console script."""
return main(["app"])
|