packflow 0.3.0__tar.gz → 0.3.1rc2__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 (40) hide show
  1. {packflow-0.3.0 → packflow-0.3.1rc2}/PKG-INFO +33 -49
  2. {packflow-0.3.0 → packflow-0.3.1rc2}/README.md +24 -45
  3. {packflow-0.3.0 → packflow-0.3.1rc2}/pyproject.toml +18 -1
  4. {packflow-0.3.0 → packflow-0.3.1rc2}/src/packflow/backend/configuration.py +1 -0
  5. {packflow-0.3.0 → packflow-0.3.1rc2}/src/packflow/backend/preprocessors.py +127 -22
  6. {packflow-0.3.0 → packflow-0.3.1rc2}/src/packflow/cli.py +6 -0
  7. packflow-0.3.1rc2/src/packflow/data/templates/minimal/README.md +22 -0
  8. packflow-0.3.1rc2/src/packflow/data/templates/minimal/test_inference.py +28 -0
  9. packflow-0.3.1rc2/src/packflow/data/templates/minimal/validate.py +30 -0
  10. {packflow-0.3.0 → packflow-0.3.1rc2}/src/packflow/loaders/config.py +26 -0
  11. packflow-0.3.1rc2/src/packflow/logger.py +11 -0
  12. {packflow-0.3.0 → packflow-0.3.1rc2}/src/packflow/project.py +23 -3
  13. packflow-0.3.1rc2/src/packflow/utils/__init__.py +10 -0
  14. {packflow-0.3.0 → packflow-0.3.1rc2}/src/packflow/utils/data.py +99 -0
  15. packflow-0.3.0/src/packflow/data/templates/minimal/README.md +0 -0
  16. packflow-0.3.0/src/packflow/data/templates/minimal/validate.py +0 -25
  17. packflow-0.3.0/src/packflow/logger.py +0 -5
  18. packflow-0.3.0/src/packflow/utils/__init__.py +0 -2
  19. {packflow-0.3.0 → packflow-0.3.1rc2}/LICENSE +0 -0
  20. {packflow-0.3.0 → packflow-0.3.1rc2}/src/packflow/__init__.py +0 -0
  21. {packflow-0.3.0 → packflow-0.3.1rc2}/src/packflow/backend/__init__.py +0 -0
  22. {packflow-0.3.0 → packflow-0.3.1rc2}/src/packflow/backend/base.py +0 -0
  23. {packflow-0.3.0 → packflow-0.3.1rc2}/src/packflow/backend/metrics.py +0 -0
  24. {packflow-0.3.0 → packflow-0.3.1rc2}/src/packflow/backend/validation.py +0 -0
  25. {packflow-0.3.0 → packflow-0.3.1rc2}/src/packflow/constants.py +0 -0
  26. {packflow-0.3.0 → packflow-0.3.1rc2}/src/packflow/data/templates/minimal/LICENSE.txt +0 -0
  27. {packflow-0.3.0 → packflow-0.3.1rc2}/src/packflow/data/templates/minimal/MODEL_CARD.md +0 -0
  28. {packflow-0.3.0 → packflow-0.3.1rc2}/src/packflow/data/templates/minimal/inference.py +0 -0
  29. {packflow-0.3.0 → packflow-0.3.1rc2}/src/packflow/data/templates/minimal/packflow.yaml +0 -0
  30. {packflow-0.3.0 → packflow-0.3.1rc2}/src/packflow/data/templates/minimal/requirements.txt +0 -0
  31. {packflow-0.3.0 → packflow-0.3.1rc2}/src/packflow/exceptions.py +0 -0
  32. {packflow-0.3.0 → packflow-0.3.1rc2}/src/packflow/loaders/__init__.py +0 -0
  33. {packflow-0.3.0 → packflow-0.3.1rc2}/src/packflow/loaders/base.py +0 -0
  34. {packflow-0.3.0 → packflow-0.3.1rc2}/src/packflow/loaders/local.py +0 -0
  35. {packflow-0.3.0 → packflow-0.3.1rc2}/src/packflow/loaders/module.py +0 -0
  36. {packflow-0.3.0 → packflow-0.3.1rc2}/src/packflow/loaders/utils.py +0 -0
  37. {packflow-0.3.0 → packflow-0.3.1rc2}/src/packflow/utils/normalize/__init__.py +0 -0
  38. {packflow-0.3.0 → packflow-0.3.1rc2}/src/packflow/utils/normalize/base.py +0 -0
  39. {packflow-0.3.0 → packflow-0.3.1rc2}/src/packflow/utils/normalize/handlers.py +0 -0
  40. {packflow-0.3.0 → packflow-0.3.1rc2}/src/packflow/utils/normalize/normalize.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: packflow
3
- Version: 0.3.0
3
+ Version: 0.3.1rc2
4
4
  Summary: AI/ML inference SDK for streaming data
5
5
  License: MIT License
6
6
 
@@ -18,13 +18,18 @@ Author-email: osd.pentagon.cdao.mbx.perceptor-program-members@mail.mil
18
18
  Maintainer: CDAO Models as a Service
19
19
  Maintainer-email: osd.pentagon.cdao.mbx.perceptor-program-members@mail.mil
20
20
  Requires-Python: >=3.10
21
- Classifier: License :: Other/Proprietary License
21
+ Classifier: Development Status :: 4 - Beta
22
+ Classifier: Intended Audience :: Developers
23
+ Classifier: Intended Audience :: Science/Research
24
+ Classifier: License :: OSI Approved :: MIT License
25
+ Classifier: Operating System :: OS Independent
22
26
  Classifier: Programming Language :: Python :: 3
23
27
  Classifier: Programming Language :: Python :: 3.10
