neuroglia-python 0.0.23__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. neuroglia_python-0.0.23/LICENSE +201 -0
  2. neuroglia_python-0.0.23/PKG-INFO +127 -0
  3. neuroglia_python-0.0.23/README.md +98 -0
  4. neuroglia_python-0.0.23/pyproject.toml +42 -0
  5. neuroglia_python-0.0.23/src/neuroglia/__init__.py +0 -0
  6. neuroglia_python-0.0.23/src/neuroglia/core/__init__.py +4 -0
  7. neuroglia_python-0.0.23/src/neuroglia/core/module_loader.py +13 -0
  8. neuroglia_python-0.0.23/src/neuroglia/core/operation_result.py +11 -0
  9. neuroglia_python-0.0.23/src/neuroglia/core/problem_details.py +25 -0
  10. neuroglia_python-0.0.23/src/neuroglia/core/type_extensions.py +75 -0
  11. neuroglia_python-0.0.23/src/neuroglia/core/type_finder.py +24 -0
  12. neuroglia_python-0.0.23/src/neuroglia/data/__init__.py +1 -0
  13. neuroglia_python-0.0.23/src/neuroglia/data/abstractions.py +124 -0
  14. neuroglia_python-0.0.23/src/neuroglia/data/infrastructure/__init__.py +0 -0
  15. neuroglia_python-0.0.23/src/neuroglia/data/infrastructure/abstractions.py +78 -0
  16. neuroglia_python-0.0.23/src/neuroglia/data/infrastructure/event_sourcing/__init__.py +0 -0
  17. neuroglia_python-0.0.23/src/neuroglia/data/infrastructure/event_sourcing/abstractions.py +126 -0
  18. neuroglia_python-0.0.23/src/neuroglia/data/infrastructure/event_sourcing/event_sourcing_repository.py +77 -0
  19. neuroglia_python-0.0.23/src/neuroglia/data/infrastructure/event_sourcing/event_store/__init__.py +0 -0
  20. neuroglia_python-0.0.23/src/neuroglia/data/infrastructure/event_sourcing/event_store/event_store.py +175 -0
  21. neuroglia_python-0.0.23/src/neuroglia/data/infrastructure/event_sourcing/read_model_reconciliator.py +62 -0
  22. neuroglia_python-0.0.23/src/neuroglia/data/infrastructure/memory/__init__.py +1 -0
  23. neuroglia_python-0.0.23/src/neuroglia/data/infrastructure/memory/memory_repository.py +29 -0
  24. neuroglia_python-0.0.23/src/neuroglia/data/infrastructure/mongo/__init__.py +0 -0
  25. neuroglia_python-0.0.23/src/neuroglia/data/infrastructure/mongo/mongo_repository.py +331 -0
  26. neuroglia_python-0.0.23/src/neuroglia/data/queries/generic/__init__.py +2 -0
  27. neuroglia_python-0.0.23/src/neuroglia/data/queries/generic/get_by_id_query.py +30 -0
  28. neuroglia_python-0.0.23/src/neuroglia/data/queries/generic/list_query.py +23 -0
  29. neuroglia_python-0.0.23/src/neuroglia/data/queryable.py +175 -0
  30. neuroglia_python-0.0.23/src/neuroglia/dependency_injection/__init__.py +1 -0
  31. neuroglia_python-0.0.23/src/neuroglia/dependency_injection/service_provider.py +341 -0
  32. neuroglia_python-0.0.23/src/neuroglia/eventing/cloud_events/__init__.py +1 -0
  33. neuroglia_python-0.0.23/src/neuroglia/eventing/cloud_events/cloud_event.py +72 -0
  34. neuroglia_python-0.0.23/src/neuroglia/eventing/cloud_events/decorators.py +5 -0
  35. neuroglia_python-0.0.23/src/neuroglia/eventing/cloud_events/infrastructure/__init__.py +4 -0
  36. neuroglia_python-0.0.23/src/neuroglia/eventing/cloud_events/infrastructure/cloud_event_bus.py +11 -0
  37. neuroglia_python-0.0.23/src/neuroglia/eventing/cloud_events/infrastructure/cloud_event_ingestor.py +74 -0
  38. neuroglia_python-0.0.23/src/neuroglia/eventing/cloud_events/infrastructure/cloud_event_middleware.py +39 -0
  39. neuroglia_python-0.0.23/src/neuroglia/eventing/cloud_events/infrastructure/cloud_event_publisher.py +103 -0
  40. neuroglia_python-0.0.23/src/neuroglia/expressions/__init__.py +0 -0
  41. neuroglia_python-0.0.23/src/neuroglia/expressions/javascript_expression_translator.py +147 -0
  42. neuroglia_python-0.0.23/src/neuroglia/hosting/__init__.py +0 -0
  43. neuroglia_python-0.0.23/src/neuroglia/hosting/abstractions.py +141 -0
  44. neuroglia_python-0.0.23/src/neuroglia/hosting/configuration/data_access_layer.py +50 -0
  45. neuroglia_python-0.0.23/src/neuroglia/hosting/web.py +87 -0
  46. neuroglia_python-0.0.23/src/neuroglia/integration/__init__.py +0 -0
  47. neuroglia_python-0.0.23/src/neuroglia/integration/models.py +18 -0
  48. neuroglia_python-0.0.23/src/neuroglia/mapping/__init__.py +1 -0
  49. neuroglia_python-0.0.23/src/neuroglia/mapping/mapper.py +238 -0
  50. neuroglia_python-0.0.23/src/neuroglia/mediation/__init__.py +1 -0
  51. neuroglia_python-0.0.23/src/neuroglia/mediation/mediator.py +182 -0
  52. neuroglia_python-0.0.23/src/neuroglia/mvc/__init__.py +0 -0
  53. neuroglia_python-0.0.23/src/neuroglia/mvc/controller_base.py +72 -0
  54. neuroglia_python-0.0.23/src/neuroglia/reactive/__init__.py +1 -0
  55. neuroglia_python-0.0.23/src/neuroglia/reactive/rx_async.py +16 -0
  56. neuroglia_python-0.0.23/src/neuroglia/serialization/__init__.py +0 -0
  57. neuroglia_python-0.0.23/src/neuroglia/serialization/abstractions.py +30 -0
  58. neuroglia_python-0.0.23/src/neuroglia/serialization/json.py +212 -0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,127 @@
