pathling 9.7.1.dev0__py3-none-any.whl → 9.8.0.dev0__py3-none-any.whl

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 (43) hide show
  1. pathling/__init__.py +108 -39
  2. pathling/_spark_defaults.py +81 -0
  3. pathling/_version.py +2 -2
  4. pathling/cli/__init__.py +27 -0
  5. pathling/cli/config.py +542 -0
  6. pathling/cli/console.py +82 -0
  7. pathling/cli/convert.py +154 -0
  8. pathling/cli/departition.py +145 -0
  9. pathling/cli/errors.py +182 -0
  10. pathling/cli/export.py +256 -0
  11. pathling/cli/fhirpath.py +249 -0
  12. pathling/cli/io.py +263 -0
  13. pathling/cli/main.py +217 -0
  14. pathling/cli/render.py +456 -0
  15. pathling/cli/resources/quiet-log4j2.properties +7 -0
  16. pathling/cli/run.py +263 -0
  17. pathling/cli/session.py +174 -0
  18. pathling/cli/sparkconf.py +269 -0
  19. pathling/cli/terminology.py +814 -0
  20. pathling/cli/view.py +153 -0
  21. pathling/context.py +37 -26
  22. {pathling-9.7.1.dev0.dist-info → pathling-9.8.0.dev0.dist-info}/METADATA +55 -12
  23. pathling-9.8.0.dev0.dist-info/RECORD +51 -0
  24. pathling-9.8.0.dev0.dist-info/entry_points.txt +2 -0
  25. {pathling-9.7.1.dev0.dist-info → pathling-9.8.0.dev0.dist-info}/licenses/LICENSE +4 -4
  26. pathling-9.7.1.dev0.dist-info/RECORD +0 -32
  27. {pathling-9.7.1.dev0.data → pathling-9.8.0.dev0.data}/data/share/pathling/examples/bulk.py +0 -0
  28. {pathling-9.7.1.dev0.data → pathling-9.8.0.dev0.data}/data/share/pathling/examples/data/bundles/Bennett146_Swaniawski813_704c9750-f6e6-473b-ee83-fbd48e07fe3f.json +0 -0
  29. {pathling-9.7.1.dev0.data → pathling-9.8.0.dev0.data}/data/share/pathling/examples/data/bundles/Dino214_Parisian75_40d82b80-b682-cd8b-da6d-396809878641.json +0 -0
  30. {pathling-9.7.1.dev0.data → pathling-9.8.0.dev0.data}/data/share/pathling/examples/data/csv/conditions.csv +0 -0
  31. {pathling-9.7.1.dev0.data → pathling-9.8.0.dev0.data}/data/share/pathling/examples/data/resources/Condition.ndjson +0 -0
  32. {pathling-9.7.1.dev0.data → pathling-9.8.0.dev0.data}/data/share/pathling/examples/data/resources/Patient.ndjson +0 -0
  33. {pathling-9.7.1.dev0.data → pathling-9.8.0.dev0.data}/data/share/pathling/examples/designation.py +0 -0
  34. {pathling-9.7.1.dev0.data → pathling-9.8.0.dev0.data}/data/share/pathling/examples/display.py +0 -0
  35. {pathling-9.7.1.dev0.data → pathling-9.8.0.dev0.data}/data/share/pathling/examples/encode_bundles.py +0 -0
  36. {pathling-9.7.1.dev0.data → pathling-9.8.0.dev0.data}/data/share/pathling/examples/encode_resources.py +0 -0
  37. {pathling-9.7.1.dev0.data → pathling-9.8.0.dev0.data}/data/share/pathling/examples/fhir_search.py +0 -0
  38. {pathling-9.7.1.dev0.data → pathling-9.8.0.dev0.data}/data/share/pathling/examples/fhir_view.py +0 -0
  39. {pathling-9.7.1.dev0.data → pathling-9.8.0.dev0.data}/data/share/pathling/examples/member_of.py +0 -0
  40. {pathling-9.7.1.dev0.data → pathling-9.8.0.dev0.data}/data/share/pathling/examples/property_of.py +0 -0
  41. {pathling-9.7.1.dev0.data → pathling-9.8.0.dev0.data}/data/share/pathling/examples/subsumes.py +0 -0
  42. {pathling-9.7.1.dev0.data → pathling-9.8.0.dev0.data}/data/share/pathling/examples/translate.py +0 -0
  43. {pathling-9.7.1.dev0.dist-info → pathling-9.8.0.dev0.dist-info}/WHEEL +0 -0
pathling/__init__.py CHANGED
@@ -15,44 +15,113 @@
15
15
  # limitations under the License.
16
16
  #
17
17
 