24
28
  Classifier: Programming Language :: Python :: 3.11
25
29
  Classifier: Programming Language :: Python :: 3.12
26
- Classifier: Programming Language :: Python :: 3.13
27
- Classifier: Programming Language :: Python :: 3.14
30
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
31
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
32
+ Classifier: Topic :: System :: Distributed Computing
28
33
  Requires-Dist: PyYaml
29
34
  Requires-Dist: click (>=8.0.0)
30
35
  Requires-Dist: deepmerge (>=2.0,<3.0)
@@ -37,14 +42,22 @@ Project-URL: Homepage, https://github.com/dow-cdao/packflow
37
42
  Project-URL: Repository, https://github.com/dow-cdao/packflow
38
43
  Description-Content-Type: text/markdown
39
44
 
40
- <h1 style="text-align: center; border-bottom: none !important;">
41
- <img src="assets/packflow-logo-white-text.png" width="500" alt="Packflow logo">
45
+ <h1 align="center" style="text-align: center; border-bottom: none !important;">
46
+ <picture>
47
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/dow-cdao/packflow/master/assets/packflow-logo-dark.png">
48
+ <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/dow-cdao/packflow/master/assets/packflow-logo-light.png">
49
+ <img src="https://raw.githubusercontent.com/dow-cdao/packflow/master/assets/packflow-logo-dark.png" width="500" alt="Packflow logo">
50
+ </picture>
42
51
  </h1>
43
52
 
44
53
  <p align="center">
45
- <a href="https://pypi.org/project/packflow/"><img alt="PyPI - Version" src="https://img.shields.io/pypi/v/packflow.svg"></a>
46
- <a href="https://pypi.org/project/packflow/"><img alt="PyPI - Python Version" src="https://img.shields.io/pypi/pyversions/packflow.svg"></a>
47
- <a href="https://github.com/dow-cdao/packflow/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/badge/License-MIT-blue.svg"></a>
54
+ <a href="https://pypi.org/project/packflow/"><img alt="Packflow on PyPI - Version" src="https://img.shields.io/pypi/v/packflow">
55
+ </a>
56
+ <a href="https://pypi.org/project/packflow/"><img alt="Packflow on PyPI - Python Versions" src="https://img.shields.io/pypi/pyversions/packflow">
57
+ </a>
58
+ <a href="https://github.com/dow-cdao/packflow/blob/master/LICENSE">
59
+ <img alt="Packflow on GitHub - License" src="https://img.shields.io/github/license/dow-cdao/packflow">
60
+ </a>
48
61
  </p>
49
62
 
50
63
  # Introduction
@@ -52,6 +65,8 @@ Description-Content-Type: text/markdown
52
65
  `packflow` is a software development kit (SDK) that simplifies the development process and standardizes packaging of AI/ML
53
66
  running on streaming data sources.
54
67
 
68
+ **What does Packflow do?** Packflow provides a framework for *writing*, *running*, and *packaging* inference code. It offers a standardized structure (the `InferenceBackend` class) for writing model execution logic, provides the runtime backbone that executes models with built-in profiling and preprocessing, and includes tools to bundle code into portable zip archives. This means you write your inference code once using Packflow's structure, and Packflow handles both the optimized execution and creation of shareable packages for transfer between systems.
69
+
55
70
  Many existing packaging frameworks are catered towards inference APIs and often require custom preprocessing steps. This can be particularly challenging when dealing with data sources that typically generate data one row at a time in key-value pairs (e.g., firewall logs or message streams).
56
71
 
57
72
  Packflow, however, is optimized to run models on either individual events or batches of events, streamlining development and reducing the need for additional preprocessing. By leveraging Packflow, teams can focus on building and deploying models with custom out-of-the-box workflows and utilities, significantly reducing the time and effort required to onboard new capabilities.
@@ -74,47 +89,19 @@ The following instructions quickly walk through how to install Packflow and serv
74
89
  pip install packflow
