hpc-as-api 0.1.0__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.
- hpc_as_api-0.1.0/.gitignore +43 -0
- hpc_as_api-0.1.0/CONTRIBUTING.md +70 -0
- hpc_as_api-0.1.0/LICENSE +153 -0
- hpc_as_api-0.1.0/PKG-INFO +344 -0
- hpc_as_api-0.1.0/README.md +155 -0
- hpc_as_api-0.1.0/docs/deployment.md +140 -0
- hpc_as_api-0.1.0/hpc_as_api/__init__.py +54 -0
- hpc_as_api-0.1.0/hpc_as_api/app.py +553 -0
- hpc_as_api-0.1.0/hpc_as_api/auth.py +459 -0
- hpc_as_api-0.1.0/hpc_as_api/compute.py +943 -0
- hpc_as_api-0.1.0/hpc_as_api/crypto.py +127 -0
- hpc_as_api-0.1.0/hpc_as_api/utils.py +202 -0
- hpc_as_api-0.1.0/paper/paper.bib +66 -0
- hpc_as_api-0.1.0/paper/paper.md +222 -0
- hpc_as_api-0.1.0/pyproject.toml +66 -0
- hpc_as_api-0.1.0/tests/__init__.py +0 -0
- hpc_as_api-0.1.0/tests/test_app.py +70 -0
- hpc_as_api-0.1.0/tests/test_compute.py +143 -0
- hpc_as_api-0.1.0/tests/test_utils.py +165 -0
- hpc_as_api-0.1.0/uv.lock +1142 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.pyo
|
|
5
|
+
*.pyd
|
|
6
|
+
.Python
|
|
7
|
+
*.egg
|
|
8
|
+
*.egg-info/
|
|
9
|
+
dist/
|
|
10
|
+
build/
|
|
11
|
+
.eggs/
|
|
12
|
+
pip-wheel-metadata/
|
|
13
|
+
*.so
|
|
14
|
+
|
|
15
|
+
# Virtual environments
|
|
16
|
+
.venv/
|
|
17
|
+
venv/
|
|
18
|
+
env/
|
|
19
|
+
|
|
20
|
+
# uv
|
|
21
|
+
.uv/
|
|
22
|
+
|
|
23
|
+
# Testing
|
|
24
|
+
.pytest_cache/
|
|
25
|
+
.coverage
|
|
26
|
+
htmlcov/
|
|
27
|
+
.tox/
|
|
28
|
+
|
|
29
|
+
# IDE
|
|
30
|
+
.vscode/
|
|
31
|
+
.idea/
|
|
32
|
+
*.swp
|
|
33
|
+
*.swo
|
|
34
|
+
|
|
35
|
+
# Secrets — never commit these
|
|
36
|
+
.env
|
|
37
|
+
*.env
|
|
38
|
+
proxy.env
|
|
39
|
+
secrets/
|
|
40
|
+
|
|
41
|
+
# OS
|
|
42
|
+
.DS_Store
|
|
43
|
+
Thumbs.db
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Contributing to hpc-as-api
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing. This document describes how to set up a development environment, run the test suite, and submit changes.
|
|
4
|
+
|
|
5
|
+
## Development setup
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
git clone https://github.com/uicacer/hpc-as-api
|
|
9
|
+
cd hpc-as-api
|
|
10
|
+
uv sync --extra dev # installs all dev dependencies
|
|
11
|
+
uv run pytest -v # should show 28 tests passing
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
If you don't have `uv`, install it with `pip install uv` or see [uv docs](https://docs.astral.sh/uv/).
|
|
15
|
+
|
|
16
|
+
## Running tests
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# All tests (no Globus credentials needed — Globus SDK is mocked)
|
|
20
|
+
uv run --extra dev pytest -v
|
|
21
|
+
|
|
22
|
+
# A single test module
|
|
23
|
+
uv run --extra dev pytest tests/test_utils.py -v
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
The `test_compute.py` and `test_app.py` tests mock the Globus SDK so they run offline without any HPC credentials.
|
|
27
|
+
|
|
28
|
+
## Project structure
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
hpc_as_api/
|
|
32
|
+
auth.py — Globus token + API key authentication, rate limiting
|
|
33
|
+
compute.py — GlobusComputeClient: job submission and streaming
|
|
34
|
+
crypto.py — AES-256-GCM end-to-end encryption
|
|
35
|
+
utils.py — OpenAI multimodal message utilities
|
|
36
|
+
app.py — FastAPI routes (standalone + embeddable router)
|
|
37
|
+
paper/
|
|
38
|
+
paper.md — JOSS paper
|
|
39
|
+
paper.bib — BibTeX references
|
|
40
|
+
tests/
|
|
41
|
+
test_utils.py — message utility tests
|
|
42
|
+
test_compute.py — GlobusComputeClient unit tests
|
|
43
|
+
test_app.py — FastAPI route tests
|
|
44
|
+
docs/
|
|
45
|
+
deployment.md — production deployment guide
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Making changes
|
|
49
|
+
|
|
50
|
+
1. Fork the repository and create a branch: `git checkout -b feature/my-change`
|
|
51
|
+
2. Make your changes, add tests where appropriate
|
|
52
|
+
3. Run `uv run --extra dev pytest` to confirm tests pass
|
|
53
|
+
4. Run `uv run --extra dev ruff check hpc_as_api/` for style checks
|
|
54
|
+
5. Open a pull request with a clear description of what changed and why
|
|
55
|
+
|
|
56
|
+
## Reporting bugs / requesting features
|
|
57
|
+
|
|
58
|
+
Open an issue at <https://github.com/uicacer/hpc-as-api/issues>. Include:
|
|
59
|
+
- Python version (`python --version`)
|
|
60
|
+
- hpc-as-api version (`pip show hpc-as-api`)
|
|
61
|
+
- A minimal reproducing example
|
|
62
|
+
- The full error traceback
|
|
63
|
+
|
|
64
|
+
## Support and governance
|
|
65
|
+
|
|
66
|
+
This project is maintained by the [ACER group at UIC](https://acer.uic.edu). Questions and bug reports via GitHub Issues are the primary support channel. Response time is typically within one week.
|
|
67
|
+
|
|
68
|
+
## License
|
|
69
|
+
|
|
70
|
+
By contributing, you agree that your contributions will be licensed under the [Apache License 2.0](LICENSE).
|
hpc_as_api-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship made available under
|
|
36
|
+
the License, as indicated by a copyright notice that is included in
|
|
37
|
+
or attached to the work (an example is provided in the Appendix below).
|
|
38
|
+
|
|
39
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
40
|
+
form, that is based on (or derived from) the Work and for which the
|
|
41
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
42
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
43
|
+
of this License, Derivative Works shall not include works that remain
|
|
44
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
45
|
+
the Work and Derivative Works thereof.
|
|
46
|
+
|
|
47
|
+
"Contribution" shall mean, as defined by Section 1(a), any work of
|
|
48
|
+
authorship submitted to the Licensor for inclusion in the Work by the
|
|
49
|
+
code owner or by an individual or Legal Entity authorized to
|
|
50
|
+
submit on behalf of the copyright owner.
|
|
51
|
+
|
|
52
|
+
"Contributor" shall mean Licensor and any Legal Entity on behalf of
|
|
53
|
+
whom a Contribution has been received by the Licensor and included
|
|
54
|
+
within the Work.
|
|
55
|
+
|
|
56
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
57
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
58
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
59
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
60
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
61
|
+
Work and such Derivative Works in Source or Object form.
|
|
62
|
+
|
|
63
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
64
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
65
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
66
|
+
(except as stated in this section) patent license to make, have made,
|
|
67
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
68
|
+
where such license applies only to those patent claims licensable
|
|
69
|
+
by such Contributor that are necessarily infringed by their
|
|
70
|
+
Contribution(s) alone or by the combinations of their Contribution(s)
|
|
71
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
72
|
+
institute patent proceedings against any entity (including a
|
|
73
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
74
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
75
|
+
or contributory patent infringement, then any patent licenses
|
|
76
|
+
granted to You under this License for that Work shall terminate
|
|
77
|
+
as of the date such litigation is filed.
|
|
78
|
+
|
|
79
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
80
|
+
Work or Distribute or Derivative Works thereof in any medium, with or without
|
|
81
|
+
modifications, and in Source or Object form, provided that You
|
|
82
|
+
meet the following conditions:
|
|
83
|
+
|
|
84
|
+
(a) You must give any other recipients of the Work or Derivative
|
|
85
|
+
Works a copy of this License; and
|
|
86
|
+
|
|
87
|
+
(b) You must cause any modified files to carry prominent notices
|
|
88
|
+
stating that You changed the files; and
|
|
89
|
+
|
|
90
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
91
|
+
that You distribute, all copyright, patent, trademark, and
|
|
92
|
+
attribution notices from the Source form of the Work,
|
|
93
|
+
excluding those notices that do not pertain to any part of
|
|
94
|
+
the Derivative Works; and
|
|
95
|
+
|
|
96
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
97
|
+
distribution, You must include a readable copy of the
|
|
98
|
+
attribution notices contained within such NOTICE file, in
|
|
99
|
+
at least one of the following places: within a NOTICE text
|
|
100
|
+
file distributed as part of the Derivative Works; within
|
|
101
|
+
the Source form or documentation, if provided along with the
|
|
102
|
+
Derivative Works; or, within a display generated by the
|
|
103
|
+
Derivative Works, if and wherever such third-party notices
|
|
104
|
+
normally appear. The contents of the NOTICE file are for
|
|
105
|
+
informational purposes only and do not modify the License.
|
|
106
|
+
|
|
107
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
108
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
109
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
110
|
+
this License, without any additional terms or conditions.
|
|
111
|
+
|
|
112
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
113
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
114
|
+
except as required for reasonable and customary use in describing the
|
|
115
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
116
|
+
|
|
117
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed
|
|
118
|
+
to in writing, Licensor provides the Work (and each Contributor
|
|
119
|
+
provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES
|
|
120
|
+
OR CONDITIONS OF ANY KIND, either express or implied, including,
|
|
121
|
+
without limitation, any warranties or conditions of TITLE,
|
|
122
|
+
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
|
|
123
|
+
|
|
124
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
125
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
126
|
+
unless required by applicable law (such as deliberate and grossly
|
|
127
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
128
|
+
liable to You for damages, including any direct, indirect, special,
|
|
129
|
+
incidental, or exemplary damages of any kind arising as a result of
|
|
130
|
+
this License or out of the use or inability to use the Work.
|
|
131
|
+
|
|
132
|
+
9. Accepting Warranty or Liability. While redistributing the Work or
|
|
133
|
+
Derivative Works thereof, You may choose to offer, and charge a fee
|
|
134
|
+
for, acceptance of support, warranty, indemnity, or other liability
|
|
135
|
+
obligations and/or rights consistent to the Law. However, in accepting
|
|
136
|
+
such obligations, You may offer such obligations only on Your own behalf
|
|
137
|
+
and on Your sole responsibility, not on behalf of any other Contributor.
|
|
138
|
+
|
|
139
|
+
END OF TERMS AND CONDITIONS
|
|
140
|
+
|
|
141
|
+
Copyright 2026 Anas Nassar, University of Illinois Chicago
|
|
142
|
+
|
|
143
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
144
|
+
you may not use this file except in compliance with the License.
|
|
145
|
+
You may obtain a copy of the License at
|
|
146
|
+
|
|
147
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
148
|
+
|
|
149
|
+
Unless required by applicable law or agreed to in writing, software
|
|
150
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
151
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
152
|
+
See the License for the specific language governing permissions and
|
|
153
|
+
limitations under the License.
|
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hpc-as-api
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: OpenAI-compatible API gateway for HPC clusters via Globus Compute
|
|
5
|
+
Project-URL: Homepage, https://github.com/uicacer/hpc-as-api
|
|
6
|
+
Project-URL: Repository, https://github.com/uicacer/hpc-as-api
|
|
7
|
+
Project-URL: Bug Tracker, https://github.com/uicacer/hpc-as-api/issues
|
|
8
|
+
Author-email: Anas Nassar <nassar@uic.edu>
|
|
9
|
+
License: Apache License
|
|
10
|
+
Version 2.0, January 2004
|
|
11
|
+
http://www.apache.org/licenses/
|
|
12
|
+
|
|
13
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
14
|
+
|
|
15
|
+
1. Definitions.
|
|
16
|
+
|
|
17
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
18
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
19
|
+
|
|
20
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
21
|
+
the copyright owner that is granting the License.
|
|
22
|
+
|
|
23
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
24
|
+
other entities that control, are controlled by, or are under common
|
|
25
|
+
control with that entity. For the purposes of this definition,
|
|
26
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
27
|
+
direction or management of such entity, whether by contract or
|
|
28
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
29
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
30
|
+
|
|
31
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
32
|
+
exercising permissions granted by this License.
|
|
33
|
+
|
|
34
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
35
|
+
including but not limited to software source code, documentation
|
|
36
|
+
source, and configuration files.
|
|
37
|
+
|
|
38
|
+
"Object" form shall mean any form resulting from mechanical
|
|
39
|
+
transformation or translation of a Source form, including but
|
|
40
|
+
not limited to compiled object code, generated documentation,
|
|
41
|
+
and conversions to other media types.
|
|
42
|
+
|
|
43
|
+
"Work" shall mean the work of authorship made available under
|
|
44
|
+
the License, as indicated by a copyright notice that is included in
|
|
45
|
+
or attached to the work (an example is provided in the Appendix below).
|
|
46
|
+
|
|
47
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
48
|
+
form, that is based on (or derived from) the Work and for which the
|
|
49
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
50
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
51
|
+
of this License, Derivative Works shall not include works that remain
|
|
52
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
53
|
+
the Work and Derivative Works thereof.
|
|
54
|
+
|
|
55
|
+
"Contribution" shall mean, as defined by Section 1(a), any work of
|
|
56
|
+
authorship submitted to the Licensor for inclusion in the Work by the
|
|
57
|
+
code owner or by an individual or Legal Entity authorized to
|
|
58
|
+
submit on behalf of the copyright owner.
|
|
59
|
+
|
|
60
|
+
"Contributor" shall mean Licensor and any Legal Entity on behalf of
|
|
61
|
+
whom a Contribution has been received by the Licensor and included
|
|
62
|
+
within the Work.
|
|
63
|
+
|
|
64
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
65
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
66
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
67
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
68
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
69
|
+
Work and such Derivative Works in Source or Object form.
|
|
70
|
+
|
|
71
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
72
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
73
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
74
|
+
(except as stated in this section) patent license to make, have made,
|
|
75
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
76
|
+
where such license applies only to those patent claims licensable
|
|
77
|
+
by such Contributor that are necessarily infringed by their
|
|
78
|
+
Contribution(s) alone or by the combinations of their Contribution(s)
|
|
79
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
80
|
+
institute patent proceedings against any entity (including a
|
|
81
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
82
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
83
|
+
or contributory patent infringement, then any patent licenses
|
|
84
|
+
granted to You under this License for that Work shall terminate
|
|
85
|
+
as of the date such litigation is filed.
|
|
86
|
+
|
|
87
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
88
|
+
Work or Distribute or Derivative Works thereof in any medium, with or without
|
|
89
|
+
modifications, and in Source or Object form, provided that You
|
|
90
|
+
meet the following conditions:
|
|
91
|
+
|
|
92
|
+
(a) You must give any other recipients of the Work or Derivative
|
|
93
|
+
Works a copy of this License; and
|
|
94
|
+
|
|
95
|
+
(b) You must cause any modified files to carry prominent notices
|
|
96
|
+
stating that You changed the files; and
|
|
97
|
+
|
|
98
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
99
|
+
that You distribute, all copyright, patent, trademark, and
|
|
100
|
+
attribution notices from the Source form of the Work,
|
|
101
|
+
excluding those notices that do not pertain to any part of
|
|
102
|
+
the Derivative Works; and
|
|
103
|
+
|
|
104
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
105
|
+
distribution, You must include a readable copy of the
|
|
106
|
+
attribution notices contained within such NOTICE file, in
|
|
107
|
+
at least one of the following places: within a NOTICE text
|
|
108
|
+
file distributed as part of the Derivative Works; within
|
|
109
|
+
the Source form or documentation, if provided along with the
|
|
110
|
+
Derivative Works; or, within a display generated by the
|
|
111
|
+
Derivative Works, if and wherever such third-party notices
|
|
112
|
+
normally appear. The contents of the NOTICE file are for
|
|
113
|
+
informational purposes only and do not modify the License.
|
|
114
|
+
|
|
115
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
116
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
117
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
118
|
+
this License, without any additional terms or conditions.
|
|
119
|
+
|
|
120
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
121
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
122
|
+
except as required for reasonable and customary use in describing the
|
|
123
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
124
|
+
|
|
125
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed
|
|
126
|
+
to in writing, Licensor provides the Work (and each Contributor
|
|
127
|
+
provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES
|
|
128
|
+
OR CONDITIONS OF ANY KIND, either express or implied, including,
|
|
129
|
+
without limitation, any warranties or conditions of TITLE,
|
|
130
|
+
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
|
|
131
|
+
|
|
132
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
133
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
134
|
+
unless required by applicable law (such as deliberate and grossly
|
|
135
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
136
|
+
liable to You for damages, including any direct, indirect, special,
|
|
137
|
+
incidental, or exemplary damages of any kind arising as a result of
|
|
138
|
+
this License or out of the use or inability to use the Work.
|
|
139
|
+
|
|
140
|
+
9. Accepting Warranty or Liability. While redistributing the Work or
|
|
141
|
+
Derivative Works thereof, You may choose to offer, and charge a fee
|
|
142
|
+
for, acceptance of support, warranty, indemnity, or other liability
|
|
143
|
+
obligations and/or rights consistent to the Law. However, in accepting
|
|
144
|
+
such obligations, You may offer such obligations only on Your own behalf
|
|
145
|
+
and on Your sole responsibility, not on behalf of any other Contributor.
|
|
146
|
+
|
|
147
|
+
END OF TERMS AND CONDITIONS
|
|
148
|
+
|
|
149
|
+
Copyright 2026 Anas Nassar, University of Illinois Chicago
|
|
150
|
+
|
|
151
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
152
|
+
you may not use this file except in compliance with the License.
|
|
153
|
+
You may obtain a copy of the License at
|
|
154
|
+
|
|
155
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
156
|
+
|
|
157
|
+
Unless required by applicable law or agreed to in writing, software
|
|
158
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
159
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
160
|
+
See the License for the specific language governing permissions and
|
|
161
|
+
limitations under the License.
|
|
162
|
+
License-File: LICENSE
|
|
163
|
+
Keywords: api-gateway,globus-compute,hpc,llm,openai,slurm,vllm
|
|
164
|
+
Classifier: Development Status :: 3 - Alpha
|
|
165
|
+
Classifier: Intended Audience :: Science/Research
|
|
166
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
167
|
+
Classifier: Programming Language :: Python :: 3
|
|
168
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
169
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
170
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
|
|
171
|
+
Classifier: Topic :: Scientific/Engineering
|
|
172
|
+
Classifier: Topic :: System :: Distributed Computing
|
|
173
|
+
Requires-Python: >=3.11
|
|
174
|
+
Requires-Dist: cryptography>=43.0
|
|
175
|
+
Requires-Dist: fastapi>=0.115
|
|
176
|
+
Requires-Dist: httpx>=0.28
|
|
177
|
+
Requires-Dist: streamrelay>=0.2.0
|
|
178
|
+
Requires-Dist: uvicorn[standard]>=0.34
|
|
179
|
+
Requires-Dist: websockets>=13.0
|
|
180
|
+
Provides-Extra: dev
|
|
181
|
+
Requires-Dist: httpx>=0.28; extra == 'dev'
|
|
182
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
|
|
183
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
184
|
+
Requires-Dist: ruff; extra == 'dev'
|
|
185
|
+
Provides-Extra: globus
|
|
186
|
+
Requires-Dist: globus-compute-sdk>=2.0; extra == 'globus'
|
|
187
|
+
Requires-Dist: globus-sdk>=4.0; extra == 'globus'
|
|
188
|
+
Description-Content-Type: text/markdown
|
|
189
|
+
|
|
190
|
+
# hpc-as-api
|
|
191
|
+
|
|
192
|
+
[](https://pypi.org/project/hpc-as-api/)
|
|
193
|
+
[](https://github.com/uicacer/hpc-as-api/blob/main/LICENSE)
|
|
194
|
+
[](https://github.com/uicacer/hpc-as-api/actions)
|
|
195
|
+
|
|
196
|
+
**OpenAI-compatible API gateway for HPC clusters via Globus Compute.**
|
|
197
|
+
|
|
198
|
+
`hpc-as-api` exposes any vLLM-served model running on an HPC cluster (SLURM, PBS, etc.) as a standard OpenAI-compatible REST API. It handles authentication, rate limiting, payload size management, and real-time token streaming — so your existing OpenAI clients work without modification.
|
|
199
|
+
|
|
200
|
+
```python
|
|
201
|
+
from hpc_as_api.compute import GlobusComputeClient
|
|
202
|
+
|
|
203
|
+
client = GlobusComputeClient(
|
|
204
|
+
endpoint_id="8d978809-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
|
|
205
|
+
models={
|
|
206
|
+
"qwen25-vl-72b": {
|
|
207
|
+
"hf_name": "Qwen/Qwen2.5-VL-72B-Instruct-AWQ",
|
|
208
|
+
"url": "http://ghi2-002:8000",
|
|
209
|
+
"context_reserve_output": 4096,
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
)
|
|
213
|
+
result = await client.submit_inference(
|
|
214
|
+
messages=[{"role": "user", "content": "Explain quantum entanglement."}],
|
|
215
|
+
model="qwen25-vl-72b",
|
|
216
|
+
)
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## Why
|
|
220
|
+
|
|
221
|
+
HPC clusters run the largest open-source LLMs (72B+ parameters) on GPU hardware that typical cloud users can't afford. But HPC infrastructure has no standard API surface — each cluster has its own SLURM scripts, SSH tunnels, and authentication systems. `hpc-as-api` provides a uniform OpenAI-compatible interface over any vLLM-served model, using [Globus Compute](https://www.globus.org/compute) for authentication and job dispatch (no open ports required on the HPC side).
|
|
222
|
+
|
|
223
|
+
## Architecture
|
|
224
|
+
|
|
225
|
+
```
|
|
226
|
+
Your App / OpenAI Client
|
|
227
|
+
│ POST /v1/chat/completions
|
|
228
|
+
▼
|
|
229
|
+
hpc-as-api (FastAPI)
|
|
230
|
+
│ Globus Compute (AMQP — no HPC firewall holes)
|
|
231
|
+
▼
|
|
232
|
+
HPC Cluster (SLURM)
|
|
233
|
+
│ vLLM HTTP API (internal LAN)
|
|
234
|
+
▼
|
|
235
|
+
GPU Compute Node
|
|
236
|
+
│ tokens flow via WebSocket relay (streamrelay)
|
|
237
|
+
▼
|
|
238
|
+
hpc-as-api → SSE stream → Your App
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
Key design points:
|
|
242
|
+
- **No open ports on HPC**: Globus Compute is outbound-only from the cluster
|
|
243
|
+
- **Real-time streaming**: Tokens stream back via [streamrelay](https://github.com/uicacer/streamrelay) WebSocket relay
|
|
244
|
+
- **E2E encryption**: Optional AES-256-GCM encryption between HPC and consumer (relay sees only ciphertext)
|
|
245
|
+
- **OpenAI-compatible**: Drop-in for any client using the OpenAI SDK
|
|
246
|
+
|
|
247
|
+
## Installation
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
# Base package (no Globus SDK)
|
|
251
|
+
pip install hpc-as-api
|
|
252
|
+
|
|
253
|
+
# With Globus Compute support
|
|
254
|
+
pip install "hpc-as-api[globus]"
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
## Quickstart: Run as a service
|
|
258
|
+
|
|
259
|
+
Set environment variables and start:
|
|
260
|
+
|
|
261
|
+
```bash
|
|
262
|
+
export GLOBUS_COMPUTE_ENDPOINT_ID="your-endpoint-uuid"
|
|
263
|
+
export HPC_MODELS='{"qwen25-vl-72b": {"hf_name": "Qwen/Qwen2.5-VL-72B-Instruct-AWQ", "url": "http://ghi2-002:8000", "context_reserve_output": 4096}}'
|
|
264
|
+
export RELAY_URL="wss://relay.example.com"
|
|
265
|
+
export RELAY_SECRET="your-relay-secret"
|
|
266
|
+
|
|
267
|
+
uvicorn hpc_as_api.app:app --host 0.0.0.0 --port 8001
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
The gateway is now reachable at `http://localhost:8001/v1/chat/completions` with the standard OpenAI API schema.
|
|
271
|
+
|
|
272
|
+
## Embed in an existing FastAPI app
|
|
273
|
+
|
|
274
|
+
```python
|
|
275
|
+
from fastapi import FastAPI
|
|
276
|
+
from hpc_as_api.app import router
|
|
277
|
+
|
|
278
|
+
app = FastAPI()
|
|
279
|
+
app.include_router(router, prefix="/hpc")
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
## Configuration reference
|
|
283
|
+
|
|
284
|
+
| Variable | Default | Description |
|
|
285
|
+
|---|---|---|
|
|
286
|
+
| `GLOBUS_COMPUTE_ENDPOINT_ID` | — | Globus endpoint UUID for the HPC cluster |
|
|
287
|
+
| `HPC_MODELS` | `{}` | JSON dict: model name → HPC config |
|
|
288
|
+
| `RELAY_URL` | — | WebSocket relay URL for token streaming |
|
|
289
|
+
| `RELAY_SECRET` | — | Shared secret for relay auth |
|
|
290
|
+
| `RELAY_ENCRYPTION_KEY` | — | AES-256 hex key for E2E encryption |
|
|
291
|
+
| `USE_GLOBUS_COMPUTE` | `true` | `false` to route directly via SSH tunnel |
|
|
292
|
+
| `LAKESHORE_VLLM_ENDPOINT` | `http://localhost:8000` | Direct vLLM URL (SSH mode) |
|
|
293
|
+
| `HPC_PROXY_HOST` | `0.0.0.0` | Bind host |
|
|
294
|
+
| `HPC_PROXY_PORT` | `8001` | Bind port |
|
|
295
|
+
|
|
296
|
+
### HPC_MODELS schema
|
|
297
|
+
|
|
298
|
+
```json
|
|
299
|
+
{
|
|
300
|
+
"my-model-name": {
|
|
301
|
+
"hf_name": "org/ModelName",
|
|
302
|
+
"url": "http://compute-node:8000",
|
|
303
|
+
"context_reserve_output": 4096
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
## Authentication
|
|
309
|
+
|
|
310
|
+
The gateway supports two auth modes (configured in `hpc_as_api/auth.py`):
|
|
311
|
+
|
|
312
|
+
- **Globus token**: Bearer token from Globus Auth, validated via introspection
|
|
313
|
+
- **API key**: Static key from `HPC_API_KEYS` env var (comma-separated)
|
|
314
|
+
|
|
315
|
+
## Development
|
|
316
|
+
|
|
317
|
+
```bash
|
|
318
|
+
git clone https://github.com/uicacer/hpc-as-api
|
|
319
|
+
cd hpc-as-api
|
|
320
|
+
uv sync --extra dev
|
|
321
|
+
uv run pytest
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
## Related
|
|
325
|
+
|
|
326
|
+
- [streamrelay](https://github.com/uicacer/streamrelay) — WebSocket relay for real-time token streaming from Globus Compute
|
|
327
|
+
- [STREAM](https://github.com/uicacer/stream) — Full tiered LLM routing system that uses hpc-as-api
|
|
328
|
+
|
|
329
|
+
## License
|
|
330
|
+
|
|
331
|
+
Apache 2.0 — see [LICENSE](LICENSE).
|
|
332
|
+
|
|
333
|
+
## Citation
|
|
334
|
+
|
|
335
|
+
If you use hpc-as-api in research, please cite:
|
|
336
|
+
|
|
337
|
+
```bibtex
|
|
338
|
+
@software{nassar2025hpcgateway,
|
|
339
|
+
author = {Nassar, Anas},
|
|
340
|
+
title = {hpc-as-api: OpenAI-compatible API gateway for HPC clusters via Globus Compute},
|
|
341
|
+
year = {2025},
|
|
342
|
+
url = {https://github.com/uicacer/hpc-as-api}
|
|
343
|
+
}
|
|
344
|
+
```
|