sashiny 0.1.1__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.
Files changed (51) hide show
  1. sashiny-0.1.1/.gitignore +35 -0
  2. sashiny-0.1.1/CHANGELOG.md +73 -0
  3. sashiny-0.1.1/LICENSE +21 -0
  4. sashiny-0.1.1/PKG-INFO +57 -0
  5. sashiny-0.1.1/README.md +14 -0
  6. sashiny-0.1.1/pyproject.toml +98 -0
  7. sashiny-0.1.1/src/sashiny/__init__.py +68 -0
  8. sashiny-0.1.1/src/sashiny/_data/sashiny.schema.json +383 -0
  9. sashiny-0.1.1/src/sashiny/_schema.py +18 -0
  10. sashiny-0.1.1/src/sashiny/app.py +60 -0
  11. sashiny-0.1.1/src/sashiny/collect.py +382 -0
  12. sashiny-0.1.1/src/sashiny/contract.py +322 -0
  13. sashiny-0.1.1/src/sashiny/engines/__init__.py +9 -0
  14. sashiny-0.1.1/src/sashiny/engines/base.py +68 -0
  15. sashiny-0.1.1/src/sashiny/engines/mock.py +157 -0
  16. sashiny-0.1.1/src/sashiny/engines/saspy.py +665 -0
  17. sashiny-0.1.1/src/sashiny/lint.py +30 -0
  18. sashiny-0.1.1/src/sashiny/modules.py +431 -0
  19. sashiny-0.1.1/src/sashiny/pool.py +184 -0
  20. sashiny-0.1.1/src/sashiny/py.typed +0 -0
  21. sashiny-0.1.1/src/sashiny/recording.py +93 -0
  22. sashiny-0.1.1/src/sashiny/result.py +93 -0
  23. sashiny-0.1.1/src/sashiny/run.py +49 -0
  24. sashiny-0.1.1/src/sashiny/upload.py +220 -0
  25. sashiny-0.1.1/src/sashiny/values.py +241 -0
  26. sashiny-0.1.1/src/sashiny/wrapper.py +89 -0
  27. sashiny-0.1.1/tests/demo_scenarios.py +167 -0
  28. sashiny-0.1.1/tests/fakesas.py +165 -0
  29. sashiny-0.1.1/tests/live/conftest.py +89 -0
  30. sashiny-0.1.1/tests/live/test_demo_live.py +136 -0
  31. sashiny-0.1.1/tests/test_app.py +31 -0
  32. sashiny-0.1.1/tests/test_collect.py +140 -0
  33. sashiny-0.1.1/tests/test_connect.py +60 -0
  34. sashiny-0.1.1/tests/test_contracts.py +54 -0
  35. sashiny-0.1.1/tests/test_demo.py +44 -0
  36. sashiny-0.1.1/tests/test_demo_scenarios.py +141 -0
  37. sashiny-0.1.1/tests/test_edge_cases.py +27 -0
  38. sashiny-0.1.1/tests/test_engine_mock.py +78 -0
  39. sashiny-0.1.1/tests/test_engine_saspy.py +48 -0
  40. sashiny-0.1.1/tests/test_engine_saspy_live.py +308 -0
  41. sashiny-0.1.1/tests/test_lint.py +17 -0
  42. sashiny-0.1.1/tests/test_module_client.py +117 -0
  43. sashiny-0.1.1/tests/test_module_render.py +148 -0
  44. sashiny-0.1.1/tests/test_modules.py +32 -0
  45. sashiny-0.1.1/tests/test_override.py +37 -0
  46. sashiny-0.1.1/tests/test_package.py +7 -0
  47. sashiny-0.1.1/tests/test_pool.py +76 -0
  48. sashiny-0.1.1/tests/test_run.py +30 -0
  49. sashiny-0.1.1/tests/test_upload.py +100 -0
  50. sashiny-0.1.1/tests/test_values.py +59 -0
  51. sashiny-0.1.1/tests/test_wrapper.py +44 -0