75
90
  ```
76
91
 
77
- from the root of the Packflow repo.
78
-
79
92
  > [!NOTE]
80
93
  > If contributing to Packflow, it is recommended to install `packflow` from source in editable mode: `pip install -e .`
81
94
 
82
- ## Packflow Documentation
83
-
84
- Packflow documentation is available pre-built in the repository and can be viewed immediately, or built from source for development work. Follow the instructions below to get started with serving the documentation.
85
-
86
- ### Viewing Pre-built Documentation
87
-
88
- The simplest way to view the Packflow documentation is to serve the pre-built HTML files included in the repository:
89
-
90
- 1. Navigate to the pre-built docs folder: `cd docs/built/html`
91
- 2. Start a local web server: `python -m http.server 8000`
92
- 3. Access the documentation in a web browser by navigating to [http://127.0.0.1:8000/](http://127.0.0.1:8000/)
93
-
94
- > [!WARNING]
95
- > If a "Not Found" error page is received when first accessing the documentation, wait a moment for the server to fully start and refresh the page.
95
+ ## Documentation
96
96
 
97
- ### Building Documentation from Source
97
+ Packflow documentation is hosted at **[https://dow-cdao.github.io/packflow/](https://dow-cdao.github.io/packflow/)**. Pre-built HTML is also available on the [`gh-pages`](https://github.com/dow-cdao/packflow/tree/gh-pages) branch.
98
98
 
99
- #### Prerequisite Requirements
100
-
101
- The following are required to build documentation from source:
102
-
103
- - **Python** (version 3.10+)
104
- - **Pip**
105
- - **Packflow** (the version corresponding to the docs being served)
106
- - **Pandoc**[^1] (see Pandoc.org's [official installation instructions](https://pandoc.org/installing.html))
107
- - **`make` Command**[^2]
99
+ To build and serve documentation locally:
108
100
 
109
- #### Steps
110
-
111
- 1. Navigate to the docs folder: `cd docs`
112
- 2. Install Python dependencies for building and hosting the documentation: `pip install -r requirements.txt`
113
- 3. Run `make dev` to serve the documentation from a working tree with live updates, or `make prod-serve` to serve static multi-version documentation (requires `.git` directory with branch/tag history)
114
- 4. Access the built documentation in a web browser by navigating to [http://127.0.0.1:8000/](http://127.0.0.1:8000/)
115
-
116
- > [!WARNING]
117
- > If a "Not Found" error page is received when first accessing the documentation, wait a moment for the server to fully start and refresh the page.
101
+ 1. Install system prerequisites: [**Pandoc**](https://pandoc.org/installing.html) (required in addition to the `pandoc` Python package) and **`make`**[^2]
102
+ 2. Navigate to the docs folder: `cd docs`
103
+ 3. Install Python dependencies: `pip install -r requirements.txt`
104
+ 4. Run `make dev` to serve with live reloading at [https://127.0.0.1:8000/](https://127.0.0.1:8000/)
118
105
 
119
106
  ## Usage
120
107
 
@@ -122,8 +109,6 @@ Packflow provides a flexible base class called an `InferenceBackend` that allows
122
109
 
123
110
  Additionally, Packflow's CLI can assist with creating projects, gathering environmental information, and creating distributable code packages for sharing reproducible inference code between disconnected environments.
124
111
 
125
- For detailed information and usage patterns on Packflow, please see the `About Packflow` and `User Guide` sections of the official documentation site.
126
-
127
112
  ### Dummy Inference Backend
128
113
 
129
114
  To create a dummy Inference Backend, update the `inference.py` file to the following:
@@ -156,7 +141,7 @@ backend({"sample": "data"})
156
141
 
157
142
  ## Contributing
158
143
 
159
- Contributions to Packflow are welcomed and highly encouraged! Please refer to the [CONTRIBUTE.md](CONTRIBUTE.md) guide for more information and guidelines for contributing to Packflow.
144
+ Contributions to Packflow are welcomed and highly encouraged! Please refer to the [CONTRIBUTING.md](https://github.com/dow-cdao/packflow/blob/master/CONTRIBUTING.md) guide for more information and guidelines for contributing to Packflow.
160
145
 
161
146
  ## Authors
162
147
 
@@ -164,10 +149,9 @@ Packflow is developed and maintained by [Booz Allen Hamilton](https://www.boozal
164
149
 
165
150
  ## License
166
151
 
167
- `packflow` is distributed under the terms of the [MIT license](https://spdx.org/licenses/MIT.html). Please refer to the [LICENSE.txt](./LICENSE) for more information of acceptable usage and distribution of Packflow.
152
+ `packflow` is distributed under the terms of the [MIT license](https://spdx.org/licenses/MIT.html). Please refer to the [LICENSE](https://github.com/dow-cdao/packflow/blob/master/LICENSE) for more information of acceptable usage and distribution of Packflow.
168
153
 
169
154
 
170
- [^1]: *Pandoc* must be installed separately from the `pandoc` python package in `docs/requirements.txt`.
171
155
  [^2]: Installation of `make` varies by operating system. On MacOS, install `xcode-select`. On Windows, it is recommend to use Windows Subsystem for Linux (WSL). On Debian/Ubuntu, `make` can be installed via `apt` package manager: <pre>
172
156
  sudo apt update
173
157
  sudo apt install make build-essential
@@ -1,11 +1,19 @@
1
- <h1 style="text-align: center; border-bottom: none !important;">
2
- <img src="assets/packflow-logo-white-text.png" width="500" alt="Packflow logo">
1
+ <h1 align="center" style="text-align: center; border-bottom: none !important;">
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/dow-cdao/packflow/master/assets/packflow-logo-dark.png">
4
+ <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/dow-cdao/packflow/master/assets/packflow-logo-light.png">
5
+ <img src="https://raw.githubusercontent.com/dow-cdao/packflow/master/assets/packflow-logo-dark.png" width="500" alt="Packflow logo">
6
+ </picture>
3
7
  </h1>
4
8
 
5
9
  <p align="center">
6
- <a href="https://pypi.org/project/packflow/"><img alt="PyPI - Version" src="https://img.shields.io/pypi/v/packflow.svg"></a>
7
- <a href="https://pypi.org/project/packflow/"><img alt="PyPI - Python Version" src="https://img.shields.io/pypi/pyversions/packflow.svg"></a>
8
- <a href="https://github.com/dow-cdao/packflow/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/badge/License-MIT-blue.svg"></a>
10
+ <a href="https://pypi.org/project/packflow/"><img alt="Packflow on PyPI - Version" src="https://img.shields.io/pypi/v/packflow">
11
+ </a>
12
+ <a href="https://pypi.org/project/packflow/"><img alt="Packflow on PyPI - Python Versions" src="https://img.shields.io/pypi/pyversions/packflow">
13
+ </a>
14
+ <a href="https://github.com/dow-cdao/packflow/blob/master/LICENSE">
15
+ <img alt="Packflow on GitHub - License" src="https://img.shields.io/github/license/dow-cdao/packflow">
16
+ </a>
9
17
  </p>
10
18
 
11
19
  # Introduction
@@ -13,6 +21,8 @@
13
21
  `packflow` is a software development kit (SDK) that simplifies the development process and standardizes packaging of AI/ML
14
22
  running on streaming data sources.
15
23
 
24
+ **What does Packflow do?** Packflow provides a framework for *writing*, *running*, and *packaging* inference code. It offers a standardized structure (the `InferenceBackend` class) for writing model execution logic, provides the runtime backbone that executes models with built-in profiling and preprocessing, and includes tools to bundle code into portable zip archives. This means you write your inference code once using Packflow's structure, and Packflow handles both the optimized execution and creation of shareable packages for transfer between systems.
25
+
16
26
  Many existing packaging frameworks are catered towards inference APIs and often require custom preprocessing steps. This can be particularly challenging when dealing with data sources that typically generate data one row at a time in key-value pairs (e.g., firewall logs or message streams).
17
27
 
18
28
  Packflow, however, is optimized to run models on either individual events or batches of events, streamlining development and reducing the need for additional preprocessing. By leveraging Packflow, teams can focus on building and deploying models with custom out-of-the-box workflows and utilities, significantly reducing the time and effort required to onboard new capabilities.
@@ -35,47 +45,19 @@ The following instructions quickly walk through how to install Packflow and serv
35
45
  pip install packflow
36
46
  ```