1
+ Metadata-Version: 2.1
2
+ Name: neuroglia-python
3
+ Version: 0.0.23
4
+ Summary: Port from .NET to Python of the Neuroglia Framework
5
+ License: Apache
6
+ Author: Charles d'Avernas
7
+ Author-email: charles.davernas@neuroglia.io
8
+ Requires-Python: >=3.12,<4.0
9
+ Classifier: License :: Other/Proprietary License
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Requires-Dist: annotated-types (>=0.6.0,<0.7.0)
14
+ Requires-Dist: classy-fastapi (>=0.6.1,<0.7.0)
15
+ Requires-Dist: esdbclient (>=1.0.17,<2.0.0)
16
+ Requires-Dist: fastapi (>=0.109.2,<0.110.0)
17
+ Requires-Dist: grpcio (>=1.60.1,<2.0.0)
18
+ Requires-Dist: httpx (>=0.26.0,<0.27.0)
19
+ Requires-Dist: multipledispatch (>=1.0.0,<2.0.0)
20
+ Requires-Dist: pydantic-settings (>=2.2.0,<3.0.0)
21
+ Requires-Dist: pymongo (>=4.6.1,<5.0.0)
22
+ Requires-Dist: pytest (>=8.1.1,<9.0.0)
23
+ Requires-Dist: python-dotenv (>=1.0.1,<2.0.0)
24
+ Requires-Dist: rx (>=3.2.0,<4.0.0)
25
+ Requires-Dist: typing-extensions (>=4.9.0,<5.0.0)
26
+ Requires-Dist: uvicorn (>=0.27.1,<0.28.0)
27
+ Description-Content-Type: text/markdown
28
+
29
+ # Neuroglia Python Framework
30
+
31
+ A framework of libraries used to build modern Python V3 applications
32
+
33
+ ## Disclaimer
34
+
35
+ This project was the opportunity for me (cdavernas) to learn Python while porting some of the concepts and services of the .NET version of the Neuroglia Framework
36
+
37
+ ## Packaging
38
+
39
+ ```sh
40
+ # Set the version tag in pyproject.toml
41
+ # Commit changes
42
+
43
+ poetry build
44
+
45
+ poetry publish --repository gitlab -u <token-username> -p <token-password>
46
+
47
+ ```
48
+
49
+ ---
50
+
51
+ _DRAFT_
52
+
53
+ ## Developer Guide Structure
54
+
55
+ ### Introduction
56
+
57
+ Briefly describe your framework, its purpose, and its target audience.
58
+ Highlight key features and benefits.
59
+
60
+ #### Installation:
61
+
62
+ Provide clear and step-by-step instructions on how to install your framework, including:
63
+ Prerequisites (e.g., Python version, dependencies)
64
+ Installation methods (e.g., pip install <framework_name>, source code compilation)
65
+ Virtual environment recommendations (for isolation and dependency management)
66
+
67
+ #### Getting Started:
68
+
69
+ Offer a simple "Hello, World!" or similar example to demonstrate basic usage and familiarize users with your framework's syntax and structure.
70
+ Include code snippets and explanations where necessary.
71
+
72
+ #### Core Concepts:
73
+
74
+ Dedicate this section to in-depth explanations of the fundamental building blocks and functionalities of your framework. This might include:
75
+ Key objects and classes within the framework
76
+ Data structures and design patterns employed
77
+ Architectural overview (e.g., MVC, MVVM) if applicable
78
+
79
+ #### Tutorials and Examples:
80
+
81
+ Provide a collection of well-structured, step-by-step tutorials that showcase how to accomplish common tasks using your framework.
82
+ Consider varying the difficulty levels (beginner, intermediate, advanced) to cater to a wide range of users.
83
+ Include code examples, explanations, and screenshots as needed.
84
+
85
+ #### API Reference:
86
+
87
+ Create a comprehensive reference for all available classes, functions, and modules within your framework.
88
+ Use a consistent format that includes the following information for each API element:
89
+ Name
90
+ Description
91
+ Arguments (with data types and descriptions)
92
+ Return values (with data types and descriptions)
93
+ Usage examples
94
+
95
+ #### Testing and Debugging:
96
+
97
+ Explain how to effectively test code written using your framework.
98
+ Recommend testing frameworks and tools.
99
+ Provide practical guidance on common debugging techniques and strategies.
100
+
101
+ #### Contributing:
102
+
103
+ Outline how developers can contribute to your framework's development.
104
+ Include information on:
105
+ Issue tracking system (e.g., GitHub issues)
106
+ Pull request guidelines
107
+ Coding style and conventions
108
+ Testing requirements
109
+
110
+ #### Community and Support:
111
+
112
+ Specify available resources for users to seek help and engage with the community. This could include:
113
+ Official channels (e.g., discussion forums, mailing lists)
114
+ Third-party resources (e.g., Stack Overflow tags, community blogs)
115
+
116
+ #### License:
117
+
118
+ Clearly state the license under which your framework is distributed.
119
+
120
+ #### Additional Tips:
121
+
122
+ Maintain a clear and concise writing style, using easy-to-understand language.
123
+ Ensure proper formatting and structure for readability.
124
+ Provide code snippets in a visually appealing format, using code blocks and syntax highlighting.
125
+ Consider adding screenshots or diagrams to illustrate complex concepts.
126
+ Regularly update the guide with new features, bug fixes, and best practices.
127
+
@@ -0,0 +1,98 @@
1
+ # Neuroglia Python Framework
2
+
3
+ A framework of libraries used to build modern Python V3 applications
4
+
5
+ ## Disclaimer
6
+
7
+ This project was the opportunity for me (cdavernas) to learn Python while porting some of the concepts and services of the .NET version of the Neuroglia Framework
8
+
9
+ ## Packaging
10
+
11
+ ```sh
12
+ # Set the version tag in pyproject.toml
13
+ # Commit changes
14
+
15
+ poetry build
16
+
17
+ poetry publish --repository gitlab -u <token-username> -p <token-password>
18
+
19
+ ```
20
+
21
+ ---
22
+
23
+ _DRAFT_
24
+
25
+ ## Developer Guide Structure
26
+
27
+ ### Introduction
28
+
29
+ Briefly describe your framework, its purpose, and its target audience.
30
+ Highlight key features and benefits.
31
+
32
+ #### Installation:
33
+
34
+ Provide clear and step-by-step instructions on how to install your framework, including:
35
+ Prerequisites (e.g., Python version, dependencies)
36
+ Installation methods (e.g., pip install <framework_name>, source code compilation)
37
+ Virtual environment recommendations (for isolation and dependency management)
38
+
39
+ #### Getting Started:
40
+
41
+ Offer a simple "Hello, World!" or similar example to demonstrate basic usage and familiarize users with your framework's syntax and structure.
42
+ Include code snippets and explanations where necessary.
43
+
44
+ #### Core Concepts:
45
+
46
+ Dedicate this section to in-depth explanations of the fundamental building blocks and functionalities of your framework. This might include:
47
+ Key objects and classes within the framework
48
+ Data structures and design patterns employed
49
+ Architectural overview (e.g., MVC, MVVM) if applicable
50
+
51
+ #### Tutorials and Examples:
52
+
53
+ Provide a collection of well-structured, step-by-step tutorials that showcase how to accomplish common tasks using your framework.
54
+ Consider varying the difficulty levels (beginner, intermediate, advanced) to cater to a wide range of users.
55
+ Include code examples, explanations, and screenshots as needed.
56
+
57
+ #### API Reference:
58
+
59
+ Create a comprehensive reference for all available classes, functions, and modules within your framework.
60
+ Use a consistent format that includes the following information for each API element:
61
+ Name
62
+ Description
63
+ Arguments (with data types and descriptions)
64
+ Return values (with data types and descriptions)
65
+ Usage examples
66
+
67
+ #### Testing and Debugging:
68
+
69
+ Explain how to effectively test code written using your framework.
70
+ Recommend testing frameworks and tools.
71
+ Provide practical guidance on common debugging techniques and strategies.
72
+
73
+ #### Contributing:
74
+
75
+ Outline how developers can contribute to your framework's development.
76
+ Include information on:
77
+ Issue tracking system (e.g., GitHub issues)
78
+ Pull request guidelines
79
+ Coding style and conventions
80
+ Testing requirements
81
+
82
+ #### Community and Support:
83
+
84
+ Specify available resources for users to seek help and engage with the community. This could include:
85
+ Official channels (e.g., discussion forums, mailing lists)
86
+ Third-party resources (e.g., Stack Overflow tags, community blogs)
87
+
88
+ #### License:
89
+
90
+ Clearly state the license under which your framework is distributed.
91
+
92
+ #### Additional Tips:
93
+
94
+ Maintain a clear and concise writing style, using easy-to-understand language.
95
+ Ensure proper formatting and structure for readability.
96
+ Provide code snippets in a visually appealing format, using code blocks and syntax highlighting.
97
+ Consider adding screenshots or diagrams to illustrate complex concepts.
98
+ Regularly update the guide with new features, bug fixes, and best practices.
@@ -0,0 +1,42 @@
1
+ [tool.poetry]
2
+ name = "neuroglia-python"
3
+ version = "0.0.23"
4
+ description = "Port from .NET to Python of the Neuroglia Framework"
5
+ authors = ["Charles d'Avernas <charles.davernas@neuroglia.io>"]
6
+ license = "Apache"
7
+ readme = "README.md"
8
+ packages = [
9
+ { include = "neuroglia", from = "src" },
10
+ ]
11
+
12
+ [tool.poetry.dependencies]
13
+ python = "^3.12"
14
+ annotated-types = "^0.6.0"
15
+ classy-fastapi = "^0.6.1"
16
+ esdbclient = "^1.0.17"
17
+ fastapi = "^0.109.2"
18
+ grpcio = "^1.60.1"
19
+ httpx = "^0.26.0"
20
+ multipledispatch = "^1.0.0"
21
+ pydantic-settings = "^2.2.0"
22
+ pymongo = "^4.6.1"
23
+ python-dotenv = "^1.0.1"
24
+ rx = "^3.2.0"
25
+ uvicorn = "^0.27.1"
26
+ typing-extensions = "^4.9.0"
27
+ pytest = "^8.1.1"
28
+
29
+ [tool.poetry.group.dev.dependencies]
30
+ pytest = "^8.0.1"
31
+ pytest-asyncio = "^0.23.5"
32
+ mypy = "^1.8.0"
33
+ autopep8 = "^2.0.4"
34
+ coverage = "^7.4.1"
35
+ mypy-extensions = "^1.0.0"
36
+
37
+ [build-system]
38
+ requires = ["poetry-core"]
39
+ build-backend = "poetry.core.masonry.api"
40
+
41
+ [tool.black]
42
+ line-length = 300
File without changes
@@ -0,0 +1,4 @@
1
+ from .module_loader import *
2
+ from .operation_result import *
3
+ from .type_finder import *
4
+ from .type_extensions import *
@@ -0,0 +1,13 @@
1
+ import importlib
2
+ import sys
3
+ from types import ModuleType
4
+
5
+
6
+ class ModuleLoader:
7
+
8
+ @staticmethod
9
+ def load(module_name: str) -> ModuleType:
10
+ module = sys.modules.get(module_name, None)
11
+ if module is None:
12
+ module = importlib.import_module(module_name)
13
+ return module
@@ -0,0 +1,11 @@
1
+ from typing import Generic, Optional, TypeVar
2
+ from neuroglia.core.problem_details import ProblemDetails
3
+
4
+ TData = TypeVar('TData')
5
+
6
+
7
+ class OperationResult(Generic[TData], ProblemDetails):
8
+ ''' Represents the result of an operation '''
9
+
10
+ data: Optional[TData]
11
+ ''' Gets the data, if any, returned by the operation in case of success '''
@@ -0,0 +1,25 @@
1
+ import dataclasses
2
+ from typing import Optional
3
+
4
+
5
+ @dataclasses.dataclass
6
+ class ProblemDetails:
7
+ '''Represents the structure of a Problem Details response (RFC 7807).'''
8
+
9
+ title: str
10
+ '''A short, human-readable summary of the problem.'''
11
+
12
+ status: int
13
+ '''The HTTP status code for this occurrence of the problem.'''
14
+
15
+ detail: Optional[str] = None
16
+ '''A human-readable explanation specific to this occurrence of the problem.'''
17
+
18
+ type: Optional[str] = None
19
+ '''A URI reference that identifies the problem type.'''
20
+
21
+ instance: Optional[str] = None
22
+ '''A URI reference that identifies the specific occurrence of the problem.'''
23
+
24
+ def is_success_status_code(self) -> bool: self.status >= 200 and self.status < 300
25
+ ''' Determines whether the operation is successfull or not '''
@@ -0,0 +1,75 @@
1
+ from typing import Dict, List, Type, TypeVar
2
+
3
+
4
+ class TypeExtensions:
5
+
6
+ @staticmethod
7
+ def get_generic_implementation(type_: Type, generic_type_definition: Type, generic_args: Dict[str, Type] = None):
8
+ base_types = TypeExtensions._get_base_types(type_)
9
+ base_types = [base for base in base_types if (issubclass(base.__origin__, generic_type_definition) if hasattr(base, "__origin__") else issubclass(base, generic_type_definition))]
10
+ base_type = next((base for base in base_types if base == generic_type_definition or (hasattr(base, "__origin__")) and base.__origin__ == generic_type_definition), None)
11
+ if hasattr(type_, "__orig_class__") and hasattr(type_.__orig_class__.__origin__, "__parameters__"):
12
+ if generic_args is None:
13
+ generic_args = dict[str, Type]()
14
+ for i in range(len(type_.__orig_class__.__origin__.__parameters__)):
15
+ name = type_.__orig_class__.__origin__.__parameters__[i].__name__
16
+ arg_type = type_.__orig_class__.__args__[i]
17
+ generic_args[name] = arg_type
18
+ if (hasattr(type_, "__origin__") and hasattr(type_.__origin__, "__parameters__")):
19
+ if generic_args is None:
20
+ generic_args = dict[str, Type]()
21
+ for i in range(len(type_.__origin__.__parameters__)):
22
+ name = type_.__origin__.__parameters__[i].__name__
23
+ arg_type = type_.__args__[i]
24
+ generic_args[name] = arg_type
25
+ if base_type is not None:
26
+ return TypeExtensions._substitute_generic_arguments(base_type, generic_args)
27
+ else:
28
+ return next((implementation_type for implementation_type in [TypeExtensions.get_generic_implementation(base, generic_type_definition, generic_args) for base in base_types]), None)
29
+
30
+ @staticmethod
31
+ def get_generic_arguments(type_: Type, generic_arguments: Dict[str, Type] = None) -> Dict[str, Type]:
32
+ if hasattr(type_, "__orig_class__") and hasattr(type_.__orig_class__.__origin__, "__parameters__"):
33
+ if generic_arguments is None:
34
+ generic_arguments = dict[str, Type]()
35
+ for i in range(len(type_.__orig_class__.__origin__.__parameters__)):
36
+ name = type_.__orig_class__.__origin__.__parameters__[i].__name__
37
+ arg_type = type_.__orig_class__.__args__[i]
38
+ generic_arguments[name] = TypeExtensions._substitute_generic_arguments(arg_type, generic_arguments)
39
+ if (hasattr(type_, "__origin__") and hasattr(type_.__origin__, "__parameters__")):
40
+ if generic_arguments is None:
41
+ generic_arguments = dict[str, Type]()
42
+ for i in range(len(type_.__origin__.__parameters__)):
43
+ name = type_.__origin__.__parameters__[i].__name__
44
+ arg_type = type_.__args__[i]
45
+ generic_arguments[name] = TypeExtensions._substitute_generic_arguments(arg_type, generic_arguments)
46
+ for base_type in TypeExtensions._get_base_types(type_):
47
+ generic_arguments = TypeExtensions.get_generic_arguments(base_type, generic_arguments)
48
+ return generic_arguments
49
+
50
+ @staticmethod
51
+ def get_generic_argument(type_: Type, name: str) -> Type | None:
52
+ generic_arguments = TypeExtensions.get_generic_arguments(type_)
53
+ return generic_arguments.get(name, None)
54
+
55
+ @staticmethod
56
+ def _get_base_types(type_: Type) -> List[Type]:
57
+ if hasattr(type_, "__origin__") and hasattr(type_.__origin__, "__orig_bases__"):
58
+ return type_.__origin__.__orig_bases__
59
+ elif hasattr(type_, "__orig_bases__"):
60
+ return type_.__orig_bases__
61
+ else:
62
+ return list[Type]()
63
+
64
+ @staticmethod
65
+ def _substitute_generic_arguments(type_: Type, generic_args: Dict[str, Type] | None = None) -> Type:
66
+ if not hasattr(type_, "__parameters__") and generic_args is not None:
67
+ if isinstance(type_, TypeVar):
68
+ return generic_args.get(type_.__name__, None)
69
+ else:
70
+ return type_
71
+ parameters = [param.__name__ for param in type_.__parameters__]
72
+ type_args = [TypeExtensions._substitute_generic_arguments(generic_arg_value, generic_args) for generic_arg_key, generic_arg_value in generic_args.items() if generic_arg_key in parameters]
73
+ if len(type_args) < 1:
74
+ return type_
75
+ return type_[*type_args]
@@ -0,0 +1,24 @@
1
+ import importlib
2
+ import inspect
3
+ import pkgutil
4
+ from types import ModuleType
5
+ from typing import Callable, List, Type
6
+
7
+
8
+ class TypeFinder:
9
+ ''' Represents an utility class that exposes methods to find and filter types '''
10
+
11
+ def get_types(module: ModuleType, predicate: Callable[[Type], bool] = lambda t: True, include_sub_modules=True, include_sub_packages=False) -> List[Type]:
12
+ ''' Recursively finds all types contained in the specified module that match the specified predicate, if any '''
13
+ results: List[Type] = list[Type]()
14
+ results.extend([cls for _, cls in inspect.getmembers(module, inspect.isclass) if predicate(cls)])
15
+ if include_sub_modules:
16
+ for submodule in [submodule for _, submodule in inspect.getmembers(module, inspect.ismodule) if submodule.__name__.startswith(module.__name__)]:
17
+ results.extend(TypeFinder.get_types(submodule, predicate, include_sub_modules, include_sub_packages))
18
+ # todo: the following creates big problems, as it will actually (re)load, thus (re)run, imported packages <= it sucks
19
+ if include_sub_packages:
20
+ if hasattr(module, "__path__"):
21
+ sub_packages = [importlib.import_module(module_name) for _, module_name, _ in pkgutil.walk_packages(module.__path__, module.__name__ + ".") if module_name.startswith(module.__name__)]
22
+ for submodule in sub_packages:
23
+ results.extend(TypeFinder.get_types(submodule, predicate, include_sub_modules, include_sub_packages))
24
+ return list(set(results))
@@ -0,0 +1 @@
1
+ from .queryable import *