Skip to main content

scitex-context

SciTeX

Execution-context detection (script vs Jupyter vs IPython) and output suppression helpers.

Full Documentation · uv pip install scitex-context[all]

pypi python docs License: AGPL v3

tests cov


Quick Start

import scitex_context as ctx

if ctx.is_notebook():
    print("Running inside Jupyter")

with ctx.suppress_output():
    noisy_function()

Demo

flowchart LR
    A["import scitex_context as ctx"] --> B{ctx.detect_environment()}
    B -- "python foo.py" --> S["script"]
    B -- "jupyter" --> N["notebook"]
    B -- "ipython REPL" --> I["ipython"]
    S & N & I --> O["ctx.get_output_directory()"]
    N --> P["ctx.get_notebook_path()"]
    A --> Q["with ctx.suppress_output():<br/>    noisy_call()"]

Figure 1. Detect-then-adapt: one import reports the execution context, then output-directory and notebook helpers follow it.

Installation

uv pip install "scitex-context[all]"

Through the umbrella: uv pip install "scitex[context]". Requires Python ≥ 3.10.

Per-extra installs
Extra Pulls in
dev pytest, pytest-cov, pytest-timeout, ruff, scitex-dev
docs sphinx, sphinx-rtd-theme, myst-parser, sphinx-copybutton, sphinx-autodoc-typehints

Architecture

flowchart LR
    U["user code"] --> D["_detect_environment.py"]
    D -- "script | notebook | ipython" --> S["_suppress_output.py"]
    D --> G["_get_notebook_path.py"]
    S --> P["public API: __init__.py"]
    G --> P

Figure 2. Module layout: environment detection feeds output suppression and notebook-path helpers, all re-exported from the public API.

Pure-stdlib, zero-dep helpers. The umbrella scitex.context import path is preserved via a sys.modules-alias bridge installed at import time.

1 Interfaces

Python API
import scitex_context as ctx

# Environment detection
ctx.detect_environment()       # "script" | "notebook" | "ipython"
ctx.is_script()                # True if running under `python foo.py`
ctx.is_notebook()              # True under Jupyter
ctx.is_ipython()               # True under bare IPython
ctx.get_output_directory()     # Conventional output dir for current context

# Notebook helpers (no-op outside a notebook)
ctx.get_notebook_path()
ctx.get_notebook_directory()
ctx.get_notebook_name()
ctx.get_notebook_info_simple()

# Output suppression
with ctx.suppress_output():
    noisy_function()

with ctx.quiet():               # alias
    chatty_lib_call()

Status

Standalone fork of scitex.context. Pure stdlib — zero deps. The umbrella package's scitex.context import path is preserved via a sys.modules-alias bridge.

Part of SciTeX

scitex-context is part of SciTeX. Install via the umbrella with pip install scitex[context] to use as scitex.context (Python) or scitex context ... (CLI).

Four Freedoms for Research

  1. The freedom to run your research anywhere — your machine, your terms.
  2. The freedom to study how every step works — from raw data to final manuscript.
  3. The freedom to redistribute your workflows, not just your papers.
  4. The freedom to modify any module and share improvements with the community.

AGPL-3.0 — because we believe research infrastructure deserves the same freedoms as the software it runs on.

License

AGPL-3.0-only (see LICENSE).


SciTeX

Metadata

Release files for scitex-context 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for scitex-context 0.1.5
File Size Uploaded
scitex_context-0.1.5.tar.gz 23.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for scitex-context 0.1.5
File Interpreter ABI Platform
scitex_context-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 47.8 kB

Release files / scitex_context-0.1.5.tar.gz

Download URL scitex_context-0.1.5.tar.gz
Size 23.8 kB
Tags Source
SHA-256 checksum
How to use checksums
1d8bb5b2e08e631f3b8b17e9180294fc2907e7ca302e616fadc46f761680ab77
BLAKE2b-256 checksum
How to use checksums
e3bb90a6b549865f6d43d86c565e5c23484793b117552dc1028e1bc9d53d7868
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.12.14

Release files / scitex_context-0.1.5-py3-none-any.whl

Download URL scitex_context-0.1.5-py3-none-any.whl
Size 24.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
213fff7bce980794e6c90e3a6f5a24e7fd886d02735e4d70bd37acace697f03d
BLAKE2b-256 checksum
How to use checksums
78b71d604b6b5d6a0a990de3d80b24b7ae0bafde242f50bae9b1d8464ac9cf27
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.12.14

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page