18
- from .coding import Coding
19
- from .context import PathlingContext, StorageType
20
- from .core import Expression, VariableExpression
21
- from .datasource import DataSource, DataSources
22
- from .fhir import MimeType, Version
23
- from .functions import to_coding, to_ecl_value_set, to_snomed_coding
24
- from .udfs import (
25
- Equivalence,
26
- PropertyType,
27
- designation,
28
- display,
29
- member_of,
30
- property_of,
31
- subsumed_by,
32
- subsumes,
33
- translate,
18
+ """Python API for Pathling.
19
+
20
+ Public names are exposed lazily (PEP 562) so that importing the ``pathling``
21
+ package itself does not pull in PySpark and the JVM-backed submodules. The
22
+ heavy imports happen only when a public name is first accessed, which keeps the
23
+ command line interface's ``--help`` and ``--version`` paths fast.
24
+
25
+ Author: John Grimes.
26
+ """
27
+
28
+ # The TYPE_CHECKING imports below exist only so that type checkers and IDEs can
29
+ # resolve the lazily-exported public names; they are intentionally unused at
30
+ # runtime, so unused-import checks are disabled for this re-export shim.
31
+ # ruff: noqa: F401
32
+
33
+ import importlib
34
+ from typing import TYPE_CHECKING, Any
35
+
36
+ if TYPE_CHECKING:
37
+ from .coding import Coding
38
+ from .context import PathlingContext, StorageType
39
+ from .core import Expression, VariableExpression
40
+ from .datasource import DataSource, DataSources
41
+ from .fhir import MimeType, Version
42
+ from .functions import to_coding, to_ecl_value_set, to_snomed_coding
43
+ from .udfs import (
44
+ Equivalence,
45
+ PropertyType,
46
+ designation,
47
+ display,
48
+ member_of,
49
+ property_of,
50
+ subsumed_by,
51
+ subsumes,
52
+ translate,
53
+ )
54
+
55
+ # Maps each lazily-exported public name to the submodule that defines it.
56
+ _LAZY_EXPORTS = {
57
+ "Coding": "pathling.coding",
58
+ "PathlingContext": "pathling.context",
59
+ "StorageType": "pathling.context",
60
+ "Expression": "pathling.core",
61
+ "VariableExpression": "pathling.core",
62
+ "DataSource": "pathling.datasource",
63
+ "DataSources": "pathling.datasource",
64
+ "MimeType": "pathling.fhir",
65
+ "Version": "pathling.fhir",
66
+ "to_coding": "pathling.functions",
67
+ "to_snomed_coding": "pathling.functions",
68
+ "to_ecl_value_set": "pathling.functions",
69
+ "member_of": "pathling.udfs",
70
+ "translate": "pathling.udfs",
71
+ "subsumes": "pathling.udfs",
72
+ "subsumed_by": "pathling.udfs",
73
+ "property_of": "pathling.udfs",
74
+ "display": "pathling.udfs",
75
+ "designation": "pathling.udfs",
76
+ "PropertyType": "pathling.udfs",
77
+ "Equivalence": "pathling.udfs",
78
+ }
79
+
80
+ __all__ = list(_LAZY_EXPORTS)
81
+
82
+ # The package submodules that may be accessed lazily after a bare
83
+ # ``import pathling`` (e.g. ``pathling.udfs.member_of``). This curated allow-list
84
+ # keeps the fallback safe - unknown names still raise ``AttributeError`` - and
85
+ # restores the pre-shim behaviour where these submodules were importable as
86
+ # package attributes, without importing PySpark on a bare ``import pathling``.
87
+ _LAZY_SUBMODULES = (
88
+ "coding",
89
+ "context",
90
+ "core",
91
+ "datasource",
92
+ "fhir",
93
+ "functions",
94
+ "udfs",
34
95
  )
35
96
 
36
- __all__ = [
37
- "PathlingContext",
38
- "StorageType",
39
- "MimeType",
40
- "Version",
41
- "Coding",
42
- "member_of",
43
- "translate",
44
- "subsumes",
45
- "subsumed_by",
46
- "property_of",
47
- "display",
48
- "designation",
49
- "PropertyType",
50
- "Equivalence",
51
- "to_coding",
52
- "to_snomed_coding",
53
- "to_ecl_value_set",
54
- "Expression",
55
- "VariableExpression",
56
- "DataSources",
57
- "DataSource",
58
- ]
97
+
98
+ def __getattr__(name: str) -> Any:
99
+ """Resolves a public name or submodule by importing it on first access.
100
+
101
+ :param name: the attribute being accessed on the ``pathling`` package.
102
+ :return: the resolved attribute value.
103
+ :raises AttributeError: if the name is neither a known public export nor a
104
+ known package submodule.
105
+ """
106
+ module_name = _LAZY_EXPORTS.get(name)
107
+ if module_name is not None:
108
+ module = importlib.import_module(module_name)
109
+ value = getattr(module, name)
110
+ # Cache on the package so subsequent lookups bypass this hook.
111
+ globals()[name] = value
112
+ return value
113
+ if name in _LAZY_SUBMODULES:
114
+ submodule = importlib.import_module(f"{__name__}.{name}")
115
+ # Cache the submodule so subsequent lookups bypass this hook.
116
+ globals()[name] = submodule
117
+ return submodule
118
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
119
+
120
+
121
+ def __dir__() -> list:
122
+ """Returns the public names and submodules of the package for introspection.
123
+
124
+ :return: the sorted list of public export names and lazily-available
125
+ submodule names.
126
+ """
127
+ return sorted(set(__all__) | set(_LAZY_SUBMODULES))
@@ -0,0 +1,81 @@
1
+ #
2
+ # Copyright © 2018-2026 Commonwealth Scientific and Industrial Research
3
+ # Organisation (CSIRO) ABN 41 687 119 230.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ """The single, PySpark-free source of truth for Pathling's managed Spark defaults.
19
+
20
+ The managed coordinates, the Delta SQL extension, and the Delta catalog that
21
+ every Pathling Spark session requires are defined here, built from the versions
22
+ in :mod:`pathling._version`. Both the session builder
23
+ (:func:`pathling.context._build_spark_session`) and the CLI merge logic
24
+ (:mod:`pathling.cli.sparkconf`) import these values so the two cannot drift
25
+ apart. This module deliberately imports no PySpark, so the CLI configuration
26
+ path can reference the defaults without paying Spark's import cost.
27
+
28
+ Author: John Grimes.
29
+ """
30
+
31
+ from pathling._version import (
32
+ __delta_version__,
33
+ __java_version__,
34
+ __scala_version__,
35
+ )
36
+
37
+ # The Spark configuration key holding the comma-separated Maven coordinates.
38
+ PACKAGES_KEY = "spark.jars.packages"
39
+
40
+ # The Spark configuration key holding the comma-separated SQL extension classes.
41
+ EXTENSIONS_KEY = "spark.sql.extensions"
42
+
43
+ # The Spark configuration key for the session catalog implementation.
44
+ CATALOG_KEY = "spark.sql.catalog.spark_catalog"
45
+
46
+ # The managed Maven coordinate (group:artifact) for the Pathling library runtime.
47
+ LIBRARY_RUNTIME_COORDINATE = "au.csiro.pathling:library-runtime"
48
+
49
+ # The managed Maven coordinate (group:artifact) for Delta Lake, which carries the
50
+ # Scala binary version in its artifact identifier.
51
+ DELTA_COORDINATE = f"io.delta:delta-spark_{__scala_version__}"
52
+
53
+ # The group:artifact identities of the coordinates Pathling manages, used to
54
+ # detect a user-supplied override at a different version.
55
+ MANAGED_COORDINATES = frozenset({LIBRARY_RUNTIME_COORDINATE, DELTA_COORDINATE})
56
+
57
+ # The Delta SQL extension class that Pathling always requires.
58
+ DELTA_EXTENSION = "io.delta.sql.DeltaSparkSessionExtension"
59
+
60
+ # The Delta catalog implementation that Pathling always requires.
61
+ DELTA_CATALOG = "org.apache.spark.sql.delta.catalog.DeltaCatalog"
62
+
63
+
64
+ def managed_spark_defaults() -> dict:
65
+ """Returns the Spark configuration that Pathling always requires.
66
+
67
+ The packages string lists both managed coordinates at the versions declared
68
+ in :mod:`pathling._version` and retains a trailing comma, matching the
69
+ historical inline literal. The extension and catalog are fixed Delta class
70
+ names.
71
+
72
+ :return: a mapping of managed Spark configuration key to value.
73
+ """
74
+ return {
75
+ PACKAGES_KEY: (
76
+ f"{LIBRARY_RUNTIME_COORDINATE}:{__java_version__},"
77
+ f"{DELTA_COORDINATE}:{__delta_version__},"
78
+ ),
79
+ EXTENSIONS_KEY: DELTA_EXTENSION,
80
+ CATALOG_KEY: DELTA_CATALOG,
81
+ }
pathling/_version.py CHANGED
@@ -2,8 +2,8 @@
2
2
  # Auto generated from POM project version.
3
3
  # Please do not modify.
4
4
  #
5
- __version__="9.7.1.dev0"
6
- __java_version__="9.7.1-SNAPSHOT"
5
+ __version__="9.8.0.dev0"
6
+ __java_version__="9.8.0-SNAPSHOT"
7
7
  __scala_version__="2.13"
8
8
  __delta_version__="4.0.0"
9
9
  __hadoop_version__="3.4.1"
@@ -0,0 +1,27 @@
1
+ #
2
+ # Copyright © 2018-2026 Commonwealth Scientific and Industrial Research
3
+ # Organisation (CSIRO) ABN 41 687 119 230.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ """Command line interface for Pathling.
19
+
20
+ This subpackage exposes the Pathling Python library through a flat, verb-based
21
+ command tree installed as the ``pathling`` console script. Modules are kept
22
+ free of eager PySpark imports so that ``--help`` and ``--version`` remain fast;
23
+ the Spark session is created lazily by :mod:`pathling.cli.session` only when a
24
+ command needs it.
25
+
26
+ Author: John Grimes.
27
+ """