@@ -0,0 +1,35 @@
1
+ # R
2
+ .Rproj.user/
3
+ .Rhistory
4
+ .RData
5
+ .Ruserdata
6
+ *.Rcheck/
7
+ R/*.tar.gz
8
+ R/docs/
9
+ renv/library/
10
+ # Python
11
+ __pycache__/
12
+ *.py[cod]
13
+ .venv/
14
+ dist/
15
+ build/
16
+ *.egg-info/
17
+ .pytest_cache/
18
+ .mypy_cache/
19
+ .ruff_cache/
20
+ .coverage
21
+ htmlcov/
22
+ # SAS / secrets
23
+ sascfg_personal.py
24
+ *.authinfo
25
+ .Renviron
26
+ .env
27
+ # OS
28
+ .DS_Store
29
+
30
+ # testthat failure snapshots
31
+ R/tests/testthat/_problems/
32
+ R/tests/testthat/testthat-problems.rds
33
+
34
+ # Build artifacts at repo root
35
+ /SAShiny_*.tar.gz
@@ -0,0 +1,73 @@
1
+ # Changelog
2
+
3
+ All notable changes to the Python library are documented here. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project uses
5
+ [Semantic Versioning](https://semver.org/).
6
+
7
+ ## [0.1.1]
8
+
9
+ ### Fixed
10
+ - `import sashiny` no longer requires the optional `shiny` extra. `app` and
11
+ `modules` are imported lazily, so the core package works with only its
12
+ declared dependencies.
13
+ - SAS-literal values (quoted/dquoted text/choice, numeric, date, multichoice,
14
+ dataset, validated bare) are emitted without `%superq`, so `WHERE` clauses
15
+ work on real SAS 9.4 (issue #16). Only `raw` text/choice keeps `%superq`.
16
+
17
+ ### Fixed (SAS OnDemand for Academics)
18
+ - `SaspyEngine` submits `options notes;` once per new SAS session (spec 6.1).
19
+ ODA starts sessions with `NONOTES`, which removed the `NOTE:` sentinels, so
20
+ every run was reported as an error and the program log was empty.
21
+ - The SAS version is read from the `SXVER=` output line, not the source echo,
22
+ which servers like ODA include in the log (it was reported as `&sysvlong;`).
23
+
24
+ ## [0.1.0]
25
+
26
+ ### Added (live demo tests)
27
+ - Before starting saspy, `SaspyEngine` checks that Java is available for IOM
28
+ connections and that `~/.authinfo` has an entry for the profile's `authkey`
29
+ (`sashiny.engines.saspy.preflight`). Without the second check saspy would
30
+ prompt for credentials on stdin, which hangs a Shiny app.
31
+ - `tests/live` runs the demo scenarios (`examples/demo-scenarios.yml`) on real
32
+ SAS when `SASHINY_LIVE=1`; offline tests check the scenarios and any
33
+ committed recordings.
34
+
35
+ ### Added (live engine and result collection)
36
+ - `SaspyEngine` runs end to end: the session starts from a generated saspy
37
+ configuration file, persists across runs, and is restarted after a failure.
38
+ Dataset inputs are uploaded with `df2sd` (spec §7) from a user file or the
39
+ contract's sample. Every output type is collected per spec §8.2: tables (raw or
40
+ SAS-formatted, with metadata and row counts), plots, HTML, scoped logs, and
41
+ csv/xlsx/xpt/sas7bdat/rtf/pdf downloads. A failing output becomes
42
+ `{"error": ...}` without affecting the others (`metadata.collect_errors`).
43
+ - `choices_from` inputs read their choices from SAS at session start (§6.4).
44
+ - Recordings (§8.3): `SaspyEngine(record_to=...)` / `connect(..., record_to=...)`
45
+ save each run; `MockEngine` replays them with the shared R/Python key and
46
+ reports `metadata.recording` as `"replayed"` or `"missing"`.
47
+ - `sashiny.collect`, `sashiny.upload` and `sashiny.recording` modules;
48
+ `UploadFile`, `UploadError`, `load_recording` and `save_recording` exports.
49
+ - Shiny modules render one card per contract output, apply contract defaults,
50
+ convert Shiny values to the contract JSON form, support file uploads with a
51
+ "use the sample" toggle, and offer downloads.
52
+ - `Pool` accepts an engine factory (one SAS session per pooled session), is an
53
+ `Engine` itself, closes discarded sessions, and keeps sessions on input
54
+ validation errors.
55
+ - Demo app: live profiles (ODA, Viya, SAS 9.4) with automatic offline fallback.
56
+
57
+ ### Changed
58
+ - Output values in `Result.outputs` are the language-neutral JSON values of spec
59
+ §8.1 (`TableResult` and `LogLine` remain exported for compatibility).
60
+ - `uploads=` accepts file paths, `UploadFile` objects or `True` (sample).
61
+
62
+ ### Fixed
63
+ - Result metadata `contract_sha256` is now the SHA-256 of the contract YAML bytes
64
+ (spec §8); previously it hashed the SAS program. `Contract` gains a `path` field.
65
+
66
+ ### Added
67
+ - Contract loader and validator (`sashiny.contract`).
68
+ - Value validation and rendering (`sashiny.values`).
69
+ - Generated SAS wrapper (`sashiny.wrapper`).
70
+ - Mock engine with record/replay and saspy engine with connection selection
71
+ (`sashiny.engines`).
72
+ - Bounded session pool (`sashiny.pool`), runner (`sashiny.run`), result object
73
+ (`sashiny.result`), and Shiny modules (`sashiny.modules`).
sashiny-0.1.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mehar Pratap Singh
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.
sashiny-0.1.1/PKG-INFO ADDED
@@ -0,0 +1,57 @@
1
+ Metadata-Version: 2.5
2
+ Name: sashiny
3
+ Version: 0.1.1
4
+ Summary: Use unchanged SAS programs as the server of Shiny applications.
5
+ Project-URL: Homepage, https://github.com/procogia/SAShiny
6
+ Project-URL: Source, https://github.com/procogia/SAShiny/tree/main/Python
7
+ Project-URL: Issues, https://github.com/procogia/SAShiny/issues
8
+ Author-email: Mehar Pratap Singh <meharpsingh@gmail.com>
9
+ Maintainer: Shreya Sharma, Love ProCogia, Igor ProCogia, Ahmer Khan
10
+ Maintainer-email: Mehar Pratap Singh <meharpsingh@gmail.com>
11
+ License-Expression: MIT
12
+ License-File: LICENSE
13
+ Keywords: aml,clinical,dashboard,sas,saspy,shiny,viya
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: Science/Research
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3 :: Only
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
25
+ Classifier: Typing :: Typed
26
+ Requires-Python: >=3.10
27
+ Requires-Dist: jsonschema>=4.18
28
+ Requires-Dist: pyyaml>=6.0
29
+ Provides-Extra: dev
30
+ Requires-Dist: mypy>=1.13; extra == 'dev'
31
+ Requires-Dist: pytest-cov>=5; extra == 'dev'
32
+ Requires-Dist: pytest>=8; extra == 'dev'
33
+ Requires-Dist: ruff>=0.8; extra == 'dev'
34
+ Provides-Extra: saspy
35
+ Requires-Dist: saspy>=5.100; extra == 'saspy'
36
+ Provides-Extra: shiny
37
+ Requires-Dist: shiny>=1.0; extra == 'shiny'
38
+ Provides-Extra: upload
39
+ Requires-Dist: openpyxl>=3.1; extra == 'upload'
40
+ Requires-Dist: pandas>=2.0; extra == 'upload'
41
+ Requires-Dist: pyreadstat>=1.2; extra == 'upload'
42
+ Description-Content-Type: text/markdown
43
+
44
+ # SAShiny (Python)
45
+
46
+ Python library for SAShiny. Use an unchanged SAS program as the server of a Shiny for Python app.
47
+
48
+ > Status: pre-alpha. The contract is specified in
49
+ > [`spec/CONTRACT.md`](https://github.com/procogia/SAShiny/blob/main/spec/CONTRACT.md).
50
+
51
+ ```sh
52
+ # development version (repository is private until the first release)
53
+ uv pip install "git+https://github.com/procogia/SAShiny#subdirectory=Python"
54
+ ```
55
+
56
+ SAS is a registered trademark of SAS Institute Inc. Shiny is a registered trademark of Posit
57
+ Software, PBC. This project is not affiliated with or endorsed by either company.
@@ -0,0 +1,14 @@
1
+ # SAShiny (Python)
2
+
3
+ Python library for SAShiny. Use an unchanged SAS program as the server of a Shiny for Python app.
4
+
5
+ > Status: pre-alpha. The contract is specified in
6
+ > [`spec/CONTRACT.md`](https://github.com/procogia/SAShiny/blob/main/spec/CONTRACT.md).
7
+
8
+ ```sh
9
+ # development version (repository is private until the first release)
10
+ uv pip install "git+https://github.com/procogia/SAShiny#subdirectory=Python"
11
+ ```
12
+
13
+ SAS is a registered trademark of SAS Institute Inc. Shiny is a registered trademark of Posit
14
+ Software, PBC. This project is not affiliated with or endorsed by either company.
@@ -0,0 +1,98 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.27"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "sashiny"
7
+ dynamic = ["version"]
8
+ description = "Use unchanged SAS programs as the server of Shiny applications."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ authors = [{ name = "Mehar Pratap Singh", email = "meharpsingh@gmail.com" }]
14
+ maintainers = [
15
+ { name = "Mehar Pratap Singh", email = "meharpsingh@gmail.com" },
16
+ { name = "Shreya Sharma" },
17
+ { name = "Love ProCogia" },
18
+ { name = "Igor ProCogia" },
19
+ { name = "Ahmer Khan" },
20
+ ]
21
+ keywords = ["sas", "shiny", "saspy", "viya", "dashboard", "clinical", "aml"]
22
+ classifiers = [
23
+ "Development Status :: 4 - Beta",
24
+ "Intended Audience :: Developers",
25
+ "Intended Audience :: Science/Research",
26
+ "Operating System :: OS Independent",
27
+ "Programming Language :: Python :: 3",
28
+ "Programming Language :: Python :: 3 :: Only",
29
+ "Programming Language :: Python :: 3.10",
30
+ "Programming Language :: Python :: 3.11",
31
+ "Programming Language :: Python :: 3.12",
32
+ "Programming Language :: Python :: 3.13",
33
+ "Topic :: Scientific/Engineering :: Information Analysis",
34
+ "Typing :: Typed",
35
+ ]
36
+ dependencies = [
37
+ "jsonschema>=4.18",
38
+ "pyyaml>=6.0",
39
+ ]
40
+
41
+ [project.optional-dependencies]
42
+ saspy = ["saspy>=5.100"]
43
+ shiny = ["shiny>=1.0"]
44
+ upload = ["pandas>=2.0", "openpyxl>=3.1", "pyreadstat>=1.2"]
45
+ dev = ["pytest>=8", "pytest-cov>=5", "ruff>=0.8", "mypy>=1.13"]
46
+
47
+ [project.urls]
48
+ Homepage = "https://github.com/procogia/SAShiny"
49
+ Source = "https://github.com/procogia/SAShiny/tree/main/Python"
50
+ Issues = "https://github.com/procogia/SAShiny/issues"
51
+
52
+ [dependency-groups]
53
+ dev = [
54
+ "pytest>=8",
55
+ "pytest-cov>=5",
56
+ "ruff>=0.8",
57
+ "mypy>=1.13",
58
+ "shiny>=1.9.0",
59
+ "pandas>=2.0",
60
+ "openpyxl>=3.1",
61
+ "pyreadstat>=1.2",
62
+ ]
63
+
64
+ [tool.hatch.version]
65
+ path = "src/sashiny/__init__.py"
66
+
67
+ [tool.hatch.build.targets.wheel]
68
+ packages = ["src/sashiny"]
69
+
70
+ [tool.hatch.build.targets.sdist]
71
+ include = ["src/sashiny", "tests", "README.md", "LICENSE", "CHANGELOG.md"]
72
+
73
+ [tool.ruff]
74
+ line-length = 100
75
+ target-version = "py310"
76
+ src = ["src", "tests"]
77
+
78
+ [tool.ruff.lint]
79
+ select = ["E", "W", "F", "I", "UP", "B", "SIM", "C4", "RUF", "D", "S", "PT", "PL"]
80
+ ignore = ["D203", "D213"]
81
+
82
+ [tool.ruff.lint.per-file-ignores]
83
+ "tests/**" = ["D", "S101", "PLR2004"]
84
+
85
+ [tool.mypy]
86
+ python_version = "3.10"
87
+ strict = true
88
+ files = ["src"]
89
+
90
+ [[tool.mypy.overrides]]
91
+ module = ["yaml", "jsonschema", "saspy", "pandas"]
92
+ ignore_missing_imports = true
93
+
94
+ [tool.pytest.ini_options]
95
+ testpaths = ["tests"]
96
+ pythonpath = ["tests"]
97
+ addopts = ["--strict-markers", "--strict-config", "-ra"]
98
+ markers = ["live: needs a real SAS session (SASHINY_LIVE=1); see tests/live/conftest.py"]
@@ -0,0 +1,68 @@
1
+ """SAShiny: use unchanged SAS programs as the server of Shiny applications.
2
+
3
+ SAS is a registered trademark of SAS Institute Inc. Shiny is a registered
4
+ trademark of Posit Software, PBC. This project is not affiliated with or
5
+ endorsed by either company.
6
+ """
7
+
8
+ from typing import Any
9
+
10
+ from .contract import Contract, Issue, load, validate
11
+ from .engines import Engine, MockEngine, SaspyEngine, connect, load_profiles
12
+ from .lint import lint
13
+ from .pool import Pool
14
+ from .recording import load_recording, save_recording
15
+ from .result import LogLine, Result, TableResult
16
+ from .run import run
17
+ from .upload import UploadError, UploadFile
18
+ from .values import render_values
19
+ from .wrapper import reset_code, wrapper_code
20
+
21
+ __all__ = [
22
+ "Contract",
23
+ "Engine",
24
+ "Issue",
25
+ "LogLine",
26
+ "MockEngine",
27
+ "Pool",
28
+ "Result",
29
+ "SaspyEngine",
30
+ "TableResult",
31
+ "UploadError",
32
+ "UploadFile",
33
+ "__version__",
34
+ "app",
35
+ "connect",
36
+ "lint",
37
+ "load",
38
+ "load_profiles",
39
+ "load_recording",
40
+ "render_values",
41
+ "reset_code",
42
+ "run",
43
+ "save_recording",
44
+ "validate",
45
+ "wrapper_code",
46
+ ]
47
+
48
+ __version__ = "0.1.1"
49
+
50
+
51
+ def __getattr__(name: str) -> Any:
52
+ """Lazily expose ``app`` and ``modules``, which need the optional ``shiny``.
53
+
54
+ The core package must import without ``shiny`` installed (it is an optional
55
+ extra). ``app`` and ``modules`` are only imported when first accessed.
56
+ """
57
+ if name == "app":
58
+ from .app import app as _app # noqa: PLC0415 - optional dependency
59
+
60
+ globals()["app"] = _app
61
+ return _app
62
+ if name == "modules":
63
+ from importlib import import_module # noqa: PLC0415 - optional dependency
64
+
65
+ _modules = import_module(f"{__name__}.modules")
66
+ globals()["modules"] = _modules
67
+ return _modules
68
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")