37
47
 
38
- from the root of the Packflow repo.
39
-
40
48
  > [!NOTE]
41
49
  > If contributing to Packflow, it is recommended to install `packflow` from source in editable mode: `pip install -e .`
42
50
 
43
- ## Packflow Documentation
44
-
45
- Packflow documentation is available pre-built in the repository and can be viewed immediately, or built from source for development work. Follow the instructions below to get started with serving the documentation.
46
-
47
- ### Viewing Pre-built Documentation
48
-
49
- The simplest way to view the Packflow documentation is to serve the pre-built HTML files included in the repository:
50
-
51
- 1. Navigate to the pre-built docs folder: `cd docs/built/html`
52
- 2. Start a local web server: `python -m http.server 8000`
53
- 3. Access the documentation in a web browser by navigating to [http://127.0.0.1:8000/](http://127.0.0.1:8000/)
54
-
55
- > [!WARNING]
56
- > If a "Not Found" error page is received when first accessing the documentation, wait a moment for the server to fully start and refresh the page.
51
+ ## Documentation
57
52
 
58
- ### Building Documentation from Source
53
+ Packflow documentation is hosted at **[https://dow-cdao.github.io/packflow/](https://dow-cdao.github.io/packflow/)**. Pre-built HTML is also available on the [`gh-pages`](https://github.com/dow-cdao/packflow/tree/gh-pages) branch.
59
54
 
60
- #### Prerequisite Requirements
61
-
62
- The following are required to build documentation from source:
63
-
64
- - **Python** (version 3.10+)
65
- - **Pip**
66
- - **Packflow** (the version corresponding to the docs being served)
67
- - **Pandoc**[^1] (see Pandoc.org's [official installation instructions](https://pandoc.org/installing.html))
68
- - **`make` Command**[^2]
55
+ To build and serve documentation locally:
69
56
 
70
- #### Steps
71
-
72
- 1. Navigate to the docs folder: `cd docs`
73
- 2. Install Python dependencies for building and hosting the documentation: `pip install -r requirements.txt`
74
- 3. Run `make dev` to serve the documentation from a working tree with live updates, or `make prod-serve` to serve static multi-version documentation (requires `.git` directory with branch/tag history)
75
- 4. Access the built documentation in a web browser by navigating to [http://127.0.0.1:8000/](http://127.0.0.1:8000/)
76
-
77
- > [!WARNING]
78
- > If a "Not Found" error page is received when first accessing the documentation, wait a moment for the server to fully start and refresh the page.
57
+ 1. Install system prerequisites: [**Pandoc**](https://pandoc.org/installing.html) (required in addition to the `pandoc` Python package) and **`make`**[^2]
58
+ 2. Navigate to the docs folder: `cd docs`
59
+ 3. Install Python dependencies: `pip install -r requirements.txt`
60
+ 4. Run `make dev` to serve with live reloading at [https://127.0.0.1:8000/](https://127.0.0.1:8000/)
79
61
 
80
62
  ## Usage
81
63
 
@@ -83,8 +65,6 @@ Packflow provides a flexible base class called an `InferenceBackend` that allows
83
65
 
84
66
  Additionally, Packflow's CLI can assist with creating projects, gathering environmental information, and creating distributable code packages for sharing reproducible inference code between disconnected environments.
85
67
 
86
- For detailed information and usage patterns on Packflow, please see the `About Packflow` and `User Guide` sections of the official documentation site.
87
-
88
68
  ### Dummy Inference Backend
89
69
 
90
70
  To create a dummy Inference Backend, update the `inference.py` file to the following:
@@ -117,7 +97,7 @@ backend({"sample": "data"})
117
97
 
118
98
  ## Contributing
119
99
 
120
- Contributions to Packflow are welcomed and highly encouraged! Please refer to the [CONTRIBUTE.md](CONTRIBUTE.md) guide for more information and guidelines for contributing to Packflow.
100
+ Contributions to Packflow are welcomed and highly encouraged! Please refer to the [CONTRIBUTING.md](https://github.com/dow-cdao/packflow/blob/master/CONTRIBUTING.md) guide for more information and guidelines for contributing to Packflow.
121
101
 
122
102
  ## Authors
123
103
 
@@ -125,10 +105,9 @@ Packflow is developed and maintained by [Booz Allen Hamilton](https://www.boozal
125
105
 
126
106
  ## License
127
107
 
128
- `packflow` is distributed under the terms of the [MIT license](https://spdx.org/licenses/MIT.html). Please refer to the [LICENSE.txt](./LICENSE) for more information of acceptable usage and distribution of Packflow.
108
+ `packflow` is distributed under the terms of the [MIT license](https://spdx.org/licenses/MIT.html). Please refer to the [LICENSE](https://github.com/dow-cdao/packflow/blob/master/LICENSE) for more information of acceptable usage and distribution of Packflow.
129
109
 
130
110
 
131
- [^1]: *Pandoc* must be installed separately from the `pandoc` python package in `docs/requirements.txt`.
132
111
  [^2]: Installation of `make` varies by operating system. On MacOS, install `xcode-select`. On Windows, it is recommend to use Windows Subsystem for Linux (WSL). On Debian/Ubuntu, `make` can be installed via `apt` package manager: <pre>
133
112
  sudo apt update
134
113
  sudo apt install make build-essential
@@ -19,6 +19,20 @@ keywords = [
19
19
  license = { file = "LICENSE" }
20
20
  readme = "README.md"
21
21
  requires-python = ">=3.10"
22
+ classifiers = [
23
+ "Development Status :: 4 - Beta",
24
+ "Intended Audience :: Developers",
25
+ "Intended Audience :: Science/Research",
26
+ "License :: OSI Approved :: MIT License",
27
+ "Operating System :: OS Independent",
28
+ "Programming Language :: Python :: 3",
29
+ "Programming Language :: Python :: 3.10",
30
+ "Programming Language :: Python :: 3.11",
31
+ "Programming Language :: Python :: 3.12",
32
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
33
+ "Topic :: Software Development :: Libraries :: Python Modules",
34
+ "Topic :: System :: Distributed Computing",
35
+ ]
22
36
  dependencies = [
23
37
  "deepmerge (>=2.0,<3.0)",
24
38
  "flatten-dict (>=0.4.2,<1.0.0)",
@@ -41,7 +55,7 @@ build-backend = "poetry.core.masonry.api"
41
55
 
42
56
 
43
57
  [tool.poetry]
44
- version = "0.3.0"
58
+ version = "0.3.1rc2"
45
59
  exclude = [
46
60
  "tests",
47
61
  "docs",
@@ -67,5 +81,8 @@ pillow = "^11.3.0"
67
81
 
68
82
  [tool.poetry.scripts]
69
83
  packflow = "packflow.cli:cli"
84
+ [tool.pytest.ini_options]
85
+ addopts = "--ignore=src/packflow/data/templates"
86
+
70
87
  [tool.coverage.run]
71
88
  omit = ["tests/*"]
@@ -34,6 +34,7 @@ class BackendConfig(BaseModel):
34
34
  flatten_nested_inputs: bool = False
35
35
  flatten_lists: bool = False
36
36
  nested_field_delimiter: str = "."
37
+ ignore_delimiter_collisions: bool = False
37
38
 
38
39
 
39
40
  def load_backend_configuration(
@@ -134,6 +134,50 @@ class RecordsPreprocessor(Preprocessor):
134
134
  self.reducer = make_reducer(self.config.nested_field_delimiter)
135
135
  self.enumerate_types = (list,) if self.config.flatten_lists else ()
136
136
 
137
+ def _check_for_delimiter_collisions(self, obj: dict) -> None:
138
+ """Check if any keys in the object contain the delimiter character.
139
+
140
+ Raises PreprocessorRuntimeError if collisions are found and
141
+ ignore_delimiter_collisions is False.
142
+
143
+ Parameters
144
+ ----------
145
+ obj : dict
146
+ Dictionary to check for delimiter collisions
147
+ """
148
+ if self.config.ignore_delimiter_collisions:
149
+ return
150
+
151
+ collisions = packflow.utils.check_delimiter_collisions(
152
+ obj, self.config.nested_field_delimiter
153
+ )
154
+
155
+ if collisions:
156
+ raise exceptions.PreprocessorRuntimeError(
157
+ f"Keys containing the delimiter '{self.config.nested_field_delimiter}' were found: {collisions}. "
158
+ f"This can cause ambiguity when using nested path access. "
159
+ f"Either rename these keys or set ignore_delimiter_collisions=True to bypass this check. "
160
+ f"Note: Setting ignore_delimiter_collisions=True may result in undefined behavior "
161
+ f"if key collisions occur during flatten/unflatten operations."
162
+ )
163
+
164
+ def _uses_nested_paths(self) -> bool:
165
+ """Check if any rename_fields keys or feature_names use nested path notation.
166
+
167
+ Returns True if delimiter is present in any field names.
168
+ """
169
+ delimiter = self.config.nested_field_delimiter
170
+
171
+ for key in self.config.rename_fields:
172
+ if delimiter in key:
173
+ return True
174
+
175
+ for feature in self.config.feature_names:
176
+ if delimiter in feature:
177
+ return True
178
+
179
+ return False
180
+
137
181
  def process(self, raw_inputs: list[dict]) -> list[dict]:
138
182
  """Process an input batch and make transformations as necessary.
139
183
 
@@ -151,36 +195,97 @@ class RecordsPreprocessor(Preprocessor):
151
195
  -------
152
196
  list[dict]
153
197
  Transformed records
198
+
199
+ Notes
200
+ -----
201
+ When accessing nested fields via delimiter notation (e.g., "a.b.c") in
202
+ feature_names or rename_fields, missing keys will be silently skipped
203
+ and not included in the output.
204
+
205
+ If flatten_nested_inputs=False, the preprocessor will never flatten the input,
206
+ preserving all keys exactly as they appear (including keys containing delimiters).
207
+ Nested path access will be done via direct traversal instead of flattening.
154
208
  """
155
209
  if self.passthrough:
156
210
  return raw_inputs
157
211
 
212
+ uses_nested_paths = self._uses_nested_paths()
213
+
214
+ # Check for delimiter collisions if we're using nested paths
215
+ if uses_nested_paths and not self.config.flatten_nested_inputs:
216
+ for obj in raw_inputs:
217
+ self._check_for_delimiter_collisions(obj)
218
+
158
219
  records = []
159
220
  for obj in raw_inputs:
160
221
  obj = obj.copy() # avoid editing input data
161
- obj = flatten(
162
- obj,
163
- reducer=self.reducer,
164
- enumerate_types=self.enumerate_types,
165
- keep_empty_types=(dict, list),
166
- )
167
- processed_obj = {}
168
-
169
- for key in self.config.rename_fields:
170
- processed_obj[self.config.rename_fields[key]] = obj.get(key)
171
-
172
- if self.config.feature_names:
173
- for feature in self.config.feature_names:
174
- if feature not in processed_obj:
175
- processed_obj[feature] = obj.get(feature)
176
- else:
177
- processed_obj.update(obj)
178
-
179
- if not self.config.flatten_nested_inputs:
180
- processed_obj = unflatten(
181
- processed_obj,
182
- splitter=make_splitter(self.config.nested_field_delimiter),
222
+
223
+ if self.config.flatten_nested_inputs:
224
+ # FLATTEN MODE: Flatten the entire structure
225
+ obj = flatten(
226
+ obj,
227
+ reducer=self.reducer,
228
+ enumerate_types=self.enumerate_types,
229
+ keep_empty_types=(dict, list),
183
230
  )
231
+ processed_obj = {}
232
+
233
+ # Process rename_fields with flattened keys
234
+ for key in self.config.rename_fields:
235
+ value = obj.get(key)
236
+ if value is not None:
237
+ processed_obj[self.config.rename_fields[key]] = value
238
+
239
+ # Process feature_names with flattened keys
240
+ if self.config.feature_names:
241
+ for feature in self.config.feature_names:
242
+ if feature not in processed_obj:
243
+ value = obj.get(feature)
244
+ if value is not None:
245
+ processed_obj[feature] = value
246
+ else:
247
+ processed_obj.update(obj)
248
+ else:
249
+ # NON-FLATTEN MODE: Preserve structure, use direct nested access
250
+ processed_obj = {}
251
+
252
+ # Process rename_fields with direct nested access
253
+ for key in self.config.rename_fields:
254
+ value = packflow.utils.get_nested_field_direct(
255
+ obj, key, self.config.nested_field_delimiter
256
+ )
257
+ if value is not None:
258
+ new_key = self.config.rename_fields[key]
259
+ # If the new key contains delimiter, create nested structure
260
+ if self.config.nested_field_delimiter in new_key:
261
+ packflow.utils.set_nested_field_direct(
262
+ processed_obj, new_key, value, self.config.nested_field_delimiter
263
+ )
264
+ else:
265
+ processed_obj[new_key] = value
266
+
267
+ # Process feature_names with direct nested access
268
+ if self.config.feature_names:
269
+ for feature in self.config.feature_names:
270
+ # Check if already added via rename_fields
271
+ existing_value = packflow.utils.get_nested_field_direct(
272
+ processed_obj, feature, self.config.nested_field_delimiter
273
+ )
274
+ if existing_value is None:
275
+ value = packflow.utils.get_nested_field_direct(
276
+ obj, feature, self.config.nested_field_delimiter
277
+ )
278
+ if value is not None:
279
+ # If feature contains delimiter, create nested structure
280
+ if self.config.nested_field_delimiter in feature:
281
+ packflow.utils.set_nested_field_direct(
282
+ processed_obj, feature, value, self.config.nested_field_delimiter
283
+ )
284
+ else:
285
+ processed_obj[feature] = value
286
+ else:
287
+ # No feature filtering - include everything
288
+ processed_obj.update(obj)
184
289
 
185
290
  records.append(processed_obj)
186
291
 
@@ -7,6 +7,9 @@ def _success_message(msg: str):
7
7
  base = click.style("Success:", fg="green")
8
8
  click.echo(f"{base} {msg}")
9
9
 
10
+ def _warning_message(msg: str):
11
+ base = click.style("Warning:", fg="yellow")
12
+ click.echo(f"{base} {msg}")
10
13
 
11
14
  def _error_message(msg: str):
12
15
  base = click.style("Error:", fg="red")
@@ -15,6 +18,7 @@ def _error_message(msg: str):
15
18
 
16
19
  @click.group()
17
20
  def cli():
21
+ """Command-line tools for creating, managing, and packaging Packflow inference projects."""
18
22
  pass
19
23
 
20
24
 
@@ -42,6 +46,8 @@ def export(project_path):
42
46
  try:
43
47
  project = packflow.PackflowProject(project_path)
44
48
  output_file = project.export()
49
+ if project.version_warning:
50
+ _warning_message(project.version_warning)
45
51
  _success_message(f"Saved Package to {output_file}")
46
52
  except Exception as e:
47
53
  _error_message(str(e))
@@ -0,0 +1,22 @@
1
+ # Project Name
2
+
3
+ Brief description of the analytic.
4
+
5
+ ## Setup
6
+
7
+ Install dependencies into the active Python environment:
8
+
9
+ ```bash
10
+ pip install -r requirements.txt
11
+ ```
12
+
13
+
14
+ ## Testing
15
+
16
+ `pytest` is required to run tests and is not included in `requirements.txt`.
17
+ Install it separately:
18
+
19
+ ```bash
20
+ pip install pytest
21
+ pytest test_inference.py
22
+ ```
@@ -0,0 +1,28 @@
1
+ # A starting point for testing the Inference Backend with pytest. The fixture below handles loading the backend
2
+ # from packflow.yaml - add test cases to verify the backend behaves as expected for this analytic.
3
+ import pytest
4
+ from packflow.loaders import LocalLoader
5
+
6
+
7
+ @pytest.fixture
8
+ def backend():
9
+ """Load the backend as configured in packflow.yaml"""
10
+ return LocalLoader.from_project(".")
11
+
12
+
13
+ def test_backend_loads(backend):
14
+ """Backend initializes without error."""
15
+ assert backend is not None
16
+
17
+
18
+ # Uncomment and add input data to test backend behavior.
19
+ # def test_backend_validate(backend):
20
+ # sample_inputs = [
21
+ # {"example_field": "example_value"},
22
+ # ]
23
+ # outputs = backend.validate(sample_inputs)
24
+ # assert outputs is not None
25
+ #
26
+ # def test_backend_output_values(backend):
27
+ # outputs = backend([{"example_field": "example_value"}])
28
+ # assert outputs[0]["expected_field"] == "expected_value"
@@ -0,0 +1,30 @@
1
+ # validate.py - checks that the backend's inputs and outputs are in the format
2
+ # Packflow expects (correct types, matching row counts, JSON-serializable values).
3
+ #
4
+ # This is NOT a test of analytic logic or accuracy. Write test cases specific
5
+ # to the expected behavior of the backend to verify correctness.
6
+ from packflow.loaders import LocalLoader
7
+
8
+ # Load the backend in the current directory
9
+ # The path 'inference:Backend' can be interpreted as
10
+ # `from inference import Backend`
11
+ backend = LocalLoader("inference:Backend").load()
12
+
13
+ # Define sample inputs that represent realistic data for the backend.
14
+ # These should exercise the expected input format(s) the backend will receive.
15
+ SAMPLE_INPUTS = [
16
+ # Replace with data structured to match this backend's expected input.
17
+ # The placeholder below will likely fail - update before running.
18
+ {"example_field": "example_value"},
19
+ ]
20
+
21
+ if __name__ == "__main__":
22
+ print("Running validation...")
23
+ print(f"Sample inputs: {SAMPLE_INPUTS}\n")
24
+
25
+ # Checks output structure (format, row count, serializaibility).
26
+ # Returns outputs if valid.
27
+ outputs = backend.validate(SAMPLE_INPUTS)
28
+
29
+ print(f"Outputs: {outputs}")
30
+ print("\nValidation passed!")
@@ -98,6 +98,32 @@ class PackflowConfig(BaseModel):
98
98
  return requirements_text
99
99
 
100
100
 
101
+ def check_python_version(config: "PackflowConfig") -> Optional[str]:
102
+ """
103
+ Compare the config's python version against the running interpreter
104
+ at the minor version level (e.g. 3.10 vs 3.11). Returns a warning
105
+ message string on mismatch, None if versions agree.
106
+ """
107
+ runtime_minor = (sys.version_info.major, sys.version_info.minor)
108
+
109
+ try:
110
+ parts = [int(p) for p in config.python_version.split('.')]
111
+ config_minor = (parts[0], parts[1])
112
+ except (ValueError, IndexError):
113
+ return (
114
+ f"Could not parse python_versoin '{config.python_version}' in packflow.yaml. "
115
+ f"Expected a version string like '{get_python_version()}'."
116
+ )
117
+
118
+ if runtime_minor != config_minor:
119
+ return (
120
+ f"packflow.yaml specifies Python {config.python_version}, "
121
+ f"but the current environment is Python {get_python_version()}. "
122
+ f"Consider updating the python_version field or switching to a matching environment."
123
+ )
124
+ return None
125
+
126
+
101
127
  def _load_raw_packaging_config(base_dir: Union[str, Path]) -> dict:
102
128
  base_dir = Path(base_dir).resolve()
103
129
  packaging_config = base_dir / constants.PACKAGING_CONFIG_NAME
@@ -0,0 +1,11 @@
1
+ import os
2
+ import sys
3
+
4
+ from loguru import logger
5
+
6
+ logger.remove()
7
+ logger.add(sys.stderr, level=os.getenv("PACKFLOW_LOG_LEVEL", "INFO"))
8
+
9
+
10
+ def get_logger():
11
+ return logger
@@ -1,12 +1,13 @@
1
1
  import importlib.resources
2
2
  import shutil
3
+ import os
3
4
  import zipfile
4
5
  from pathlib import Path
5
6
  from typing import Union
6
7
 
7
8
  import packflow.constants as constants
8
9
 
9
- from .loaders.config import PackflowConfig
10
+ from .loaders.config import PackflowConfig, check_python_version
10
11
 
11
12
 
12
13
  class PackflowProject:
@@ -30,6 +31,7 @@ class PackflowProject:
30
31
 
31
32
  base_path = Path(config.name).resolve()
32
33
 
34
+ created_new_dir = not base_path.exists()
33
35
  base_path.mkdir(parents=True, exist_ok=force)
34
36
 
35
37
  # HARD CODED SINCE THERE'S ONLY ONE TEMPLATE RIGHT NOW
@@ -41,9 +43,24 @@ class PackflowProject:
41
43
 
42
44
  shutil.copytree(str(templates_dir), str(base_path), dirs_exist_ok=True)
43
45
 
44
- config.write_yaml(base_path)
45
46
 
46
- config.write_requirements(base_path)
47
+ try:
48
+ # Ensure all created files/directories are writable regardless of
49
+ # source permissions or environment umask settings
50
+ os.chmod(base_path, 0o755)
51
+ for root, dirs, files in os.walk(base_path):
52
+ for d in dirs:
53
+ os.chmod(os.path.join(root, d), 0o755)
54
+ for f in files:
55
+ os.chmod(os.path.join(root, f), 0o644)
56
+
57
+ config.write_yaml(base_path)
58
+
59
+ config.write_requirements(base_path)
60
+ except Exception:
61
+ if created_new_dir:
62
+ shutil.rmtree(base_path, ignore_errors=True)
63
+ raise
47
64
 
48
65
  return cls(base_path)
49
66
 
@@ -55,6 +72,9 @@ class PackflowProject:
55
72
  Save the loaded project as a package.zip with schema `{name}-{version}-pkg.zip`
56
73
  """
57
74
  config = PackflowConfig.from_project_path(self.base_dir)
75
+
76
+ self.version_warning = check_python_version(config)
77
+
58
78
  export_file_name = config.archive_file_name(output_directory)
59
79
 
60
80
  try:
@@ -0,0 +1,10 @@
1
+ from .data import (
2
+ check_delimiter_collisions,
3
+ flatten_dict,
4
+ flatten_records,
5
+ get_nested_field,
6
+ get_nested_field_direct,
7
+ records_to_ndarray,
8
+ set_nested_field_direct,
9
+ )
10
+ from .normalize import ensure_native_types, ensure_valid_output
@@ -6,6 +6,105 @@ from flatten_dict import flatten, unflatten
6
6
  from flatten_dict.reducers import make_reducer
7
7
 
8
8
 
9
+ def check_delimiter_collisions(obj: dict, delimiter: str, path: str = "") -> List[str]:
10
+ """
11
+ Recursively check for keys containing the delimiter character.
12
+
13
+ Parameters
14
+ ----------
15
+ obj : dict
16
+ Dictionary to check for delimiter collisions
17
+ delimiter : str
18
+ The delimiter character to check for
19
+ path : str
20
+ Current path (for recursive calls)
21
+
22
+ Returns
23
+ -------
24
+ List[str]
25
+ List of paths where delimiter collisions were found
26
+ """
27
+ collisions = []
28
+
29
+ for key, value in obj.items():
30
+ current_path = f"{path}{delimiter}{key}" if path else key
31
+
32
+ if delimiter in key:
33
+ collisions.append(current_path)
34
+
35
+ if isinstance(value, dict):
36
+ collisions.extend(check_delimiter_collisions(value, delimiter, current_path))
37
+
38
+ return collisions
39
+
40
+
41
+ def get_nested_field_direct(obj: dict, field: str, delimiter: str = ".") -> Any:
42
+ """
43
+ Retrieves a nested field by traversing the dictionary structure directly.
44
+ Does not use flattening, preserving keys that contain the delimiter.
45
+
46
+ Parameters
47
+ ----------
48
+ obj : dict
49
+ Dictionary to traverse
50
+ field : str
51
+ Field path using delimiter notation (e.g., "a.b.c")
52
+ delimiter : str
53
+ Delimiter to split the field path
54
+
55
+ Returns
56
+ -------
57
+ Any
58
+ The value at the nested path, or None if not found
59
+ """
60
+ # First check if the field exists as a literal key
61
+ if field in obj:
62
+ return obj[field]
63
+
64
+ # Otherwise, traverse the nested structure
65
+ parts = field.split(delimiter)
66
+ current = obj
67
+
68
+ for part in parts:
69
+ if not isinstance(current, dict) or part not in current:
70
+ return None
71
+ current = current[part]
72
+
73
+ return current
74
+
75
+
76
+ def set_nested_field_direct(obj: dict, field: str, value: Any, delimiter: str = ".") -> None:
77
+ """
78
+ Sets a nested field by creating the nested structure directly.
79
+ Does not use flattening/unflattening.
80
+
81
+ Parameters
82
+ ----------
83
+ obj : dict
84
+ Dictionary to modify (modified in place)
85
+ field : str
86
+ Field path using delimiter notation (e.g., "a.b.c")
87
+ value : Any
88
+ Value to set at the nested path
89
+ delimiter : str
90
+ Delimiter to split the field path
91
+ """
92
+ parts = field.split(delimiter)
93
+ current = obj
94
+
95
+ # Navigate/create the nested structure
96
+ for part in parts[:-1]:
97
+ if part not in current:
98
+ current[part] = {}
99
+ elif not isinstance(current[part], dict):
100
+ # Can't traverse further if we hit a non-dict value
101
+ return
102
+ current = current[part]
103
+
104
+ # Set the final value
105
+ current[parts[-1]] = value
106
+
107
+
9
108
  def get_nested_field(obj: dict, field: str, delimiter: Optional[str] = None) -> Any:
10
109
  """
11
110
  Retrieves a single nested field from a dictionary given a field name.
@@ -1,25 +0,0 @@
1
- # Import Packflow's dev tools to run validations on the Inference Backend
2
- from packflow.loaders import LocalLoader
3
-
4
- # Load the backend in the current directory
5
- # The path 'inference:Backend' can be interpreted as
6
- # `from inference import Backend`
7
- backend = LocalLoader("inference:Backend").load()
8
-
9
- # Define sample inputs that represent realistic data for your backend.
10
- # These should exercise the expected input format(s) your backend will receive.
11
- SAMPLE_INPUTS = [
12
- {"example_field": "example_value"},
13
- # Add more sample rows as needed
14
- ]
15
-
16
- if __name__ == "__main__":
17
- print("Running validation...")
18
- print(f"Sample inputs: {SAMPLE_INPUTS}\n")
19
-
20
- # backend.validate() runs your backend and checks the outputs
21
- # meet Packflow's API requirements. Returns outputs if valid.
22
- outputs = backend.validate(SAMPLE_INPUTS)
23
-
24
- print(f"Outputs: {outputs}")
25
- print("\nValidation passed!")
@@ -1,5 +0,0 @@
1
- from loguru import logger
2
-
3
-
4
- def get_logger():
5
- return logger
@@ -1,2 +0,0 @@
1
- from .data import flatten_dict, flatten_records, records_to_ndarray
2
- from .normalize import ensure_native_types, ensure_valid_output
File without changes