Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +9 -0
- tool_server/.venv/lib/python3.12/site-packages/blake3-1.0.5.dist-info/licenses/LICENSE +330 -0
- tool_server/.venv/lib/python3.12/site-packages/blake3/__pycache__/__init__.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/cpuinfo/__pycache__/__init__.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/cpuinfo/__pycache__/__main__.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/cpuinfo/__pycache__/cpuinfo.cpython-312.pyc +3 -0
- tool_server/.venv/lib/python3.12/site-packages/cusparselt/include/cusparseLt.h +371 -0
- tool_server/.venv/lib/python3.12/site-packages/cusparselt/lib/libcusparseLt.so.0 +3 -0
- tool_server/.venv/lib/python3.12/site-packages/fastapi-0.115.0.dist-info/licenses/LICENSE +21 -0
- tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/__init__.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/__main__.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/_compat.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/applications.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/background.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/cli.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/concurrency.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/datastructures.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/encoders.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/exception_handlers.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/exceptions.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/logger.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/param_functions.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/params.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/requests.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/responses.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/routing.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/staticfiles.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/templating.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/testclient.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/types.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/utils.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/websockets.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fastapi/dependencies/__init__.py +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fastapi/dependencies/__pycache__/__init__.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fastapi/dependencies/__pycache__/models.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fastapi/dependencies/__pycache__/utils.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fastapi/dependencies/models.py +37 -0
- tool_server/.venv/lib/python3.12/site-packages/fastapi/dependencies/utils.py +962 -0
- tool_server/.venv/lib/python3.12/site-packages/fastapi/middleware/__init__.py +1 -0
- tool_server/.venv/lib/python3.12/site-packages/fastapi/middleware/__pycache__/__init__.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fastapi/middleware/__pycache__/cors.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fastapi/middleware/__pycache__/gzip.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fastapi/middleware/__pycache__/httpsredirect.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fastapi/middleware/__pycache__/trustedhost.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fastapi/middleware/__pycache__/wsgi.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/fastapi/middleware/cors.py +1 -0
- tool_server/.venv/lib/python3.12/site-packages/fastapi/middleware/gzip.py +1 -0
- tool_server/.venv/lib/python3.12/site-packages/fastapi/middleware/httpsredirect.py +3 -0
- tool_server/.venv/lib/python3.12/site-packages/fastapi/middleware/trustedhost.py +3 -0
- tool_server/.venv/lib/python3.12/site-packages/fastapi/middleware/wsgi.py +1 -0
.gitattributes
CHANGED
|
@@ -3944,3 +3944,12 @@ tool_server/.venv/lib/python3.12/site-packages/numba/tests/__pycache__/test_jitc
|
|
| 3944 |
tool_server/.venv/lib/python3.12/site-packages/numba/tests/__pycache__/test_linalg.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 3945 |
tool_server/.venv/lib/python3.12/site-packages/numba/tests/__pycache__/test_lists.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 3946 |
tool_server/.venv/lib/python3.12/site-packages/numba/tests/__pycache__/test_ufuncs.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3944 |
tool_server/.venv/lib/python3.12/site-packages/numba/tests/__pycache__/test_linalg.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 3945 |
tool_server/.venv/lib/python3.12/site-packages/numba/tests/__pycache__/test_lists.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 3946 |
tool_server/.venv/lib/python3.12/site-packages/numba/tests/__pycache__/test_ufuncs.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 3947 |
+
tool_server/.venv/lib/python3.12/site-packages/numba/tests/__pycache__/test_unicode.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 3948 |
+
tool_server/.venv/lib/python3.12/site-packages/numba/tests/__pycache__/test_stencils.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 3949 |
+
tool_server/.venv/lib/python3.12/site-packages/numba/tests/__pycache__/test_parfors.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 3950 |
+
tool_server/.venv/lib/python3.12/site-packages/numba/tests/__pycache__/test_random.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 3951 |
+
tool_server/.venv/lib/python3.12/site-packages/cpuinfo/__pycache__/cpuinfo.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 3952 |
+
tool_server/.venv/lib/python3.12/site-packages/cusparselt/lib/libcusparseLt.so.0 filter=lfs diff=lfs merge=lfs -text
|
| 3953 |
+
tool_server/.venv/lib/python3.12/site-packages/mpmath/__pycache__/function_docs.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 3954 |
+
tool_server/.venv/lib/python3.12/site-packages/mpmath/tests/__pycache__/test_fp.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 3955 |
+
tool_server/.venv/lib/python3.12/site-packages/mpmath/tests/__pycache__/test_functions2.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
tool_server/.venv/lib/python3.12/site-packages/blake3-1.0.5.dist-info/licenses/LICENSE
ADDED
|
@@ -0,0 +1,330 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
This work is released into the public domain with CC0 1.0. Alternatively, it is
|
| 2 |
+
licensed under the Apache License 2.0.
|
| 3 |
+
|
| 4 |
+
-------------------------------------------------------------------------------
|
| 5 |
+
|
| 6 |
+
Creative Commons Legal Code
|
| 7 |
+
|
| 8 |
+
CC0 1.0 Universal
|
| 9 |
+
|
| 10 |
+
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
|
| 11 |
+
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
|
| 12 |
+
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
|
| 13 |
+
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
|
| 14 |
+
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
|
| 15 |
+
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
|
| 16 |
+
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
|
| 17 |
+
HEREUNDER.
|
| 18 |
+
|
| 19 |
+
Statement of Purpose
|
| 20 |
+
|
| 21 |
+
The laws of most jurisdictions throughout the world automatically confer
|
| 22 |
+
exclusive Copyright and Related Rights (defined below) upon the creator
|
| 23 |
+
and subsequent owner(s) (each and all, an "owner") of an original work of
|
| 24 |
+
authorship and/or a database (each, a "Work").
|
| 25 |
+
|
| 26 |
+
Certain owners wish to permanently relinquish those rights to a Work for
|
| 27 |
+
the purpose of contributing to a commons of creative, cultural and
|
| 28 |
+
scientific works ("Commons") that the public can reliably and without fear
|
| 29 |
+
of later claims of infringement build upon, modify, incorporate in other
|
| 30 |
+
works, reuse and redistribute as freely as possible in any form whatsoever
|
| 31 |
+
and for any purposes, including without limitation commercial purposes.
|
| 32 |
+
These owners may contribute to the Commons to promote the ideal of a free
|
| 33 |
+
culture and the further production of creative, cultural and scientific
|
| 34 |
+
works, or to gain reputation or greater distribution for their Work in
|
| 35 |
+
part through the use and efforts of others.
|
| 36 |
+
|
| 37 |
+
For these and/or other purposes and motivations, and without any
|
| 38 |
+
expectation of additional consideration or compensation, the person
|
| 39 |
+
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
|
| 40 |
+
is an owner of Copyright and Related Rights in the Work, voluntarily
|
| 41 |
+
elects to apply CC0 to the Work and publicly distribute the Work under its
|
| 42 |
+
terms, with knowledge of his or her Copyright and Related Rights in the
|
| 43 |
+
Work and the meaning and intended legal effect of CC0 on those rights.
|
| 44 |
+
|
| 45 |
+
1. Copyright and Related Rights. A Work made available under CC0 may be
|
| 46 |
+
protected by copyright and related or neighboring rights ("Copyright and
|
| 47 |
+
Related Rights"). Copyright and Related Rights include, but are not
|
| 48 |
+
limited to, the following:
|
| 49 |
+
|
| 50 |
+
i. the right to reproduce, adapt, distribute, perform, display,
|
| 51 |
+
communicate, and translate a Work;
|
| 52 |
+
ii. moral rights retained by the original author(s) and/or performer(s);
|
| 53 |
+
iii. publicity and privacy rights pertaining to a person's image or
|
| 54 |
+
likeness depicted in a Work;
|
| 55 |
+
iv. rights protecting against unfair competition in regards to a Work,
|
| 56 |
+
subject to the limitations in paragraph 4(a), below;
|
| 57 |
+
v. rights protecting the extraction, dissemination, use and reuse of data
|
| 58 |
+
in a Work;
|
| 59 |
+
vi. database rights (such as those arising under Directive 96/9/EC of the
|
| 60 |
+
European Parliament and of the Council of 11 March 1996 on the legal
|
| 61 |
+
protection of databases, and under any national implementation
|
| 62 |
+
thereof, including any amended or successor version of such
|
| 63 |
+
directive); and
|
| 64 |
+
vii. other similar, equivalent or corresponding rights throughout the
|
| 65 |
+
world based on applicable law or treaty, and any national
|
| 66 |
+
implementations thereof.
|
| 67 |
+
|
| 68 |
+
2. Waiver. To the greatest extent permitted by, but not in contravention
|
| 69 |
+
of, applicable law, Affirmer hereby overtly, fully, permanently,
|
| 70 |
+
irrevocably and unconditionally waives, abandons, and surrenders all of
|
| 71 |
+
Affirmer's Copyright and Related Rights and associated claims and causes
|
| 72 |
+
of action, whether now known or unknown (including existing as well as
|
| 73 |
+
future claims and causes of action), in the Work (i) in all territories
|
| 74 |
+
worldwide, (ii) for the maximum duration provided by applicable law or
|
| 75 |
+
treaty (including future time extensions), (iii) in any current or future
|
| 76 |
+
medium and for any number of copies, and (iv) for any purpose whatsoever,
|
| 77 |
+
including without limitation commercial, advertising or promotional
|
| 78 |
+
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
|
| 79 |
+
member of the public at large and to the detriment of Affirmer's heirs and
|
| 80 |
+
successors, fully intending that such Waiver shall not be subject to
|
| 81 |
+
revocation, rescission, cancellation, termination, or any other legal or
|
| 82 |
+
equitable action to disrupt the quiet enjoyment of the Work by the public
|
| 83 |
+
as contemplated by Affirmer's express Statement of Purpose.
|
| 84 |
+
|
| 85 |
+
3. Public License Fallback. Should any part of the Waiver for any reason
|
| 86 |
+
be judged legally invalid or ineffective under applicable law, then the
|
| 87 |
+
Waiver shall be preserved to the maximum extent permitted taking into
|
| 88 |
+
account Affirmer's express Statement of Purpose. In addition, to the
|
| 89 |
+
extent the Waiver is so judged Affirmer hereby grants to each affected
|
| 90 |
+
person a royalty-free, non transferable, non sublicensable, non exclusive,
|
| 91 |
+
irrevocable and unconditional license to exercise Affirmer's Copyright and
|
| 92 |
+
Related Rights in the Work (i) in all territories worldwide, (ii) for the
|
| 93 |
+
maximum duration provided by applicable law or treaty (including future
|
| 94 |
+
time extensions), (iii) in any current or future medium and for any number
|
| 95 |
+
of copies, and (iv) for any purpose whatsoever, including without
|
| 96 |
+
limitation commercial, advertising or promotional purposes (the
|
| 97 |
+
"License"). The License shall be deemed effective as of the date CC0 was
|
| 98 |
+
applied by Affirmer to the Work. Should any part of the License for any
|
| 99 |
+
reason be judged legally invalid or ineffective under applicable law, such
|
| 100 |
+
partial invalidity or ineffectiveness shall not invalidate the remainder
|
| 101 |
+
of the License, and in such case Affirmer hereby affirms that he or she
|
| 102 |
+
will not (i) exercise any of his or her remaining Copyright and Related
|
| 103 |
+
Rights in the Work or (ii) assert any associated claims and causes of
|
| 104 |
+
action with respect to the Work, in either case contrary to Affirmer's
|
| 105 |
+
express Statement of Purpose.
|
| 106 |
+
|
| 107 |
+
4. Limitations and Disclaimers.
|
| 108 |
+
|
| 109 |
+
a. No trademark or patent rights held by Affirmer are waived, abandoned,
|
| 110 |
+
surrendered, licensed or otherwise affected by this document.
|
| 111 |
+
b. Affirmer offers the Work as-is and makes no representations or
|
| 112 |
+
warranties of any kind concerning the Work, express, implied,
|
| 113 |
+
statutory or otherwise, including without limitation warranties of
|
| 114 |
+
title, merchantability, fitness for a particular purpose, non
|
| 115 |
+
infringement, or the absence of latent or other defects, accuracy, or
|
| 116 |
+
the present or absence of errors, whether or not discoverable, all to
|
| 117 |
+
the greatest extent permissible under applicable law.
|
| 118 |
+
c. Affirmer disclaims responsibility for clearing rights of other persons
|
| 119 |
+
that may apply to the Work or any use thereof, including without
|
| 120 |
+
limitation any person's Copyright and Related Rights in the Work.
|
| 121 |
+
Further, Affirmer disclaims responsibility for obtaining any necessary
|
| 122 |
+
consents, permissions or other rights required for any use of the
|
| 123 |
+
Work.
|
| 124 |
+
d. Affirmer understands and acknowledges that Creative Commons is not a
|
| 125 |
+
party to this document and has no duty or obligation with respect to
|
| 126 |
+
this CC0 or use of the Work.
|
| 127 |
+
|
| 128 |
+
-------------------------------------------------------------------------------
|
| 129 |
+
|
| 130 |
+
Apache License
|
| 131 |
+
Version 2.0, January 2004
|
| 132 |
+
http://www.apache.org/licenses/
|
| 133 |
+
|
| 134 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
| 135 |
+
|
| 136 |
+
1. Definitions.
|
| 137 |
+
|
| 138 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
| 139 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
| 140 |
+
|
| 141 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
| 142 |
+
the copyright owner that is granting the License.
|
| 143 |
+
|
| 144 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
| 145 |
+
other entities that control, are controlled by, or are under common
|
| 146 |
+
control with that entity. For the purposes of this definition,
|
| 147 |
+
"control" means (i) the power, direct or indirect, to cause the
|
| 148 |
+
direction or management of such entity, whether by contract or
|
| 149 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
| 150 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
| 151 |
+
|
| 152 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
| 153 |
+
exercising permissions granted by this License.
|
| 154 |
+
|
| 155 |
+
"Source" form shall mean the preferred form for making modifications,
|
| 156 |
+
including but not limited to software source code, documentation
|
| 157 |
+
source, and configuration files.
|
| 158 |
+
|
| 159 |
+
"Object" form shall mean any form resulting from mechanical
|
| 160 |
+
transformation or translation of a Source form, including but
|
| 161 |
+
not limited to compiled object code, generated documentation,
|
| 162 |
+
and conversions to other media types.
|
| 163 |
+
|
| 164 |
+
"Work" shall mean the work of authorship, whether in Source or
|
| 165 |
+
Object form, made available under the License, as indicated by a
|
| 166 |
+
copyright notice that is included in or attached to the work
|
| 167 |
+
(an example is provided in the Appendix below).
|
| 168 |
+
|
| 169 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
| 170 |
+
form, that is based on (or derived from) the Work and for which the
|
| 171 |
+
editorial revisions, annotations, elaborations, or other modifications
|
| 172 |
+
represent, as a whole, an original work of authorship. For the purposes
|
| 173 |
+
of this License, Derivative Works shall not include works that remain
|
| 174 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
| 175 |
+
the Work and Derivative Works thereof.
|
| 176 |
+
|
| 177 |
+
"Contribution" shall mean any work of authorship, including
|
| 178 |
+
the original version of the Work and any modifications or additions
|
| 179 |
+
to that Work or Derivative Works thereof, that is intentionally
|
| 180 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
| 181 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
| 182 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
| 183 |
+
means any form of electronic, verbal, or written communication sent
|
| 184 |
+
to the Licensor or its representatives, including but not limited to
|
| 185 |
+
communication on electronic mailing lists, source code control systems,
|
| 186 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
| 187 |
+
Licensor for the purpose of discussing and improving the Work, but
|
| 188 |
+
excluding communication that is conspicuously marked or otherwise
|
| 189 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
| 190 |
+
|
| 191 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
| 192 |
+
on behalf of whom a Contribution has been received by Licensor and
|
| 193 |
+
subsequently incorporated within the Work.
|
| 194 |
+
|
| 195 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
| 196 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 197 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 198 |
+
copyright license to reproduce, prepare Derivative Works of,
|
| 199 |
+
publicly display, publicly perform, sublicense, and distribute the
|
| 200 |
+
Work and such Derivative Works in Source or Object form.
|
| 201 |
+
|
| 202 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
| 203 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 204 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 205 |
+
(except as stated in this section) patent license to make, have made,
|
| 206 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
| 207 |
+
where such license applies only to those patent claims licensable
|
| 208 |
+
by such Contributor that are necessarily infringed by their
|
| 209 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
| 210 |
+
with the Work to which such Contribution(s) was submitted. If You
|
| 211 |
+
institute patent litigation against any entity (including a
|
| 212 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
| 213 |
+
or a Contribution incorporated within the Work constitutes direct
|
| 214 |
+
or contributory patent infringement, then any patent licenses
|
| 215 |
+
granted to You under this License for that Work shall terminate
|
| 216 |
+
as of the date such litigation is filed.
|
| 217 |
+
|
| 218 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
| 219 |
+
Work or Derivative Works thereof in any medium, with or without
|
| 220 |
+
modifications, and in Source or Object form, provided that You
|
| 221 |
+
meet the following conditions:
|
| 222 |
+
|
| 223 |
+
(a) You must give any other recipients of the Work or
|
| 224 |
+
Derivative Works a copy of this License; and
|
| 225 |
+
|
| 226 |
+
(b) You must cause any modified files to carry prominent notices
|
| 227 |
+
stating that You changed the files; and
|
| 228 |
+
|
| 229 |
+
(c) You must retain, in the Source form of any Derivative Works
|
| 230 |
+
that You distribute, all copyright, patent, trademark, and
|
| 231 |
+
attribution notices from the Source form of the Work,
|
| 232 |
+
excluding those notices that do not pertain to any part of
|
| 233 |
+
the Derivative Works; and
|
| 234 |
+
|
| 235 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
| 236 |
+
distribution, then any Derivative Works that You distribute must
|
| 237 |
+
include a readable copy of the attribution notices contained
|
| 238 |
+
within such NOTICE file, excluding those notices that do not
|
| 239 |
+
pertain to any part of the Derivative Works, in at least one
|
| 240 |
+
of the following places: within a NOTICE text file distributed
|
| 241 |
+
as part of the Derivative Works; within the Source form or
|
| 242 |
+
documentation, if provided along with the Derivative Works; or,
|
| 243 |
+
within a display generated by the Derivative Works, if and
|
| 244 |
+
wherever such third-party notices normally appear. The contents
|
| 245 |
+
of the NOTICE file are for informational purposes only and
|
| 246 |
+
do not modify the License. You may add Your own attribution
|
| 247 |
+
notices within Derivative Works that You distribute, alongside
|
| 248 |
+
or as an addendum to the NOTICE text from the Work, provided
|
| 249 |
+
that such additional attribution notices cannot be construed
|
| 250 |
+
as modifying the License.
|
| 251 |
+
|
| 252 |
+
You may add Your own copyright statement to Your modifications and
|
| 253 |
+
may provide additional or different license terms and conditions
|
| 254 |
+
for use, reproduction, or distribution of Your modifications, or
|
| 255 |
+
for any such Derivative Works as a whole, provided Your use,
|
| 256 |
+
reproduction, and distribution of the Work otherwise complies with
|
| 257 |
+
the conditions stated in this License.
|
| 258 |
+
|
| 259 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
| 260 |
+
any Contribution intentionally submitted for inclusion in the Work
|
| 261 |
+
by You to the Licensor shall be under the terms and conditions of
|
| 262 |
+
this License, without any additional terms or conditions.
|
| 263 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
| 264 |
+
the terms of any separate license agreement you may have executed
|
| 265 |
+
with Licensor regarding such Contributions.
|
| 266 |
+
|
| 267 |
+
6. Trademarks. This License does not grant permission to use the trade
|
| 268 |
+
names, trademarks, service marks, or product names of the Licensor,
|
| 269 |
+
except as required for reasonable and customary use in describing the
|
| 270 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
| 271 |
+
|
| 272 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
| 273 |
+
agreed to in writing, Licensor provides the Work (and each
|
| 274 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
| 275 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
| 276 |
+
implied, including, without limitation, any warranties or conditions
|
| 277 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
| 278 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
| 279 |
+
appropriateness of using or redistributing the Work and assume any
|
| 280 |
+
risks associated with Your exercise of permissions under this License.
|
| 281 |
+
|
| 282 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
| 283 |
+
whether in tort (including negligence), contract, or otherwise,
|
| 284 |
+
unless required by applicable law (such as deliberate and grossly
|
| 285 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
| 286 |
+
liable to You for damages, including any direct, indirect, special,
|
| 287 |
+
incidental, or consequential damages of any character arising as a
|
| 288 |
+
result of this License or out of the use or inability to use the
|
| 289 |
+
Work (including but not limited to damages for loss of goodwill,
|
| 290 |
+
work stoppage, computer failure or malfunction, or any and all
|
| 291 |
+
other commercial damages or losses), even if such Contributor
|
| 292 |
+
has been advised of the possibility of such damages.
|
| 293 |
+
|
| 294 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
| 295 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
| 296 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
| 297 |
+
or other liability obligations and/or rights consistent with this
|
| 298 |
+
License. However, in accepting such obligations, You may act only
|
| 299 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
| 300 |
+
of any other Contributor, and only if You agree to indemnify,
|
| 301 |
+
defend, and hold each Contributor harmless for any liability
|
| 302 |
+
incurred by, or claims asserted against, such Contributor by reason
|
| 303 |
+
of your accepting any such warranty or additional liability.
|
| 304 |
+
|
| 305 |
+
END OF TERMS AND CONDITIONS
|
| 306 |
+
|
| 307 |
+
APPENDIX: How to apply the Apache License to your work.
|
| 308 |
+
|
| 309 |
+
To apply the Apache License to your work, attach the following
|
| 310 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
| 311 |
+
replaced with your own identifying information. (Don't include
|
| 312 |
+
the brackets!) The text should be enclosed in the appropriate
|
| 313 |
+
comment syntax for the file format. We also recommend that a
|
| 314 |
+
file or class name and description of purpose be included on the
|
| 315 |
+
same "printed page" as the copyright notice for easier
|
| 316 |
+
identification within third-party archives.
|
| 317 |
+
|
| 318 |
+
Copyright 2020 Jack O'Connor
|
| 319 |
+
|
| 320 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
| 321 |
+
you may not use this file except in compliance with the License.
|
| 322 |
+
You may obtain a copy of the License at
|
| 323 |
+
|
| 324 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
| 325 |
+
|
| 326 |
+
Unless required by applicable law or agreed to in writing, software
|
| 327 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
| 328 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 329 |
+
See the License for the specific language governing permissions and
|
| 330 |
+
limitations under the License.
|
tool_server/.venv/lib/python3.12/site-packages/blake3/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (337 Bytes). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/cpuinfo/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (230 Bytes). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/cpuinfo/__pycache__/__main__.cpython-312.pyc
ADDED
|
Binary file (250 Bytes). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/cpuinfo/__pycache__/cpuinfo.cpython-312.pyc
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d8c036a5b7bbe48794f538a83ce1864230ba04d548b5b78dca3cdddf15f738dc
|
| 3 |
+
size 109071
|
tool_server/.venv/lib/python3.12/site-packages/cusparselt/include/cusparseLt.h
ADDED
|
@@ -0,0 +1,371 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
|
| 3 |
+
*
|
| 4 |
+
* NVIDIA CORPORATION and its licensors retain all intellectual property
|
| 5 |
+
* and proprietary rights in and to this software, related documentation
|
| 6 |
+
* and any modifications thereto. Any use, reproduction, disclosure or
|
| 7 |
+
* distribution of this software and related documentation without an express
|
| 8 |
+
* license agreement from NVIDIA CORPORATION is strictly prohibited.
|
| 9 |
+
*/
|
| 10 |
+
#if !defined(CUSPARSELT_HEADER_)
|
| 11 |
+
#define CUSPARSELT_HEADER_
|
| 12 |
+
|
| 13 |
+
#include "cusparse.h" // cusparseStatus_t
|
| 14 |
+
|
| 15 |
+
#include <cstddef> // size_t
|
| 16 |
+
#include <driver_types.h> // cudaStream_t
|
| 17 |
+
#include <library_types.h> // cudaDataType
|
| 18 |
+
#include <stdint.h> // uint8_t
|
| 19 |
+
|
| 20 |
+
//##############################################################################
|
| 21 |
+
//# CUSPARSELT VERSION INFORMATION
|
| 22 |
+
//##############################################################################
|
| 23 |
+
|
| 24 |
+
#define CUSPARSELT_VER_MAJOR 0
|
| 25 |
+
#define CUSPARSELT_VER_MINOR 6
|
| 26 |
+
#define CUSPARSELT_VER_PATCH 3
|
| 27 |
+
#define CUSPARSELT_VER_BUILD 2
|
| 28 |
+
#define CUSPARSELT_VERSION (CUSPARSELT_VER_MAJOR * 1000 + \
|
| 29 |
+
CUSPARSELT_VER_MINOR * 100 + \
|
| 30 |
+
CUSPARSELT_VER_PATCH)
|
| 31 |
+
|
| 32 |
+
// #############################################################################
|
| 33 |
+
// # MACRO
|
| 34 |
+
// #############################################################################
|
| 35 |
+
|
| 36 |
+
#if !defined(CUSPARSELT_API)
|
| 37 |
+
# if defined(_WIN32)
|
| 38 |
+
# define CUSPARSELT_API __stdcall
|
| 39 |
+
# else
|
| 40 |
+
# define CUSPARSELT_API
|
| 41 |
+
# endif
|
| 42 |
+
#endif
|
| 43 |
+
|
| 44 |
+
//------------------------------------------------------------------------------
|
| 45 |
+
|
| 46 |
+
#if defined(__cplusplus)
|
| 47 |
+
extern "C" {
|
| 48 |
+
#endif // defined(__cplusplus)
|
| 49 |
+
|
| 50 |
+
//##############################################################################
|
| 51 |
+
//# OPAQUE DATA STRUCTURES
|
| 52 |
+
//##############################################################################
|
| 53 |
+
|
| 54 |
+
typedef struct { uint8_t data[13072]; } cusparseLtHandle_t;
|
| 55 |
+
|
| 56 |
+
typedef struct { uint8_t data[13072]; } cusparseLtMatDescriptor_t;
|
| 57 |
+
|
| 58 |
+
typedef struct { uint8_t data[13072]; } cusparseLtMatmulDescriptor_t;
|
| 59 |
+
|
| 60 |
+
typedef struct { uint8_t data[13072]; } cusparseLtMatmulAlgSelection_t;
|
| 61 |
+
|
| 62 |
+
typedef struct { uint8_t data[13072]; } cusparseLtMatmulPlan_t;
|
| 63 |
+
|
| 64 |
+
//##############################################################################
|
| 65 |
+
//# INITIALIZATION, DESTROY
|
| 66 |
+
//##############################################################################
|
| 67 |
+
|
| 68 |
+
cusparseStatus_t CUSPARSELT_API
|
| 69 |
+
cusparseLtInit(cusparseLtHandle_t* handle);
|
| 70 |
+
|
| 71 |
+
cusparseStatus_t CUSPARSELT_API
|
| 72 |
+
cusparseLtDestroy(const cusparseLtHandle_t* handle);
|
| 73 |
+
|
| 74 |
+
cusparseStatus_t CUSPARSELT_API
|
| 75 |
+
cusparseLtGetVersion(const cusparseLtHandle_t* handle,
|
| 76 |
+
int* version);
|
| 77 |
+
|
| 78 |
+
cusparseStatus_t CUSPARSELT_API
|
| 79 |
+
cusparseLtGetProperty(libraryPropertyType propertyType,
|
| 80 |
+
int* value);
|
| 81 |
+
|
| 82 |
+
//##############################################################################
|
| 83 |
+
//# MATRIX DESCRIPTOR
|
| 84 |
+
//##############################################################################
|
| 85 |
+
// Dense Matrix
|
| 86 |
+
|
| 87 |
+
cusparseStatus_t CUSPARSELT_API
|
| 88 |
+
cusparseLtDenseDescriptorInit(const cusparseLtHandle_t* handle,
|
| 89 |
+
cusparseLtMatDescriptor_t* matDescr,
|
| 90 |
+
int64_t rows,
|
| 91 |
+
int64_t cols,
|
| 92 |
+
int64_t ld,
|
| 93 |
+
uint32_t alignment,
|
| 94 |
+
cudaDataType valueType,
|
| 95 |
+
cusparseOrder_t order);
|
| 96 |
+
|
| 97 |
+
//------------------------------------------------------------------------------
|
| 98 |
+
// Structured Matrix
|
| 99 |
+
|
| 100 |
+
typedef enum {
|
| 101 |
+
CUSPARSELT_SPARSITY_50_PERCENT
|
| 102 |
+
} cusparseLtSparsity_t;
|
| 103 |
+
|
| 104 |
+
cusparseStatus_t CUSPARSELT_API
|
| 105 |
+
cusparseLtStructuredDescriptorInit(const cusparseLtHandle_t* handle,
|
| 106 |
+
cusparseLtMatDescriptor_t* matDescr,
|
| 107 |
+
int64_t rows,
|
| 108 |
+
int64_t cols,
|
| 109 |
+
int64_t ld,
|
| 110 |
+
uint32_t alignment,
|
| 111 |
+
cudaDataType valueType,
|
| 112 |
+
cusparseOrder_t order,
|
| 113 |
+
cusparseLtSparsity_t sparsity);
|
| 114 |
+
|
| 115 |
+
cusparseStatus_t CUSPARSELT_API
|
| 116 |
+
cusparseLtMatDescriptorDestroy(const cusparseLtMatDescriptor_t* matDescr);
|
| 117 |
+
|
| 118 |
+
//------------------------------------------------------------------------------
|
| 119 |
+
|
| 120 |
+
typedef enum {
|
| 121 |
+
CUSPARSELT_MAT_NUM_BATCHES, // READ/WRITE
|
| 122 |
+
CUSPARSELT_MAT_BATCH_STRIDE // READ/WRITE
|
| 123 |
+
} cusparseLtMatDescAttribute_t;
|
| 124 |
+
|
| 125 |
+
cusparseStatus_t CUSPARSELT_API
|
| 126 |
+
cusparseLtMatDescSetAttribute(const cusparseLtHandle_t* handle,
|
| 127 |
+
cusparseLtMatDescriptor_t* matmulDescr,
|
| 128 |
+
cusparseLtMatDescAttribute_t matAttribute,
|
| 129 |
+
const void* data,
|
| 130 |
+
size_t dataSize);
|
| 131 |
+
|
| 132 |
+
cusparseStatus_t CUSPARSELT_API
|
| 133 |
+
cusparseLtMatDescGetAttribute(const cusparseLtHandle_t* handle,
|
| 134 |
+
const cusparseLtMatDescriptor_t* matmulDescr,
|
| 135 |
+
cusparseLtMatDescAttribute_t matAttribute,
|
| 136 |
+
void* data,
|
| 137 |
+
size_t dataSize);
|
| 138 |
+
|
| 139 |
+
//##############################################################################
|
| 140 |
+
//# MATMUL DESCRIPTOR
|
| 141 |
+
//##############################################################################
|
| 142 |
+
|
| 143 |
+
typedef enum {
|
| 144 |
+
CUSPARSE_COMPUTE_32I,
|
| 145 |
+
CUSPARSE_COMPUTE_16F,
|
| 146 |
+
CUSPARSE_COMPUTE_32F
|
| 147 |
+
} cusparseComputeType;
|
| 148 |
+
|
| 149 |
+
cusparseStatus_t CUSPARSELT_API
|
| 150 |
+
cusparseLtMatmulDescriptorInit(const cusparseLtHandle_t* handle,
|
| 151 |
+
cusparseLtMatmulDescriptor_t* matmulDescr,
|
| 152 |
+
cusparseOperation_t opA,
|
| 153 |
+
cusparseOperation_t opB,
|
| 154 |
+
const cusparseLtMatDescriptor_t* matA,
|
| 155 |
+
const cusparseLtMatDescriptor_t* matB,
|
| 156 |
+
const cusparseLtMatDescriptor_t* matC,
|
| 157 |
+
const cusparseLtMatDescriptor_t* matD,
|
| 158 |
+
cusparseComputeType computeType);
|
| 159 |
+
|
| 160 |
+
//------------------------------------------------------------------------------
|
| 161 |
+
|
| 162 |
+
typedef enum {
|
| 163 |
+
CUSPARSELT_MATMUL_ACTIVATION_RELU, // READ/WRITE
|
| 164 |
+
CUSPARSELT_MATMUL_ACTIVATION_RELU_UPPERBOUND, // READ/WRITE
|
| 165 |
+
CUSPARSELT_MATMUL_ACTIVATION_RELU_THRESHOLD, // READ/WRITE
|
| 166 |
+
CUSPARSELT_MATMUL_ACTIVATION_GELU, // READ/WRITE
|
| 167 |
+
CUSPARSELT_MATMUL_ACTIVATION_GELU_SCALING, // READ/WRITE
|
| 168 |
+
CUSPARSELT_MATMUL_ALPHA_VECTOR_SCALING, // READ/WRITE
|
| 169 |
+
CUSPARSELT_MATMUL_BETA_VECTOR_SCALING, // READ/WRITE
|
| 170 |
+
CUSPARSELT_MATMUL_BIAS_STRIDE, // READ/WRITE
|
| 171 |
+
CUSPARSELT_MATMUL_BIAS_POINTER, // READ/WRITE
|
| 172 |
+
CUSPARSELT_MATMUL_SPARSE_MAT_POINTER, // READ/WRITE
|
| 173 |
+
} cusparseLtMatmulDescAttribute_t;
|
| 174 |
+
|
| 175 |
+
cusparseStatus_t CUSPARSELT_API
|
| 176 |
+
cusparseLtMatmulDescSetAttribute(const cusparseLtHandle_t* handle,
|
| 177 |
+
cusparseLtMatmulDescriptor_t* matmulDescr,
|
| 178 |
+
cusparseLtMatmulDescAttribute_t matmulAttribute,
|
| 179 |
+
const void* data,
|
| 180 |
+
size_t dataSize);
|
| 181 |
+
|
| 182 |
+
cusparseStatus_t CUSPARSELT_API
|
| 183 |
+
cusparseLtMatmulDescGetAttribute(
|
| 184 |
+
const cusparseLtHandle_t* handle,
|
| 185 |
+
const cusparseLtMatmulDescriptor_t* matmulDescr,
|
| 186 |
+
cusparseLtMatmulDescAttribute_t matmulAttribute,
|
| 187 |
+
void* data,
|
| 188 |
+
size_t dataSize);
|
| 189 |
+
|
| 190 |
+
//##############################################################################
|
| 191 |
+
//# ALGORITHM SELECTION
|
| 192 |
+
//##############################################################################
|
| 193 |
+
|
| 194 |
+
typedef enum {
|
| 195 |
+
CUSPARSELT_MATMUL_ALG_DEFAULT
|
| 196 |
+
} cusparseLtMatmulAlg_t;
|
| 197 |
+
|
| 198 |
+
cusparseStatus_t CUSPARSELT_API
|
| 199 |
+
cusparseLtMatmulAlgSelectionInit(
|
| 200 |
+
const cusparseLtHandle_t* handle,
|
| 201 |
+
cusparseLtMatmulAlgSelection_t* algSelection,
|
| 202 |
+
const cusparseLtMatmulDescriptor_t* matmulDescr,
|
| 203 |
+
cusparseLtMatmulAlg_t alg);
|
| 204 |
+
|
| 205 |
+
typedef enum {
|
| 206 |
+
CUSPARSELT_MATMUL_ALG_CONFIG_ID, // READ/WRITE
|
| 207 |
+
CUSPARSELT_MATMUL_ALG_CONFIG_MAX_ID, // READ-ONLY
|
| 208 |
+
CUSPARSELT_MATMUL_SEARCH_ITERATIONS, // READ/WRITE
|
| 209 |
+
CUSPARSELT_MATMUL_SPLIT_K, // READ/WRITE
|
| 210 |
+
CUSPARSELT_MATMUL_SPLIT_K_MODE, // READ/WRITE
|
| 211 |
+
CUSPARSELT_MATMUL_SPLIT_K_BUFFERS // READ/WRITE
|
| 212 |
+
} cusparseLtMatmulAlgAttribute_t;
|
| 213 |
+
|
| 214 |
+
typedef enum {
|
| 215 |
+
CUSPARSELT_INVALID_MODE = 0,
|
| 216 |
+
CUSPARSELT_SPLIT_K_MODE_ONE_KERNEL = 1,
|
| 217 |
+
CUSPARSELT_SPLIT_K_MODE_TWO_KERNELS = 2
|
| 218 |
+
} cusparseLtSplitKMode_t;
|
| 219 |
+
|
| 220 |
+
cusparseStatus_t CUSPARSELT_API
|
| 221 |
+
cusparseLtMatmulAlgSetAttribute(const cusparseLtHandle_t* handle,
|
| 222 |
+
cusparseLtMatmulAlgSelection_t* algSelection,
|
| 223 |
+
cusparseLtMatmulAlgAttribute_t attribute,
|
| 224 |
+
const void* data,
|
| 225 |
+
size_t dataSize);
|
| 226 |
+
|
| 227 |
+
cusparseStatus_t CUSPARSELT_API
|
| 228 |
+
cusparseLtMatmulAlgGetAttribute(
|
| 229 |
+
const cusparseLtHandle_t* handle,
|
| 230 |
+
const cusparseLtMatmulAlgSelection_t* algSelection,
|
| 231 |
+
cusparseLtMatmulAlgAttribute_t attribute,
|
| 232 |
+
void* data,
|
| 233 |
+
size_t dataSize);
|
| 234 |
+
|
| 235 |
+
//##############################################################################
|
| 236 |
+
//# MATMUL PLAN
|
| 237 |
+
//##############################################################################
|
| 238 |
+
|
| 239 |
+
cusparseStatus_t CUSPARSELT_API
|
| 240 |
+
cusparseLtMatmulGetWorkspace(
|
| 241 |
+
const cusparseLtHandle_t* handle,
|
| 242 |
+
const cusparseLtMatmulPlan_t* plan,
|
| 243 |
+
size_t* workspaceSize);
|
| 244 |
+
|
| 245 |
+
cusparseStatus_t CUSPARSELT_API
|
| 246 |
+
cusparseLtMatmulPlanInit(const cusparseLtHandle_t* handle,
|
| 247 |
+
cusparseLtMatmulPlan_t* plan,
|
| 248 |
+
const cusparseLtMatmulDescriptor_t* matmulDescr,
|
| 249 |
+
const cusparseLtMatmulAlgSelection_t* algSelection);
|
| 250 |
+
|
| 251 |
+
cusparseStatus_t CUSPARSELT_API
|
| 252 |
+
cusparseLtMatmulPlanDestroy(const cusparseLtMatmulPlan_t* plan);
|
| 253 |
+
|
| 254 |
+
//##############################################################################
|
| 255 |
+
//# MATMUL EXECUTION
|
| 256 |
+
//##############################################################################
|
| 257 |
+
|
| 258 |
+
cusparseStatus_t CUSPARSELT_API
|
| 259 |
+
cusparseLtMatmul(const cusparseLtHandle_t* handle,
|
| 260 |
+
const cusparseLtMatmulPlan_t* plan,
|
| 261 |
+
const void* alpha,
|
| 262 |
+
const void* d_A,
|
| 263 |
+
const void* d_B,
|
| 264 |
+
const void* beta,
|
| 265 |
+
const void* d_C,
|
| 266 |
+
void* d_D,
|
| 267 |
+
void* workspace,
|
| 268 |
+
cudaStream_t* streams,
|
| 269 |
+
int32_t numStreams);
|
| 270 |
+
|
| 271 |
+
cusparseStatus_t CUSPARSELT_API
|
| 272 |
+
cusparseLtMatmulSearch(const cusparseLtHandle_t* handle,
|
| 273 |
+
cusparseLtMatmulPlan_t* plan,
|
| 274 |
+
const void* alpha,
|
| 275 |
+
const void* d_A,
|
| 276 |
+
const void* d_B,
|
| 277 |
+
const void* beta,
|
| 278 |
+
const void* d_C,
|
| 279 |
+
void* d_D,
|
| 280 |
+
void* workspace,
|
| 281 |
+
// void* device_buf,
|
| 282 |
+
cudaStream_t* streams,
|
| 283 |
+
int32_t numStreams);
|
| 284 |
+
|
| 285 |
+
//##############################################################################
|
| 286 |
+
//# HELPER ROUTINES
|
| 287 |
+
//##############################################################################
|
| 288 |
+
// PRUNING
|
| 289 |
+
|
| 290 |
+
typedef enum {
|
| 291 |
+
CUSPARSELT_PRUNE_SPMMA_TILE = 0,
|
| 292 |
+
CUSPARSELT_PRUNE_SPMMA_STRIP = 1
|
| 293 |
+
} cusparseLtPruneAlg_t;
|
| 294 |
+
|
| 295 |
+
cusparseStatus_t CUSPARSELT_API
|
| 296 |
+
cusparseLtSpMMAPrune(const cusparseLtHandle_t* handle,
|
| 297 |
+
const cusparseLtMatmulDescriptor_t* matmulDescr,
|
| 298 |
+
const void* d_in,
|
| 299 |
+
void* d_out,
|
| 300 |
+
cusparseLtPruneAlg_t pruneAlg,
|
| 301 |
+
cudaStream_t stream);
|
| 302 |
+
|
| 303 |
+
cusparseStatus_t CUSPARSELT_API
|
| 304 |
+
cusparseLtSpMMAPruneCheck(const cusparseLtHandle_t* handle,
|
| 305 |
+
const cusparseLtMatmulDescriptor_t* matmulDescr,
|
| 306 |
+
const void* d_in,
|
| 307 |
+
int* valid,
|
| 308 |
+
cudaStream_t stream);
|
| 309 |
+
|
| 310 |
+
cusparseStatus_t CUSPARSELT_API
|
| 311 |
+
cusparseLtSpMMAPrune2(const cusparseLtHandle_t* handle,
|
| 312 |
+
const cusparseLtMatDescriptor_t* sparseMatDescr,
|
| 313 |
+
int isSparseA,
|
| 314 |
+
cusparseOperation_t op,
|
| 315 |
+
const void* d_in,
|
| 316 |
+
void* d_out,
|
| 317 |
+
cusparseLtPruneAlg_t pruneAlg,
|
| 318 |
+
cudaStream_t stream);
|
| 319 |
+
|
| 320 |
+
cusparseStatus_t CUSPARSELT_API
|
| 321 |
+
cusparseLtSpMMAPruneCheck2(const cusparseLtHandle_t* handle,
|
| 322 |
+
const cusparseLtMatDescriptor_t* sparseMatDescr,
|
| 323 |
+
int isSparseA,
|
| 324 |
+
cusparseOperation_t op,
|
| 325 |
+
const void* d_in,
|
| 326 |
+
int* d_valid,
|
| 327 |
+
cudaStream_t stream);
|
| 328 |
+
|
| 329 |
+
//------------------------------------------------------------------------------
|
| 330 |
+
// COMPRESSION
|
| 331 |
+
|
| 332 |
+
cusparseStatus_t CUSPARSELT_API
|
| 333 |
+
cusparseLtSpMMACompressedSize(
|
| 334 |
+
const cusparseLtHandle_t* handle,
|
| 335 |
+
const cusparseLtMatmulPlan_t* plan,
|
| 336 |
+
size_t* compressedSize,
|
| 337 |
+
size_t* compressedBufferSize);
|
| 338 |
+
|
| 339 |
+
cusparseStatus_t CUSPARSELT_API
|
| 340 |
+
cusparseLtSpMMACompress(const cusparseLtHandle_t* handle,
|
| 341 |
+
const cusparseLtMatmulPlan_t* plan,
|
| 342 |
+
const void* d_dense,
|
| 343 |
+
void* d_compressed,
|
| 344 |
+
void* d_compressed_buffer,
|
| 345 |
+
cudaStream_t stream);
|
| 346 |
+
|
| 347 |
+
cusparseStatus_t CUSPARSELT_API
|
| 348 |
+
cusparseLtSpMMACompressedSize2(
|
| 349 |
+
const cusparseLtHandle_t* handle,
|
| 350 |
+
const cusparseLtMatDescriptor_t* sparseMatDescr,
|
| 351 |
+
size_t* compressedSize,
|
| 352 |
+
size_t* compressedBufferSize);
|
| 353 |
+
|
| 354 |
+
cusparseStatus_t CUSPARSELT_API
|
| 355 |
+
cusparseLtSpMMACompress2(const cusparseLtHandle_t* handle,
|
| 356 |
+
const cusparseLtMatDescriptor_t* sparseMatDescr,
|
| 357 |
+
int isSparseA,
|
| 358 |
+
cusparseOperation_t op,
|
| 359 |
+
const void* d_dense,
|
| 360 |
+
void* d_compressed,
|
| 361 |
+
void* d_compressed_buffer,
|
| 362 |
+
cudaStream_t stream);
|
| 363 |
+
|
| 364 |
+
//==============================================================================
|
| 365 |
+
//==============================================================================
|
| 366 |
+
|
| 367 |
+
#if defined(__cplusplus)
|
| 368 |
+
}
|
| 369 |
+
#endif // defined(__cplusplus)
|
| 370 |
+
|
| 371 |
+
#endif // !defined(CUSPARSELT_HEADER_)
|
tool_server/.venv/lib/python3.12/site-packages/cusparselt/lib/libcusparseLt.so.0
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c8c9812c891d12ffb2a4dee3134cb62705b17954c753408dfe001853ad051c29
|
| 3 |
+
size 237384129
|
tool_server/.venv/lib/python3.12/site-packages/fastapi-0.115.0.dist-info/licenses/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
The MIT License (MIT)
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2018 Sebastián Ramírez
|
| 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
|
| 13 |
+
all 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
|
| 21 |
+
THE SOFTWARE.
|
tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (1.09 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/__main__.cpython-312.pyc
ADDED
|
Binary file (239 Bytes). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/_compat.cpython-312.pyc
ADDED
|
Binary file (27.6 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/applications.cpython-312.pyc
ADDED
|
Binary file (84.1 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/background.cpython-312.pyc
ADDED
|
Binary file (2.37 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/cli.cpython-312.pyc
ADDED
|
Binary file (653 Bytes). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/concurrency.cpython-312.pyc
ADDED
|
Binary file (1.61 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/datastructures.cpython-312.pyc
ADDED
|
Binary file (8.14 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/encoders.cpython-312.pyc
ADDED
|
Binary file (10.9 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/exception_handlers.cpython-312.pyc
ADDED
|
Binary file (2.07 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/exceptions.cpython-312.pyc
ADDED
|
Binary file (7.16 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/logger.cpython-312.pyc
ADDED
|
Binary file (279 Bytes). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/param_functions.cpython-312.pyc
ADDED
|
Binary file (35.1 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/params.cpython-312.pyc
ADDED
|
Binary file (25 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/requests.cpython-312.pyc
ADDED
|
Binary file (268 Bytes). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/responses.cpython-312.pyc
ADDED
|
Binary file (2.4 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/routing.cpython-312.pyc
ADDED
|
Binary file (82.2 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/staticfiles.cpython-312.pyc
ADDED
|
Binary file (240 Bytes). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/templating.cpython-312.pyc
ADDED
|
Binary file (242 Bytes). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/testclient.cpython-312.pyc
ADDED
|
Binary file (237 Bytes). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/types.cpython-312.pyc
ADDED
|
Binary file (748 Bytes). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/utils.cpython-312.pyc
ADDED
|
Binary file (8.38 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fastapi/__pycache__/websockets.cpython-312.pyc
ADDED
|
Binary file (317 Bytes). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fastapi/dependencies/__init__.py
ADDED
|
File without changes
|
tool_server/.venv/lib/python3.12/site-packages/fastapi/dependencies/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (190 Bytes). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fastapi/dependencies/__pycache__/models.cpython-312.pyc
ADDED
|
Binary file (2.73 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fastapi/dependencies/__pycache__/utils.cpython-312.pyc
ADDED
|
Binary file (37.9 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fastapi/dependencies/models.py
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from dataclasses import dataclass, field
|
| 2 |
+
from typing import Any, Callable, List, Optional, Sequence, Tuple
|
| 3 |
+
|
| 4 |
+
from fastapi._compat import ModelField
|
| 5 |
+
from fastapi.security.base import SecurityBase
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
@dataclass
|
| 9 |
+
class SecurityRequirement:
|
| 10 |
+
security_scheme: SecurityBase
|
| 11 |
+
scopes: Optional[Sequence[str]] = None
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
@dataclass
|
| 15 |
+
class Dependant:
|
| 16 |
+
path_params: List[ModelField] = field(default_factory=list)
|
| 17 |
+
query_params: List[ModelField] = field(default_factory=list)
|
| 18 |
+
header_params: List[ModelField] = field(default_factory=list)
|
| 19 |
+
cookie_params: List[ModelField] = field(default_factory=list)
|
| 20 |
+
body_params: List[ModelField] = field(default_factory=list)
|
| 21 |
+
dependencies: List["Dependant"] = field(default_factory=list)
|
| 22 |
+
security_requirements: List[SecurityRequirement] = field(default_factory=list)
|
| 23 |
+
name: Optional[str] = None
|
| 24 |
+
call: Optional[Callable[..., Any]] = None
|
| 25 |
+
request_param_name: Optional[str] = None
|
| 26 |
+
websocket_param_name: Optional[str] = None
|
| 27 |
+
http_connection_param_name: Optional[str] = None
|
| 28 |
+
response_param_name: Optional[str] = None
|
| 29 |
+
background_tasks_param_name: Optional[str] = None
|
| 30 |
+
security_scopes_param_name: Optional[str] = None
|
| 31 |
+
security_scopes: Optional[List[str]] = None
|
| 32 |
+
use_cache: bool = True
|
| 33 |
+
path: Optional[str] = None
|
| 34 |
+
cache_key: Tuple[Optional[Callable[..., Any]], Tuple[str, ...]] = field(init=False)
|
| 35 |
+
|
| 36 |
+
def __post_init__(self) -> None:
|
| 37 |
+
self.cache_key = (self.call, tuple(sorted(set(self.security_scopes or []))))
|
tool_server/.venv/lib/python3.12/site-packages/fastapi/dependencies/utils.py
ADDED
|
@@ -0,0 +1,962 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import inspect
|
| 2 |
+
from contextlib import AsyncExitStack, contextmanager
|
| 3 |
+
from copy import copy, deepcopy
|
| 4 |
+
from dataclasses import dataclass
|
| 5 |
+
from typing import (
|
| 6 |
+
Any,
|
| 7 |
+
Callable,
|
| 8 |
+
Coroutine,
|
| 9 |
+
Dict,
|
| 10 |
+
ForwardRef,
|
| 11 |
+
List,
|
| 12 |
+
Mapping,
|
| 13 |
+
Optional,
|
| 14 |
+
Sequence,
|
| 15 |
+
Tuple,
|
| 16 |
+
Type,
|
| 17 |
+
Union,
|
| 18 |
+
cast,
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
import anyio
|
| 22 |
+
from fastapi import params
|
| 23 |
+
from fastapi._compat import (
|
| 24 |
+
PYDANTIC_V2,
|
| 25 |
+
ErrorWrapper,
|
| 26 |
+
ModelField,
|
| 27 |
+
Required,
|
| 28 |
+
Undefined,
|
| 29 |
+
_regenerate_error_with_loc,
|
| 30 |
+
copy_field_info,
|
| 31 |
+
create_body_model,
|
| 32 |
+
evaluate_forwardref,
|
| 33 |
+
field_annotation_is_scalar,
|
| 34 |
+
get_annotation_from_field_info,
|
| 35 |
+
get_cached_model_fields,
|
| 36 |
+
get_missing_field_error,
|
| 37 |
+
is_bytes_field,
|
| 38 |
+
is_bytes_sequence_field,
|
| 39 |
+
is_scalar_field,
|
| 40 |
+
is_scalar_sequence_field,
|
| 41 |
+
is_sequence_field,
|
| 42 |
+
is_uploadfile_or_nonable_uploadfile_annotation,
|
| 43 |
+
is_uploadfile_sequence_annotation,
|
| 44 |
+
lenient_issubclass,
|
| 45 |
+
sequence_types,
|
| 46 |
+
serialize_sequence_value,
|
| 47 |
+
value_is_sequence,
|
| 48 |
+
)
|
| 49 |
+
from fastapi.background import BackgroundTasks
|
| 50 |
+
from fastapi.concurrency import (
|
| 51 |
+
asynccontextmanager,
|
| 52 |
+
contextmanager_in_threadpool,
|
| 53 |
+
)
|
| 54 |
+
from fastapi.dependencies.models import Dependant, SecurityRequirement
|
| 55 |
+
from fastapi.logger import logger
|
| 56 |
+
from fastapi.security.base import SecurityBase
|
| 57 |
+
from fastapi.security.oauth2 import OAuth2, SecurityScopes
|
| 58 |
+
from fastapi.security.open_id_connect_url import OpenIdConnect
|
| 59 |
+
from fastapi.utils import create_model_field, get_path_param_names
|
| 60 |
+
from pydantic import BaseModel
|
| 61 |
+
from pydantic.fields import FieldInfo
|
| 62 |
+
from starlette.background import BackgroundTasks as StarletteBackgroundTasks
|
| 63 |
+
from starlette.concurrency import run_in_threadpool
|
| 64 |
+
from starlette.datastructures import (
|
| 65 |
+
FormData,
|
| 66 |
+
Headers,
|
| 67 |
+
ImmutableMultiDict,
|
| 68 |
+
QueryParams,
|
| 69 |
+
UploadFile,
|
| 70 |
+
)
|
| 71 |
+
from starlette.requests import HTTPConnection, Request
|
| 72 |
+
from starlette.responses import Response
|
| 73 |
+
from starlette.websockets import WebSocket
|
| 74 |
+
from typing_extensions import Annotated, get_args, get_origin
|
| 75 |
+
|
| 76 |
+
multipart_not_installed_error = (
|
| 77 |
+
'Form data requires "python-multipart" to be installed. \n'
|
| 78 |
+
'You can install "python-multipart" with: \n\n'
|
| 79 |
+
"pip install python-multipart\n"
|
| 80 |
+
)
|
| 81 |
+
multipart_incorrect_install_error = (
|
| 82 |
+
'Form data requires "python-multipart" to be installed. '
|
| 83 |
+
'It seems you installed "multipart" instead. \n'
|
| 84 |
+
'You can remove "multipart" with: \n\n'
|
| 85 |
+
"pip uninstall multipart\n\n"
|
| 86 |
+
'And then install "python-multipart" with: \n\n'
|
| 87 |
+
"pip install python-multipart\n"
|
| 88 |
+
)
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
def ensure_multipart_is_installed() -> None:
|
| 92 |
+
try:
|
| 93 |
+
# __version__ is available in both multiparts, and can be mocked
|
| 94 |
+
from multipart import __version__ # type: ignore
|
| 95 |
+
|
| 96 |
+
assert __version__
|
| 97 |
+
try:
|
| 98 |
+
# parse_options_header is only available in the right multipart
|
| 99 |
+
from multipart.multipart import parse_options_header # type: ignore
|
| 100 |
+
|
| 101 |
+
assert parse_options_header
|
| 102 |
+
except ImportError:
|
| 103 |
+
logger.error(multipart_incorrect_install_error)
|
| 104 |
+
raise RuntimeError(multipart_incorrect_install_error) from None
|
| 105 |
+
except ImportError:
|
| 106 |
+
logger.error(multipart_not_installed_error)
|
| 107 |
+
raise RuntimeError(multipart_not_installed_error) from None
|
| 108 |
+
|
| 109 |
+
|
| 110 |
+
def get_param_sub_dependant(
|
| 111 |
+
*,
|
| 112 |
+
param_name: str,
|
| 113 |
+
depends: params.Depends,
|
| 114 |
+
path: str,
|
| 115 |
+
security_scopes: Optional[List[str]] = None,
|
| 116 |
+
) -> Dependant:
|
| 117 |
+
assert depends.dependency
|
| 118 |
+
return get_sub_dependant(
|
| 119 |
+
depends=depends,
|
| 120 |
+
dependency=depends.dependency,
|
| 121 |
+
path=path,
|
| 122 |
+
name=param_name,
|
| 123 |
+
security_scopes=security_scopes,
|
| 124 |
+
)
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
def get_parameterless_sub_dependant(*, depends: params.Depends, path: str) -> Dependant:
|
| 128 |
+
assert callable(
|
| 129 |
+
depends.dependency
|
| 130 |
+
), "A parameter-less dependency must have a callable dependency"
|
| 131 |
+
return get_sub_dependant(depends=depends, dependency=depends.dependency, path=path)
|
| 132 |
+
|
| 133 |
+
|
| 134 |
+
def get_sub_dependant(
|
| 135 |
+
*,
|
| 136 |
+
depends: params.Depends,
|
| 137 |
+
dependency: Callable[..., Any],
|
| 138 |
+
path: str,
|
| 139 |
+
name: Optional[str] = None,
|
| 140 |
+
security_scopes: Optional[List[str]] = None,
|
| 141 |
+
) -> Dependant:
|
| 142 |
+
security_requirement = None
|
| 143 |
+
security_scopes = security_scopes or []
|
| 144 |
+
if isinstance(depends, params.Security):
|
| 145 |
+
dependency_scopes = depends.scopes
|
| 146 |
+
security_scopes.extend(dependency_scopes)
|
| 147 |
+
if isinstance(dependency, SecurityBase):
|
| 148 |
+
use_scopes: List[str] = []
|
| 149 |
+
if isinstance(dependency, (OAuth2, OpenIdConnect)):
|
| 150 |
+
use_scopes = security_scopes
|
| 151 |
+
security_requirement = SecurityRequirement(
|
| 152 |
+
security_scheme=dependency, scopes=use_scopes
|
| 153 |
+
)
|
| 154 |
+
sub_dependant = get_dependant(
|
| 155 |
+
path=path,
|
| 156 |
+
call=dependency,
|
| 157 |
+
name=name,
|
| 158 |
+
security_scopes=security_scopes,
|
| 159 |
+
use_cache=depends.use_cache,
|
| 160 |
+
)
|
| 161 |
+
if security_requirement:
|
| 162 |
+
sub_dependant.security_requirements.append(security_requirement)
|
| 163 |
+
return sub_dependant
|
| 164 |
+
|
| 165 |
+
|
| 166 |
+
CacheKey = Tuple[Optional[Callable[..., Any]], Tuple[str, ...]]
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
def get_flat_dependant(
|
| 170 |
+
dependant: Dependant,
|
| 171 |
+
*,
|
| 172 |
+
skip_repeats: bool = False,
|
| 173 |
+
visited: Optional[List[CacheKey]] = None,
|
| 174 |
+
) -> Dependant:
|
| 175 |
+
if visited is None:
|
| 176 |
+
visited = []
|
| 177 |
+
visited.append(dependant.cache_key)
|
| 178 |
+
|
| 179 |
+
flat_dependant = Dependant(
|
| 180 |
+
path_params=dependant.path_params.copy(),
|
| 181 |
+
query_params=dependant.query_params.copy(),
|
| 182 |
+
header_params=dependant.header_params.copy(),
|
| 183 |
+
cookie_params=dependant.cookie_params.copy(),
|
| 184 |
+
body_params=dependant.body_params.copy(),
|
| 185 |
+
security_requirements=dependant.security_requirements.copy(),
|
| 186 |
+
use_cache=dependant.use_cache,
|
| 187 |
+
path=dependant.path,
|
| 188 |
+
)
|
| 189 |
+
for sub_dependant in dependant.dependencies:
|
| 190 |
+
if skip_repeats and sub_dependant.cache_key in visited:
|
| 191 |
+
continue
|
| 192 |
+
flat_sub = get_flat_dependant(
|
| 193 |
+
sub_dependant, skip_repeats=skip_repeats, visited=visited
|
| 194 |
+
)
|
| 195 |
+
flat_dependant.path_params.extend(flat_sub.path_params)
|
| 196 |
+
flat_dependant.query_params.extend(flat_sub.query_params)
|
| 197 |
+
flat_dependant.header_params.extend(flat_sub.header_params)
|
| 198 |
+
flat_dependant.cookie_params.extend(flat_sub.cookie_params)
|
| 199 |
+
flat_dependant.body_params.extend(flat_sub.body_params)
|
| 200 |
+
flat_dependant.security_requirements.extend(flat_sub.security_requirements)
|
| 201 |
+
return flat_dependant
|
| 202 |
+
|
| 203 |
+
|
| 204 |
+
def _get_flat_fields_from_params(fields: List[ModelField]) -> List[ModelField]:
|
| 205 |
+
if not fields:
|
| 206 |
+
return fields
|
| 207 |
+
first_field = fields[0]
|
| 208 |
+
if len(fields) == 1 and lenient_issubclass(first_field.type_, BaseModel):
|
| 209 |
+
fields_to_extract = get_cached_model_fields(first_field.type_)
|
| 210 |
+
return fields_to_extract
|
| 211 |
+
return fields
|
| 212 |
+
|
| 213 |
+
|
| 214 |
+
def get_flat_params(dependant: Dependant) -> List[ModelField]:
|
| 215 |
+
flat_dependant = get_flat_dependant(dependant, skip_repeats=True)
|
| 216 |
+
path_params = _get_flat_fields_from_params(flat_dependant.path_params)
|
| 217 |
+
query_params = _get_flat_fields_from_params(flat_dependant.query_params)
|
| 218 |
+
header_params = _get_flat_fields_from_params(flat_dependant.header_params)
|
| 219 |
+
cookie_params = _get_flat_fields_from_params(flat_dependant.cookie_params)
|
| 220 |
+
return path_params + query_params + header_params + cookie_params
|
| 221 |
+
|
| 222 |
+
|
| 223 |
+
def get_typed_signature(call: Callable[..., Any]) -> inspect.Signature:
|
| 224 |
+
signature = inspect.signature(call)
|
| 225 |
+
globalns = getattr(call, "__globals__", {})
|
| 226 |
+
typed_params = [
|
| 227 |
+
inspect.Parameter(
|
| 228 |
+
name=param.name,
|
| 229 |
+
kind=param.kind,
|
| 230 |
+
default=param.default,
|
| 231 |
+
annotation=get_typed_annotation(param.annotation, globalns),
|
| 232 |
+
)
|
| 233 |
+
for param in signature.parameters.values()
|
| 234 |
+
]
|
| 235 |
+
typed_signature = inspect.Signature(typed_params)
|
| 236 |
+
return typed_signature
|
| 237 |
+
|
| 238 |
+
|
| 239 |
+
def get_typed_annotation(annotation: Any, globalns: Dict[str, Any]) -> Any:
|
| 240 |
+
if isinstance(annotation, str):
|
| 241 |
+
annotation = ForwardRef(annotation)
|
| 242 |
+
annotation = evaluate_forwardref(annotation, globalns, globalns)
|
| 243 |
+
return annotation
|
| 244 |
+
|
| 245 |
+
|
| 246 |
+
def get_typed_return_annotation(call: Callable[..., Any]) -> Any:
|
| 247 |
+
signature = inspect.signature(call)
|
| 248 |
+
annotation = signature.return_annotation
|
| 249 |
+
|
| 250 |
+
if annotation is inspect.Signature.empty:
|
| 251 |
+
return None
|
| 252 |
+
|
| 253 |
+
globalns = getattr(call, "__globals__", {})
|
| 254 |
+
return get_typed_annotation(annotation, globalns)
|
| 255 |
+
|
| 256 |
+
|
| 257 |
+
def get_dependant(
|
| 258 |
+
*,
|
| 259 |
+
path: str,
|
| 260 |
+
call: Callable[..., Any],
|
| 261 |
+
name: Optional[str] = None,
|
| 262 |
+
security_scopes: Optional[List[str]] = None,
|
| 263 |
+
use_cache: bool = True,
|
| 264 |
+
) -> Dependant:
|
| 265 |
+
path_param_names = get_path_param_names(path)
|
| 266 |
+
endpoint_signature = get_typed_signature(call)
|
| 267 |
+
signature_params = endpoint_signature.parameters
|
| 268 |
+
dependant = Dependant(
|
| 269 |
+
call=call,
|
| 270 |
+
name=name,
|
| 271 |
+
path=path,
|
| 272 |
+
security_scopes=security_scopes,
|
| 273 |
+
use_cache=use_cache,
|
| 274 |
+
)
|
| 275 |
+
for param_name, param in signature_params.items():
|
| 276 |
+
is_path_param = param_name in path_param_names
|
| 277 |
+
param_details = analyze_param(
|
| 278 |
+
param_name=param_name,
|
| 279 |
+
annotation=param.annotation,
|
| 280 |
+
value=param.default,
|
| 281 |
+
is_path_param=is_path_param,
|
| 282 |
+
)
|
| 283 |
+
if param_details.depends is not None:
|
| 284 |
+
sub_dependant = get_param_sub_dependant(
|
| 285 |
+
param_name=param_name,
|
| 286 |
+
depends=param_details.depends,
|
| 287 |
+
path=path,
|
| 288 |
+
security_scopes=security_scopes,
|
| 289 |
+
)
|
| 290 |
+
dependant.dependencies.append(sub_dependant)
|
| 291 |
+
continue
|
| 292 |
+
if add_non_field_param_to_dependency(
|
| 293 |
+
param_name=param_name,
|
| 294 |
+
type_annotation=param_details.type_annotation,
|
| 295 |
+
dependant=dependant,
|
| 296 |
+
):
|
| 297 |
+
assert (
|
| 298 |
+
param_details.field is None
|
| 299 |
+
), f"Cannot specify multiple FastAPI annotations for {param_name!r}"
|
| 300 |
+
continue
|
| 301 |
+
assert param_details.field is not None
|
| 302 |
+
if isinstance(param_details.field.field_info, params.Body):
|
| 303 |
+
dependant.body_params.append(param_details.field)
|
| 304 |
+
else:
|
| 305 |
+
add_param_to_fields(field=param_details.field, dependant=dependant)
|
| 306 |
+
return dependant
|
| 307 |
+
|
| 308 |
+
|
| 309 |
+
def add_non_field_param_to_dependency(
|
| 310 |
+
*, param_name: str, type_annotation: Any, dependant: Dependant
|
| 311 |
+
) -> Optional[bool]:
|
| 312 |
+
if lenient_issubclass(type_annotation, Request):
|
| 313 |
+
dependant.request_param_name = param_name
|
| 314 |
+
return True
|
| 315 |
+
elif lenient_issubclass(type_annotation, WebSocket):
|
| 316 |
+
dependant.websocket_param_name = param_name
|
| 317 |
+
return True
|
| 318 |
+
elif lenient_issubclass(type_annotation, HTTPConnection):
|
| 319 |
+
dependant.http_connection_param_name = param_name
|
| 320 |
+
return True
|
| 321 |
+
elif lenient_issubclass(type_annotation, Response):
|
| 322 |
+
dependant.response_param_name = param_name
|
| 323 |
+
return True
|
| 324 |
+
elif lenient_issubclass(type_annotation, StarletteBackgroundTasks):
|
| 325 |
+
dependant.background_tasks_param_name = param_name
|
| 326 |
+
return True
|
| 327 |
+
elif lenient_issubclass(type_annotation, SecurityScopes):
|
| 328 |
+
dependant.security_scopes_param_name = param_name
|
| 329 |
+
return True
|
| 330 |
+
return None
|
| 331 |
+
|
| 332 |
+
|
| 333 |
+
@dataclass
|
| 334 |
+
class ParamDetails:
|
| 335 |
+
type_annotation: Any
|
| 336 |
+
depends: Optional[params.Depends]
|
| 337 |
+
field: Optional[ModelField]
|
| 338 |
+
|
| 339 |
+
|
| 340 |
+
def analyze_param(
|
| 341 |
+
*,
|
| 342 |
+
param_name: str,
|
| 343 |
+
annotation: Any,
|
| 344 |
+
value: Any,
|
| 345 |
+
is_path_param: bool,
|
| 346 |
+
) -> ParamDetails:
|
| 347 |
+
field_info = None
|
| 348 |
+
depends = None
|
| 349 |
+
type_annotation: Any = Any
|
| 350 |
+
use_annotation: Any = Any
|
| 351 |
+
if annotation is not inspect.Signature.empty:
|
| 352 |
+
use_annotation = annotation
|
| 353 |
+
type_annotation = annotation
|
| 354 |
+
# Extract Annotated info
|
| 355 |
+
if get_origin(use_annotation) is Annotated:
|
| 356 |
+
annotated_args = get_args(annotation)
|
| 357 |
+
type_annotation = annotated_args[0]
|
| 358 |
+
fastapi_annotations = [
|
| 359 |
+
arg
|
| 360 |
+
for arg in annotated_args[1:]
|
| 361 |
+
if isinstance(arg, (FieldInfo, params.Depends))
|
| 362 |
+
]
|
| 363 |
+
fastapi_specific_annotations = [
|
| 364 |
+
arg
|
| 365 |
+
for arg in fastapi_annotations
|
| 366 |
+
if isinstance(arg, (params.Param, params.Body, params.Depends))
|
| 367 |
+
]
|
| 368 |
+
if fastapi_specific_annotations:
|
| 369 |
+
fastapi_annotation: Union[FieldInfo, params.Depends, None] = (
|
| 370 |
+
fastapi_specific_annotations[-1]
|
| 371 |
+
)
|
| 372 |
+
else:
|
| 373 |
+
fastapi_annotation = None
|
| 374 |
+
# Set default for Annotated FieldInfo
|
| 375 |
+
if isinstance(fastapi_annotation, FieldInfo):
|
| 376 |
+
# Copy `field_info` because we mutate `field_info.default` below.
|
| 377 |
+
field_info = copy_field_info(
|
| 378 |
+
field_info=fastapi_annotation, annotation=use_annotation
|
| 379 |
+
)
|
| 380 |
+
assert field_info.default is Undefined or field_info.default is Required, (
|
| 381 |
+
f"`{field_info.__class__.__name__}` default value cannot be set in"
|
| 382 |
+
f" `Annotated` for {param_name!r}. Set the default value with `=` instead."
|
| 383 |
+
)
|
| 384 |
+
if value is not inspect.Signature.empty:
|
| 385 |
+
assert not is_path_param, "Path parameters cannot have default values"
|
| 386 |
+
field_info.default = value
|
| 387 |
+
else:
|
| 388 |
+
field_info.default = Required
|
| 389 |
+
# Get Annotated Depends
|
| 390 |
+
elif isinstance(fastapi_annotation, params.Depends):
|
| 391 |
+
depends = fastapi_annotation
|
| 392 |
+
# Get Depends from default value
|
| 393 |
+
if isinstance(value, params.Depends):
|
| 394 |
+
assert depends is None, (
|
| 395 |
+
"Cannot specify `Depends` in `Annotated` and default value"
|
| 396 |
+
f" together for {param_name!r}"
|
| 397 |
+
)
|
| 398 |
+
assert field_info is None, (
|
| 399 |
+
"Cannot specify a FastAPI annotation in `Annotated` and `Depends` as a"
|
| 400 |
+
f" default value together for {param_name!r}"
|
| 401 |
+
)
|
| 402 |
+
depends = value
|
| 403 |
+
# Get FieldInfo from default value
|
| 404 |
+
elif isinstance(value, FieldInfo):
|
| 405 |
+
assert field_info is None, (
|
| 406 |
+
"Cannot specify FastAPI annotations in `Annotated` and default value"
|
| 407 |
+
f" together for {param_name!r}"
|
| 408 |
+
)
|
| 409 |
+
field_info = value
|
| 410 |
+
if PYDANTIC_V2:
|
| 411 |
+
field_info.annotation = type_annotation
|
| 412 |
+
|
| 413 |
+
# Get Depends from type annotation
|
| 414 |
+
if depends is not None and depends.dependency is None:
|
| 415 |
+
# Copy `depends` before mutating it
|
| 416 |
+
depends = copy(depends)
|
| 417 |
+
depends.dependency = type_annotation
|
| 418 |
+
|
| 419 |
+
# Handle non-param type annotations like Request
|
| 420 |
+
if lenient_issubclass(
|
| 421 |
+
type_annotation,
|
| 422 |
+
(
|
| 423 |
+
Request,
|
| 424 |
+
WebSocket,
|
| 425 |
+
HTTPConnection,
|
| 426 |
+
Response,
|
| 427 |
+
StarletteBackgroundTasks,
|
| 428 |
+
SecurityScopes,
|
| 429 |
+
),
|
| 430 |
+
):
|
| 431 |
+
assert depends is None, f"Cannot specify `Depends` for type {type_annotation!r}"
|
| 432 |
+
assert (
|
| 433 |
+
field_info is None
|
| 434 |
+
), f"Cannot specify FastAPI annotation for type {type_annotation!r}"
|
| 435 |
+
# Handle default assignations, neither field_info nor depends was not found in Annotated nor default value
|
| 436 |
+
elif field_info is None and depends is None:
|
| 437 |
+
default_value = value if value is not inspect.Signature.empty else Required
|
| 438 |
+
if is_path_param:
|
| 439 |
+
# We might check here that `default_value is Required`, but the fact is that the same
|
| 440 |
+
# parameter might sometimes be a path parameter and sometimes not. See
|
| 441 |
+
# `tests/test_infer_param_optionality.py` for an example.
|
| 442 |
+
field_info = params.Path(annotation=use_annotation)
|
| 443 |
+
elif is_uploadfile_or_nonable_uploadfile_annotation(
|
| 444 |
+
type_annotation
|
| 445 |
+
) or is_uploadfile_sequence_annotation(type_annotation):
|
| 446 |
+
field_info = params.File(annotation=use_annotation, default=default_value)
|
| 447 |
+
elif not field_annotation_is_scalar(annotation=type_annotation):
|
| 448 |
+
field_info = params.Body(annotation=use_annotation, default=default_value)
|
| 449 |
+
else:
|
| 450 |
+
field_info = params.Query(annotation=use_annotation, default=default_value)
|
| 451 |
+
|
| 452 |
+
field = None
|
| 453 |
+
# It's a field_info, not a dependency
|
| 454 |
+
if field_info is not None:
|
| 455 |
+
# Handle field_info.in_
|
| 456 |
+
if is_path_param:
|
| 457 |
+
assert isinstance(field_info, params.Path), (
|
| 458 |
+
f"Cannot use `{field_info.__class__.__name__}` for path param"
|
| 459 |
+
f" {param_name!r}"
|
| 460 |
+
)
|
| 461 |
+
elif (
|
| 462 |
+
isinstance(field_info, params.Param)
|
| 463 |
+
and getattr(field_info, "in_", None) is None
|
| 464 |
+
):
|
| 465 |
+
field_info.in_ = params.ParamTypes.query
|
| 466 |
+
use_annotation_from_field_info = get_annotation_from_field_info(
|
| 467 |
+
use_annotation,
|
| 468 |
+
field_info,
|
| 469 |
+
param_name,
|
| 470 |
+
)
|
| 471 |
+
if isinstance(field_info, params.Form):
|
| 472 |
+
ensure_multipart_is_installed()
|
| 473 |
+
if not field_info.alias and getattr(field_info, "convert_underscores", None):
|
| 474 |
+
alias = param_name.replace("_", "-")
|
| 475 |
+
else:
|
| 476 |
+
alias = field_info.alias or param_name
|
| 477 |
+
field_info.alias = alias
|
| 478 |
+
field = create_model_field(
|
| 479 |
+
name=param_name,
|
| 480 |
+
type_=use_annotation_from_field_info,
|
| 481 |
+
default=field_info.default,
|
| 482 |
+
alias=alias,
|
| 483 |
+
required=field_info.default in (Required, Undefined),
|
| 484 |
+
field_info=field_info,
|
| 485 |
+
)
|
| 486 |
+
if is_path_param:
|
| 487 |
+
assert is_scalar_field(
|
| 488 |
+
field=field
|
| 489 |
+
), "Path params must be of one of the supported types"
|
| 490 |
+
elif isinstance(field_info, params.Query):
|
| 491 |
+
assert (
|
| 492 |
+
is_scalar_field(field)
|
| 493 |
+
or is_scalar_sequence_field(field)
|
| 494 |
+
or (
|
| 495 |
+
lenient_issubclass(field.type_, BaseModel)
|
| 496 |
+
# For Pydantic v1
|
| 497 |
+
and getattr(field, "shape", 1) == 1
|
| 498 |
+
)
|
| 499 |
+
)
|
| 500 |
+
|
| 501 |
+
return ParamDetails(type_annotation=type_annotation, depends=depends, field=field)
|
| 502 |
+
|
| 503 |
+
|
| 504 |
+
def add_param_to_fields(*, field: ModelField, dependant: Dependant) -> None:
|
| 505 |
+
field_info = field.field_info
|
| 506 |
+
field_info_in = getattr(field_info, "in_", None)
|
| 507 |
+
if field_info_in == params.ParamTypes.path:
|
| 508 |
+
dependant.path_params.append(field)
|
| 509 |
+
elif field_info_in == params.ParamTypes.query:
|
| 510 |
+
dependant.query_params.append(field)
|
| 511 |
+
elif field_info_in == params.ParamTypes.header:
|
| 512 |
+
dependant.header_params.append(field)
|
| 513 |
+
else:
|
| 514 |
+
assert (
|
| 515 |
+
field_info_in == params.ParamTypes.cookie
|
| 516 |
+
), f"non-body parameters must be in path, query, header or cookie: {field.name}"
|
| 517 |
+
dependant.cookie_params.append(field)
|
| 518 |
+
|
| 519 |
+
|
| 520 |
+
def is_coroutine_callable(call: Callable[..., Any]) -> bool:
|
| 521 |
+
if inspect.isroutine(call):
|
| 522 |
+
return inspect.iscoroutinefunction(call)
|
| 523 |
+
if inspect.isclass(call):
|
| 524 |
+
return False
|
| 525 |
+
dunder_call = getattr(call, "__call__", None) # noqa: B004
|
| 526 |
+
return inspect.iscoroutinefunction(dunder_call)
|
| 527 |
+
|
| 528 |
+
|
| 529 |
+
def is_async_gen_callable(call: Callable[..., Any]) -> bool:
|
| 530 |
+
if inspect.isasyncgenfunction(call):
|
| 531 |
+
return True
|
| 532 |
+
dunder_call = getattr(call, "__call__", None) # noqa: B004
|
| 533 |
+
return inspect.isasyncgenfunction(dunder_call)
|
| 534 |
+
|
| 535 |
+
|
| 536 |
+
def is_gen_callable(call: Callable[..., Any]) -> bool:
|
| 537 |
+
if inspect.isgeneratorfunction(call):
|
| 538 |
+
return True
|
| 539 |
+
dunder_call = getattr(call, "__call__", None) # noqa: B004
|
| 540 |
+
return inspect.isgeneratorfunction(dunder_call)
|
| 541 |
+
|
| 542 |
+
|
| 543 |
+
async def solve_generator(
|
| 544 |
+
*, call: Callable[..., Any], stack: AsyncExitStack, sub_values: Dict[str, Any]
|
| 545 |
+
) -> Any:
|
| 546 |
+
if is_gen_callable(call):
|
| 547 |
+
cm = contextmanager_in_threadpool(contextmanager(call)(**sub_values))
|
| 548 |
+
elif is_async_gen_callable(call):
|
| 549 |
+
cm = asynccontextmanager(call)(**sub_values)
|
| 550 |
+
return await stack.enter_async_context(cm)
|
| 551 |
+
|
| 552 |
+
|
| 553 |
+
@dataclass
|
| 554 |
+
class SolvedDependency:
|
| 555 |
+
values: Dict[str, Any]
|
| 556 |
+
errors: List[Any]
|
| 557 |
+
background_tasks: Optional[StarletteBackgroundTasks]
|
| 558 |
+
response: Response
|
| 559 |
+
dependency_cache: Dict[Tuple[Callable[..., Any], Tuple[str]], Any]
|
| 560 |
+
|
| 561 |
+
|
| 562 |
+
async def solve_dependencies(
|
| 563 |
+
*,
|
| 564 |
+
request: Union[Request, WebSocket],
|
| 565 |
+
dependant: Dependant,
|
| 566 |
+
body: Optional[Union[Dict[str, Any], FormData]] = None,
|
| 567 |
+
background_tasks: Optional[StarletteBackgroundTasks] = None,
|
| 568 |
+
response: Optional[Response] = None,
|
| 569 |
+
dependency_overrides_provider: Optional[Any] = None,
|
| 570 |
+
dependency_cache: Optional[Dict[Tuple[Callable[..., Any], Tuple[str]], Any]] = None,
|
| 571 |
+
async_exit_stack: AsyncExitStack,
|
| 572 |
+
embed_body_fields: bool,
|
| 573 |
+
) -> SolvedDependency:
|
| 574 |
+
values: Dict[str, Any] = {}
|
| 575 |
+
errors: List[Any] = []
|
| 576 |
+
if response is None:
|
| 577 |
+
response = Response()
|
| 578 |
+
del response.headers["content-length"]
|
| 579 |
+
response.status_code = None # type: ignore
|
| 580 |
+
dependency_cache = dependency_cache or {}
|
| 581 |
+
sub_dependant: Dependant
|
| 582 |
+
for sub_dependant in dependant.dependencies:
|
| 583 |
+
sub_dependant.call = cast(Callable[..., Any], sub_dependant.call)
|
| 584 |
+
sub_dependant.cache_key = cast(
|
| 585 |
+
Tuple[Callable[..., Any], Tuple[str]], sub_dependant.cache_key
|
| 586 |
+
)
|
| 587 |
+
call = sub_dependant.call
|
| 588 |
+
use_sub_dependant = sub_dependant
|
| 589 |
+
if (
|
| 590 |
+
dependency_overrides_provider
|
| 591 |
+
and dependency_overrides_provider.dependency_overrides
|
| 592 |
+
):
|
| 593 |
+
original_call = sub_dependant.call
|
| 594 |
+
call = getattr(
|
| 595 |
+
dependency_overrides_provider, "dependency_overrides", {}
|
| 596 |
+
).get(original_call, original_call)
|
| 597 |
+
use_path: str = sub_dependant.path # type: ignore
|
| 598 |
+
use_sub_dependant = get_dependant(
|
| 599 |
+
path=use_path,
|
| 600 |
+
call=call,
|
| 601 |
+
name=sub_dependant.name,
|
| 602 |
+
security_scopes=sub_dependant.security_scopes,
|
| 603 |
+
)
|
| 604 |
+
|
| 605 |
+
solved_result = await solve_dependencies(
|
| 606 |
+
request=request,
|
| 607 |
+
dependant=use_sub_dependant,
|
| 608 |
+
body=body,
|
| 609 |
+
background_tasks=background_tasks,
|
| 610 |
+
response=response,
|
| 611 |
+
dependency_overrides_provider=dependency_overrides_provider,
|
| 612 |
+
dependency_cache=dependency_cache,
|
| 613 |
+
async_exit_stack=async_exit_stack,
|
| 614 |
+
embed_body_fields=embed_body_fields,
|
| 615 |
+
)
|
| 616 |
+
background_tasks = solved_result.background_tasks
|
| 617 |
+
dependency_cache.update(solved_result.dependency_cache)
|
| 618 |
+
if solved_result.errors:
|
| 619 |
+
errors.extend(solved_result.errors)
|
| 620 |
+
continue
|
| 621 |
+
if sub_dependant.use_cache and sub_dependant.cache_key in dependency_cache:
|
| 622 |
+
solved = dependency_cache[sub_dependant.cache_key]
|
| 623 |
+
elif is_gen_callable(call) or is_async_gen_callable(call):
|
| 624 |
+
solved = await solve_generator(
|
| 625 |
+
call=call, stack=async_exit_stack, sub_values=solved_result.values
|
| 626 |
+
)
|
| 627 |
+
elif is_coroutine_callable(call):
|
| 628 |
+
solved = await call(**solved_result.values)
|
| 629 |
+
else:
|
| 630 |
+
solved = await run_in_threadpool(call, **solved_result.values)
|
| 631 |
+
if sub_dependant.name is not None:
|
| 632 |
+
values[sub_dependant.name] = solved
|
| 633 |
+
if sub_dependant.cache_key not in dependency_cache:
|
| 634 |
+
dependency_cache[sub_dependant.cache_key] = solved
|
| 635 |
+
path_values, path_errors = request_params_to_args(
|
| 636 |
+
dependant.path_params, request.path_params
|
| 637 |
+
)
|
| 638 |
+
query_values, query_errors = request_params_to_args(
|
| 639 |
+
dependant.query_params, request.query_params
|
| 640 |
+
)
|
| 641 |
+
header_values, header_errors = request_params_to_args(
|
| 642 |
+
dependant.header_params, request.headers
|
| 643 |
+
)
|
| 644 |
+
cookie_values, cookie_errors = request_params_to_args(
|
| 645 |
+
dependant.cookie_params, request.cookies
|
| 646 |
+
)
|
| 647 |
+
values.update(path_values)
|
| 648 |
+
values.update(query_values)
|
| 649 |
+
values.update(header_values)
|
| 650 |
+
values.update(cookie_values)
|
| 651 |
+
errors += path_errors + query_errors + header_errors + cookie_errors
|
| 652 |
+
if dependant.body_params:
|
| 653 |
+
(
|
| 654 |
+
body_values,
|
| 655 |
+
body_errors,
|
| 656 |
+
) = await request_body_to_args( # body_params checked above
|
| 657 |
+
body_fields=dependant.body_params,
|
| 658 |
+
received_body=body,
|
| 659 |
+
embed_body_fields=embed_body_fields,
|
| 660 |
+
)
|
| 661 |
+
values.update(body_values)
|
| 662 |
+
errors.extend(body_errors)
|
| 663 |
+
if dependant.http_connection_param_name:
|
| 664 |
+
values[dependant.http_connection_param_name] = request
|
| 665 |
+
if dependant.request_param_name and isinstance(request, Request):
|
| 666 |
+
values[dependant.request_param_name] = request
|
| 667 |
+
elif dependant.websocket_param_name and isinstance(request, WebSocket):
|
| 668 |
+
values[dependant.websocket_param_name] = request
|
| 669 |
+
if dependant.background_tasks_param_name:
|
| 670 |
+
if background_tasks is None:
|
| 671 |
+
background_tasks = BackgroundTasks()
|
| 672 |
+
values[dependant.background_tasks_param_name] = background_tasks
|
| 673 |
+
if dependant.response_param_name:
|
| 674 |
+
values[dependant.response_param_name] = response
|
| 675 |
+
if dependant.security_scopes_param_name:
|
| 676 |
+
values[dependant.security_scopes_param_name] = SecurityScopes(
|
| 677 |
+
scopes=dependant.security_scopes
|
| 678 |
+
)
|
| 679 |
+
return SolvedDependency(
|
| 680 |
+
values=values,
|
| 681 |
+
errors=errors,
|
| 682 |
+
background_tasks=background_tasks,
|
| 683 |
+
response=response,
|
| 684 |
+
dependency_cache=dependency_cache,
|
| 685 |
+
)
|
| 686 |
+
|
| 687 |
+
|
| 688 |
+
def _validate_value_with_model_field(
|
| 689 |
+
*, field: ModelField, value: Any, values: Dict[str, Any], loc: Tuple[str, ...]
|
| 690 |
+
) -> Tuple[Any, List[Any]]:
|
| 691 |
+
if value is None:
|
| 692 |
+
if field.required:
|
| 693 |
+
return None, [get_missing_field_error(loc=loc)]
|
| 694 |
+
else:
|
| 695 |
+
return deepcopy(field.default), []
|
| 696 |
+
v_, errors_ = field.validate(value, values, loc=loc)
|
| 697 |
+
if isinstance(errors_, ErrorWrapper):
|
| 698 |
+
return None, [errors_]
|
| 699 |
+
elif isinstance(errors_, list):
|
| 700 |
+
new_errors = _regenerate_error_with_loc(errors=errors_, loc_prefix=())
|
| 701 |
+
return None, new_errors
|
| 702 |
+
else:
|
| 703 |
+
return v_, []
|
| 704 |
+
|
| 705 |
+
|
| 706 |
+
def _get_multidict_value(
|
| 707 |
+
field: ModelField, values: Mapping[str, Any], alias: Union[str, None] = None
|
| 708 |
+
) -> Any:
|
| 709 |
+
alias = alias or field.alias
|
| 710 |
+
if is_sequence_field(field) and isinstance(values, (ImmutableMultiDict, Headers)):
|
| 711 |
+
value = values.getlist(alias)
|
| 712 |
+
else:
|
| 713 |
+
value = values.get(alias, None)
|
| 714 |
+
if (
|
| 715 |
+
value is None
|
| 716 |
+
or (
|
| 717 |
+
isinstance(field.field_info, params.Form)
|
| 718 |
+
and isinstance(value, str) # For type checks
|
| 719 |
+
and value == ""
|
| 720 |
+
)
|
| 721 |
+
or (is_sequence_field(field) and len(value) == 0)
|
| 722 |
+
):
|
| 723 |
+
if field.required:
|
| 724 |
+
return
|
| 725 |
+
else:
|
| 726 |
+
return deepcopy(field.default)
|
| 727 |
+
return value
|
| 728 |
+
|
| 729 |
+
|
| 730 |
+
def request_params_to_args(
|
| 731 |
+
fields: Sequence[ModelField],
|
| 732 |
+
received_params: Union[Mapping[str, Any], QueryParams, Headers],
|
| 733 |
+
) -> Tuple[Dict[str, Any], List[Any]]:
|
| 734 |
+
values: Dict[str, Any] = {}
|
| 735 |
+
errors: List[Dict[str, Any]] = []
|
| 736 |
+
|
| 737 |
+
if not fields:
|
| 738 |
+
return values, errors
|
| 739 |
+
|
| 740 |
+
first_field = fields[0]
|
| 741 |
+
fields_to_extract = fields
|
| 742 |
+
single_not_embedded_field = False
|
| 743 |
+
if len(fields) == 1 and lenient_issubclass(first_field.type_, BaseModel):
|
| 744 |
+
fields_to_extract = get_cached_model_fields(first_field.type_)
|
| 745 |
+
single_not_embedded_field = True
|
| 746 |
+
|
| 747 |
+
params_to_process: Dict[str, Any] = {}
|
| 748 |
+
|
| 749 |
+
processed_keys = set()
|
| 750 |
+
|
| 751 |
+
for field in fields_to_extract:
|
| 752 |
+
alias = None
|
| 753 |
+
if isinstance(received_params, Headers):
|
| 754 |
+
# Handle fields extracted from a Pydantic Model for a header, each field
|
| 755 |
+
# doesn't have a FieldInfo of type Header with the default convert_underscores=True
|
| 756 |
+
convert_underscores = getattr(field.field_info, "convert_underscores", True)
|
| 757 |
+
if convert_underscores:
|
| 758 |
+
alias = (
|
| 759 |
+
field.alias
|
| 760 |
+
if field.alias != field.name
|
| 761 |
+
else field.name.replace("_", "-")
|
| 762 |
+
)
|
| 763 |
+
value = _get_multidict_value(field, received_params, alias=alias)
|
| 764 |
+
if value is not None:
|
| 765 |
+
params_to_process[field.name] = value
|
| 766 |
+
processed_keys.add(alias or field.alias)
|
| 767 |
+
processed_keys.add(field.name)
|
| 768 |
+
|
| 769 |
+
for key, value in received_params.items():
|
| 770 |
+
if key not in processed_keys:
|
| 771 |
+
params_to_process[key] = value
|
| 772 |
+
|
| 773 |
+
if single_not_embedded_field:
|
| 774 |
+
field_info = first_field.field_info
|
| 775 |
+
assert isinstance(
|
| 776 |
+
field_info, params.Param
|
| 777 |
+
), "Params must be subclasses of Param"
|
| 778 |
+
loc: Tuple[str, ...] = (field_info.in_.value,)
|
| 779 |
+
v_, errors_ = _validate_value_with_model_field(
|
| 780 |
+
field=first_field, value=params_to_process, values=values, loc=loc
|
| 781 |
+
)
|
| 782 |
+
return {first_field.name: v_}, errors_
|
| 783 |
+
|
| 784 |
+
for field in fields:
|
| 785 |
+
value = _get_multidict_value(field, received_params)
|
| 786 |
+
field_info = field.field_info
|
| 787 |
+
assert isinstance(
|
| 788 |
+
field_info, params.Param
|
| 789 |
+
), "Params must be subclasses of Param"
|
| 790 |
+
loc = (field_info.in_.value, field.alias)
|
| 791 |
+
v_, errors_ = _validate_value_with_model_field(
|
| 792 |
+
field=field, value=value, values=values, loc=loc
|
| 793 |
+
)
|
| 794 |
+
if errors_:
|
| 795 |
+
errors.extend(errors_)
|
| 796 |
+
else:
|
| 797 |
+
values[field.name] = v_
|
| 798 |
+
return values, errors
|
| 799 |
+
|
| 800 |
+
|
| 801 |
+
def _should_embed_body_fields(fields: List[ModelField]) -> bool:
|
| 802 |
+
if not fields:
|
| 803 |
+
return False
|
| 804 |
+
# More than one dependency could have the same field, it would show up as multiple
|
| 805 |
+
# fields but it's the same one, so count them by name
|
| 806 |
+
body_param_names_set = {field.name for field in fields}
|
| 807 |
+
# A top level field has to be a single field, not multiple
|
| 808 |
+
if len(body_param_names_set) > 1:
|
| 809 |
+
return True
|
| 810 |
+
first_field = fields[0]
|
| 811 |
+
# If it explicitly specifies it is embedded, it has to be embedded
|
| 812 |
+
if getattr(first_field.field_info, "embed", None):
|
| 813 |
+
return True
|
| 814 |
+
# If it's a Form (or File) field, it has to be a BaseModel to be top level
|
| 815 |
+
# otherwise it has to be embedded, so that the key value pair can be extracted
|
| 816 |
+
if isinstance(first_field.field_info, params.Form) and not lenient_issubclass(
|
| 817 |
+
first_field.type_, BaseModel
|
| 818 |
+
):
|
| 819 |
+
return True
|
| 820 |
+
return False
|
| 821 |
+
|
| 822 |
+
|
| 823 |
+
async def _extract_form_body(
|
| 824 |
+
body_fields: List[ModelField],
|
| 825 |
+
received_body: FormData,
|
| 826 |
+
) -> Dict[str, Any]:
|
| 827 |
+
values = {}
|
| 828 |
+
first_field = body_fields[0]
|
| 829 |
+
first_field_info = first_field.field_info
|
| 830 |
+
|
| 831 |
+
for field in body_fields:
|
| 832 |
+
value = _get_multidict_value(field, received_body)
|
| 833 |
+
if (
|
| 834 |
+
isinstance(first_field_info, params.File)
|
| 835 |
+
and is_bytes_field(field)
|
| 836 |
+
and isinstance(value, UploadFile)
|
| 837 |
+
):
|
| 838 |
+
value = await value.read()
|
| 839 |
+
elif (
|
| 840 |
+
is_bytes_sequence_field(field)
|
| 841 |
+
and isinstance(first_field_info, params.File)
|
| 842 |
+
and value_is_sequence(value)
|
| 843 |
+
):
|
| 844 |
+
# For types
|
| 845 |
+
assert isinstance(value, sequence_types) # type: ignore[arg-type]
|
| 846 |
+
results: List[Union[bytes, str]] = []
|
| 847 |
+
|
| 848 |
+
async def process_fn(
|
| 849 |
+
fn: Callable[[], Coroutine[Any, Any, Any]],
|
| 850 |
+
) -> None:
|
| 851 |
+
result = await fn()
|
| 852 |
+
results.append(result) # noqa: B023
|
| 853 |
+
|
| 854 |
+
async with anyio.create_task_group() as tg:
|
| 855 |
+
for sub_value in value:
|
| 856 |
+
tg.start_soon(process_fn, sub_value.read)
|
| 857 |
+
value = serialize_sequence_value(field=field, value=results)
|
| 858 |
+
if value is not None:
|
| 859 |
+
values[field.alias] = value
|
| 860 |
+
for key, value in received_body.items():
|
| 861 |
+
if key not in values:
|
| 862 |
+
values[key] = value
|
| 863 |
+
return values
|
| 864 |
+
|
| 865 |
+
|
| 866 |
+
async def request_body_to_args(
|
| 867 |
+
body_fields: List[ModelField],
|
| 868 |
+
received_body: Optional[Union[Dict[str, Any], FormData]],
|
| 869 |
+
embed_body_fields: bool,
|
| 870 |
+
) -> Tuple[Dict[str, Any], List[Dict[str, Any]]]:
|
| 871 |
+
values: Dict[str, Any] = {}
|
| 872 |
+
errors: List[Dict[str, Any]] = []
|
| 873 |
+
assert body_fields, "request_body_to_args() should be called with fields"
|
| 874 |
+
single_not_embedded_field = len(body_fields) == 1 and not embed_body_fields
|
| 875 |
+
first_field = body_fields[0]
|
| 876 |
+
body_to_process = received_body
|
| 877 |
+
|
| 878 |
+
fields_to_extract: List[ModelField] = body_fields
|
| 879 |
+
|
| 880 |
+
if single_not_embedded_field and lenient_issubclass(first_field.type_, BaseModel):
|
| 881 |
+
fields_to_extract = get_cached_model_fields(first_field.type_)
|
| 882 |
+
|
| 883 |
+
if isinstance(received_body, FormData):
|
| 884 |
+
body_to_process = await _extract_form_body(fields_to_extract, received_body)
|
| 885 |
+
|
| 886 |
+
if single_not_embedded_field:
|
| 887 |
+
loc: Tuple[str, ...] = ("body",)
|
| 888 |
+
v_, errors_ = _validate_value_with_model_field(
|
| 889 |
+
field=first_field, value=body_to_process, values=values, loc=loc
|
| 890 |
+
)
|
| 891 |
+
return {first_field.name: v_}, errors_
|
| 892 |
+
for field in body_fields:
|
| 893 |
+
loc = ("body", field.alias)
|
| 894 |
+
value: Optional[Any] = None
|
| 895 |
+
if body_to_process is not None:
|
| 896 |
+
try:
|
| 897 |
+
value = body_to_process.get(field.alias)
|
| 898 |
+
# If the received body is a list, not a dict
|
| 899 |
+
except AttributeError:
|
| 900 |
+
errors.append(get_missing_field_error(loc))
|
| 901 |
+
continue
|
| 902 |
+
v_, errors_ = _validate_value_with_model_field(
|
| 903 |
+
field=field, value=value, values=values, loc=loc
|
| 904 |
+
)
|
| 905 |
+
if errors_:
|
| 906 |
+
errors.extend(errors_)
|
| 907 |
+
else:
|
| 908 |
+
values[field.name] = v_
|
| 909 |
+
return values, errors
|
| 910 |
+
|
| 911 |
+
|
| 912 |
+
def get_body_field(
|
| 913 |
+
*, flat_dependant: Dependant, name: str, embed_body_fields: bool
|
| 914 |
+
) -> Optional[ModelField]:
|
| 915 |
+
"""
|
| 916 |
+
Get a ModelField representing the request body for a path operation, combining
|
| 917 |
+
all body parameters into a single field if necessary.
|
| 918 |
+
|
| 919 |
+
Used to check if it's form data (with `isinstance(body_field, params.Form)`)
|
| 920 |
+
or JSON and to generate the JSON Schema for a request body.
|
| 921 |
+
|
| 922 |
+
This is **not** used to validate/parse the request body, that's done with each
|
| 923 |
+
individual body parameter.
|
| 924 |
+
"""
|
| 925 |
+
if not flat_dependant.body_params:
|
| 926 |
+
return None
|
| 927 |
+
first_param = flat_dependant.body_params[0]
|
| 928 |
+
if not embed_body_fields:
|
| 929 |
+
return first_param
|
| 930 |
+
model_name = "Body_" + name
|
| 931 |
+
BodyModel = create_body_model(
|
| 932 |
+
fields=flat_dependant.body_params, model_name=model_name
|
| 933 |
+
)
|
| 934 |
+
required = any(True for f in flat_dependant.body_params if f.required)
|
| 935 |
+
BodyFieldInfo_kwargs: Dict[str, Any] = {
|
| 936 |
+
"annotation": BodyModel,
|
| 937 |
+
"alias": "body",
|
| 938 |
+
}
|
| 939 |
+
if not required:
|
| 940 |
+
BodyFieldInfo_kwargs["default"] = None
|
| 941 |
+
if any(isinstance(f.field_info, params.File) for f in flat_dependant.body_params):
|
| 942 |
+
BodyFieldInfo: Type[params.Body] = params.File
|
| 943 |
+
elif any(isinstance(f.field_info, params.Form) for f in flat_dependant.body_params):
|
| 944 |
+
BodyFieldInfo = params.Form
|
| 945 |
+
else:
|
| 946 |
+
BodyFieldInfo = params.Body
|
| 947 |
+
|
| 948 |
+
body_param_media_types = [
|
| 949 |
+
f.field_info.media_type
|
| 950 |
+
for f in flat_dependant.body_params
|
| 951 |
+
if isinstance(f.field_info, params.Body)
|
| 952 |
+
]
|
| 953 |
+
if len(set(body_param_media_types)) == 1:
|
| 954 |
+
BodyFieldInfo_kwargs["media_type"] = body_param_media_types[0]
|
| 955 |
+
final_field = create_model_field(
|
| 956 |
+
name="body",
|
| 957 |
+
type_=BodyModel,
|
| 958 |
+
required=required,
|
| 959 |
+
alias="body",
|
| 960 |
+
field_info=BodyFieldInfo(**BodyFieldInfo_kwargs),
|
| 961 |
+
)
|
| 962 |
+
return final_field
|
tool_server/.venv/lib/python3.12/site-packages/fastapi/middleware/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
from starlette.middleware import Middleware as Middleware
|
tool_server/.venv/lib/python3.12/site-packages/fastapi/middleware/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (246 Bytes). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fastapi/middleware/__pycache__/cors.cpython-312.pyc
ADDED
|
Binary file (251 Bytes). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fastapi/middleware/__pycache__/gzip.cpython-312.pyc
ADDED
|
Binary file (251 Bytes). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fastapi/middleware/__pycache__/httpsredirect.cpython-312.pyc
ADDED
|
Binary file (280 Bytes). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fastapi/middleware/__pycache__/trustedhost.cpython-312.pyc
ADDED
|
Binary file (274 Bytes). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fastapi/middleware/__pycache__/wsgi.cpython-312.pyc
ADDED
|
Binary file (251 Bytes). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/fastapi/middleware/cors.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
from starlette.middleware.cors import CORSMiddleware as CORSMiddleware # noqa
|
tool_server/.venv/lib/python3.12/site-packages/fastapi/middleware/gzip.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
from starlette.middleware.gzip import GZipMiddleware as GZipMiddleware # noqa
|
tool_server/.venv/lib/python3.12/site-packages/fastapi/middleware/httpsredirect.py
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from starlette.middleware.httpsredirect import ( # noqa
|
| 2 |
+
HTTPSRedirectMiddleware as HTTPSRedirectMiddleware,
|
| 3 |
+
)
|
tool_server/.venv/lib/python3.12/site-packages/fastapi/middleware/trustedhost.py
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from starlette.middleware.trustedhost import ( # noqa
|
| 2 |
+
TrustedHostMiddleware as TrustedHostMiddleware,
|
| 3 |
+
)
|
tool_server/.venv/lib/python3.12/site-packages/fastapi/middleware/wsgi.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
from starlette.middleware.wsgi import WSGIMiddleware as WSGIMiddleware # noqa
|