opengris-parfun 7.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. opengris_parfun-7.3.0.dist-info/METADATA +165 -0
  2. opengris_parfun-7.3.0.dist-info/RECORD +43 -0
  3. opengris_parfun-7.3.0.dist-info/WHEEL +5 -0
  4. opengris_parfun-7.3.0.dist-info/licenses/LICENSE +201 -0
  5. opengris_parfun-7.3.0.dist-info/licenses/LICENSE.spdx +7 -0
  6. opengris_parfun-7.3.0.dist-info/licenses/NOTICE +7 -0
  7. opengris_parfun-7.3.0.dist-info/top_level.txt +1 -0
  8. parfun/__init__.py +26 -0
  9. parfun/about.py +1 -0
  10. parfun/backend/__init__.py +0 -0
  11. parfun/backend/dask.py +151 -0
  12. parfun/backend/local_multiprocessing.py +92 -0
  13. parfun/backend/local_single_process.py +47 -0
  14. parfun/backend/mixins.py +68 -0
  15. parfun/backend/profiled_future.py +50 -0
  16. parfun/backend/scaler.py +226 -0
  17. parfun/backend/utility.py +7 -0
  18. parfun/combine/__init__.py +0 -0
  19. parfun/combine/collection.py +13 -0
  20. parfun/combine/dataframe.py +13 -0
  21. parfun/dataframe.py +175 -0
  22. parfun/decorators.py +135 -0
  23. parfun/entry_point.py +180 -0
  24. parfun/functions.py +71 -0
  25. parfun/kernel/__init__.py +0 -0
  26. parfun/kernel/function_signature.py +197 -0
  27. parfun/kernel/parallel_function.py +262 -0
  28. parfun/object.py +7 -0
  29. parfun/partition/__init__.py +0 -0
  30. parfun/partition/api.py +136 -0
  31. parfun/partition/collection.py +13 -0
  32. parfun/partition/dataframe.py +16 -0
  33. parfun/partition/object.py +50 -0
  34. parfun/partition/primitives.py +317 -0
  35. parfun/partition/utility.py +54 -0
  36. parfun/partition_size_estimator/__init__.py +0 -0
  37. parfun/partition_size_estimator/linear_regression_estimator.py +189 -0
  38. parfun/partition_size_estimator/mixins.py +22 -0
  39. parfun/partition_size_estimator/object.py +19 -0
  40. parfun/profiler/__init__.py +0 -0
  41. parfun/profiler/functions.py +261 -0
  42. parfun/profiler/object.py +68 -0
  43. parfun/py_list.py +56 -0
@@ -0,0 +1,165 @@
1
+ Metadata-Version: 2.4
2
+ Name: opengris-parfun
3
+ Version: 7.3.0
4
+ Summary: Lightweight parallelisation library for Python
5
+ Author-email: Citi <opensource@citi.com>
6
+ License: Apache 2.0
7
+ Project-URL: Home, https://github.com/Citi/parfun
8
+ Project-URL: Issues, https://github.com/Citi/parfun/issues
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: Apache Software License
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Topic :: System :: Distributed Computing
14
+ Requires-Python: >=3.10
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ License-File: LICENSE.spdx
18
+ License-File: NOTICE
19
+ Requires-Dist: psutil>=7.0.0
20
+ Requires-Dist: attrs
21
+ Requires-Dist: scikit-learn>=1.6.1
22
+ Provides-Extra: pandas
23
+ Requires-Dist: pandas; extra == "pandas"
24
+ Provides-Extra: dask
25
+ Requires-Dist: dask>=2025.5.1; extra == "dask"
26
+ Requires-Dist: distributed>=2025.5.1; extra == "dask"
27
+ Provides-Extra: scaler
28
+ Requires-Dist: opengris-scaler; extra == "scaler"
29
+ Dynamic: license-file
30
+
31
+ <div align="center">
32
+ <a href="https://github.com/finos/opengris-parfun">
33
+ <img src="https://github.com/finos/branding/blob/master/project-logos/active-project-logos/OpenGRIS/Parfun/2025_OpenGRIS_Parfun.svg" alt="OpenGRIS Parfun" width="180" height="80">
34
+ </a>
35
+
36
+ <p align="center">
37
+ Lightweight parallelization library for Python.
38
+ </p>
39
+
40
+ <p align="center">
41
+ <a href="https://community.finos.org/docs/governance/Software-Projects/stages/incubating">
42
+ <img src="https://cdn.jsdelivr.net/gh/finos/contrib-toolbox@master/images/badge-incubating.svg">
43
+ </a>
44
+ <a href="https://finos.github.io/opengris-parfun/">
45
+ <img src="https://img.shields.io/badge/Documentation-0f1632">
46
+ </a>
47
+ <a href="./LICENSE">
48
+ <img src="https://img.shields.io/github/license/citi/parfun?label=license&colorA=0f1632&colorB=255be3">
49
+ </a>
50
+ <a href="https://pypi.org/project/opengris-parfun/">
51
+ <img alt="PyPI - Version" src="https://img.shields.io/pypi/v/opengris-parfun?colorA=0f1632&colorB=255be3">
52
+ </a>
53
+ <img src="https://api.securityscorecards.dev/projects/github.com/Citi/parfun/badge">
54
+ </p>
55
+ </div>
56
+
57
+ <br />
58
+
59
+ OpenGRIS Parfun is a lightweight library **making it easy to write and run Python in parallel and distributed systems**.
60
+
61
+ The main feature of the library is its `@parallel` decorator that transparently executes standard Python functions in parallel
62
+ following the [map-reduce](https://en.wikipedia.org/wiki/MapReduce) pattern:
63
+
64
+ ```Python
65
+ from typing import List
66
+
67
+ import parfun as pf
68
+
69
+
70
+ @pf.parallel(
71
+ # parallelize by chunking the argument list (map)
72
+ split=pf.per_argument(
73
+ values=pf.py_list.by_chunk
74
+ ),
75
+
76
+ # merge the output by concatenating the results (reduce)
77
+ combine_with=pf.py_list.concat,
78
+ )
79
+ def list_pow(values: List[float], factor: float) -> List[float]:
80
+ """compute powers of a list of numbers"""
81
+ return [v**factor for v in values]
82
+
83
+
84
+ if __name__ == "__main__":
85
+ with pf.set_parallel_backend_context("local_multiprocessing"): # use a local pool of processes
86
+ print(list_pow([1, 2, 3], 2)) # runs in parallel, prints [1, 4, 9]
87
+ ```
88
+
89
+ ## Features
90
+
91
+ * **Provides significant speedups** to existing Python functions.
92
+ * **Only requires basic understanding of parallel and distributed computing systems**.
93
+ * **Automatically estimates the optimal sub-task splitting strategy** (the *partition size*).
94
+ * **Transparently handles data transmission, caching, and synchronization**.
95
+ * **Supports various distributed computing backends**:
96
+ * Python's built-in [multiprocessing module](https://docs.python.org/3/library/multiprocessing.html).
97
+ * [Scaler](https://github.com/finos/opengris-scaler/).
98
+ * [Dask](https://www.dask.org/).
99
+
100
+ ## Quick Start
101
+
102
+ Install Parfun directly from PyPI:
103
+
104
+ ```bash
105
+ pip install opengris-parfun
106
+ pip install "opengris-parfun[pandas,scaler,dask]" # with optional dependencies
107
+ ```
108
+
109
+ The official documentation is available at [citi.github.io/parfun/](https://citi.github.io/parfun/).
110
+
111
+ Take a look at our documentation's [quickstart tutorial](https://citi.github.io/parfun/tutorials/quickstart.html) to get
112
+ more examples and a deeper overview of the library.
113
+
114
+ Alternatively, you can build the documentation from source:
115
+
116
+ ```bash
117
+ cd docs
118
+ pip install -r requirements.txt
119
+ make html
120
+ ```
121
+
122
+ The documentation's main page can then be found at `docs/build/html/index.html`.
123
+
124
+ ## Benchmarks
125
+
126
+ **Parfun effectively parallelizes even short-duration functions**.
127
+
128
+ For example, when running a short 0.28-second machine learning function on an AMD Epyc 7313 16-Core Processor, we found that Parfun
129
+ provided an impressive **7.4x speedup**. Source code for this experiment [here](examples/california_housing/main.py).
130
+
131
+ ![Benchmark Results](images/benchmark_results.svg)
132
+
133
+ ## Contributing
134
+
135
+ Your contributions are at the core of making this a true open source project. Any contributions you make are **greatly appreciated**.
136
+
137
+ We welcome you to:
138
+
139
+ * Fix typos or touch up documentation
140
+ * Share your opinions on [existing issues](https://github.com/finos/opengris-parfun/issues)
141
+ * Help expand and improve our library by [opening a new issue](https://github.com/finos/opengris-parfun/issues/new)
142
+
143
+ Please review [functional contribution guidelines](./CONTRIBUTING.md) to get started 👍.
144
+
145
+ _NOTE:_ Commits and pull requests to FINOS repositories will only be accepted from those contributors with an active, executed Individual Contributor License Agreement (ICLA) with FINOS OR contributors who are covered under an existing and active Corporate Contribution License Agreement (CCLA) executed with FINOS. Commits from individuals not covered under an ICLA or CCLA will be flagged and blocked by the ([EasyCLA](https://community.finos.org/docs/governance/Software-Projects/easycla)) tool. Please note that some CCLAs require individuals/employees to be explicitly named on the CCLA.
146
+
147
+ *Need an ICLA? Unsure if you are covered under an existing CCLA? Email [help@finos.org](mailto:help@finos.org)*
148
+
149
+ ## Code of Conduct
150
+
151
+ Please see the FINOS [Community Code of Conduct](https://www.finos.org/code-of-conduct).
152
+
153
+ ## License
154
+
155
+ Copyright 2023 Citigroup, Inc.
156
+
157
+ This project is distributed under the [Apache-2.0 License](https://www.apache.org/licenses/LICENSE-2.0). See
158
+ [`LICENSE`](./LICENSE) for more information.
159
+
160
+ SPDX-License-Identifier: [Apache-2.0](https://spdx.org/licenses/Apache-2.0).
161
+
162
+ ## Contact
163
+
164
+ If you have a query or require support with this project, [raise an issue](https://github.com/Citi/parfun/issues).
165
+ Otherwise, reach out to [opensource@citi.com](mailto:opensource@citi.com).
@@ -0,0 +1,43 @@
1
+ opengris_parfun-7.3.0.dist-info/licenses/LICENSE,sha256=xudC0jta6OXJkSHiLzzQQU50HIwSo0G97exO280dtR8,11345
2
+ opengris_parfun-7.3.0.dist-info/licenses/LICENSE.spdx,sha256=Vn2QWt7Wc4_2ZyB5p_4WFma3hKaQ1DfzzONpU1IvW6w,225
3
+ opengris_parfun-7.3.0.dist-info/licenses/NOTICE,sha256=sROWM7UjdQVv4UiNiCJ1_iTWl0oGKDmCqCtn1cAk7hw,285
4
+ parfun/__init__.py,sha256=LwheH2OWHMO0obQ3om22XxmIHeP4jvo66gonkg_6_GQ,887
5
+ parfun/about.py,sha256=sdpc-9h8PmmRVaqNA9R2vvMOVXFYIKW9zf9YS8np6ig,22
6
+ parfun/dataframe.py,sha256=G5FH-FJ1QKa0DJ-RspA-IcLzvRvi0nWN08VKoh96vDs,5186
7
+ parfun/decorators.py,sha256=iq3X2l7sSIHG2j7pBRwztuAvwStv191tQrrbHpFrF2Y,6047
8
+ parfun/entry_point.py,sha256=AfcRK1hTbH8fN1cZAVb2bUfgC3P0WjFHskRNYL5l8Ec,6390
9
+ parfun/functions.py,sha256=5dsrSnFrEmdI2PQRNBN2ZApCNtX6suipjIjfZPyOGs0,2613
10
+ parfun/object.py,sha256=ej_1l2DmtEFrsteM55lJEEbVP8lAx_Fz-Lb5HhiU7dw,241
11
+ parfun/py_list.py,sha256=UJ78wOXPQcrEpZ5rVVyr9f-LEmY2gIv46RAC3ZCr7GI,1361
12
+ parfun/backend/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
+ parfun/backend/dask.py,sha256=HQn9v3VeLu0e5t5HEqvM3Jxa7jVrMZs6IczVqJrh_IE,4929
14
+ parfun/backend/local_multiprocessing.py,sha256=SjmiCtnOwIIThbFSn1MRkZrN2qhnRf64bEIp_OODDbM,3426
15
+ parfun/backend/local_single_process.py,sha256=XPiM7n239tiKsxOf_EGVKoP65rB0z-EOt2FxqJ7Qvvg,1439
16
+ parfun/backend/mixins.py,sha256=wSc36Zm4Ryfhdb7l_h2tV7YlfAj9V9Jskl_HCr1gzXw,1819
17
+ parfun/backend/profiled_future.py,sha256=i0TmzKvS2Sj2P57YvOF9SMofOlAvX21_kdITTa_Wo9A,1802
18
+ parfun/backend/scaler.py,sha256=GXsKoYKs0f-2cnj8J9cjXYr-F9U7wRRjkNljM45IsXU,8094
19
+ parfun/backend/utility.py,sha256=OeypHvDEHNlz-U7MucBDglyVg9LahLNsqwwpXjW-ot0,243
20
+ parfun/combine/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
+ parfun/combine/collection.py,sha256=-MLGwUaiEFsx6iar5IXZwJ_WTFFSSBppdbVF5stRuU8,250
22
+ parfun/combine/dataframe.py,sha256=ocN8gskjClYb-pTXz4DwzN9F0KwIw_69VZ1k2GIlhCg,249
23
+ parfun/kernel/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
+ parfun/kernel/function_signature.py,sha256=5oxjfoEL9iRLwQXrQhR35p1idK8rnF6nd88uczjxn3w,7544
25
+ parfun/kernel/parallel_function.py,sha256=rl-V4FTWGIuxytwfICzdTHEhQxEfbzYlQYEoGdYVP1M,10512
26
+ parfun/partition/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
+ parfun/partition/api.py,sha256=jQWDu3wuuG1wuRVJSx34TJbI_AblK8i938JQRUKFluk,5097
28
+ parfun/partition/collection.py,sha256=NifreVi3bCMjWhPYN6Z5yPSP1YRkxdMNkOMQlO9Qr7s,260
29
+ parfun/partition/dataframe.py,sha256=xXBqDNIIhYtzqUGHQ3s4J70kAwaEcxxlhFLzFznA1rg,301
30
+ parfun/partition/object.py,sha256=iW8FA211VkfSep5vmjwabWsNaEhm6b6RH4lfMDWaG58,1887
31
+ parfun/partition/primitives.py,sha256=dx8LrH2nGKDY8JopgQ3j1n49P2SBQNGQja5LT0jGPb0,11598
32
+ parfun/partition/utility.py,sha256=cik2J5YlpZZJncaOM1hfVmsem4L_tQiAwObDyCSMkjc,2071
33
+ parfun/partition_size_estimator/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
34
+ parfun/partition_size_estimator/linear_regression_estimator.py,sha256=RRfcf9I4uC0XKyyKZtpZW7DwvPBV9ZdLPec-mdEBRP8,8486
35
+ parfun/partition_size_estimator/mixins.py,sha256=fXAnaBSz7Fd70QIJifw9UwgXt3lF98dZ93lO__butJI,702
36
+ parfun/partition_size_estimator/object.py,sha256=jr0PNpoKKO1B310b0JOsEE_G7YmgYphEhGlCaI_Wrxw,437
37
+ parfun/profiler/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
38
+ parfun/profiler/functions.py,sha256=sLHSHbkcygxBYR8YKOxdUDot401blzGk0WRSU3nR3VY,9891
39
+ parfun/profiler/object.py,sha256=W6iERUYD_BzxhlYiP4JOx0RtantHyX8FrGMAq9aEeno,2546
40
+ opengris_parfun-7.3.0.dist-info/METADATA,sha256=vXe8nM7NlSJp9sLcBUNnap7ei9T9s_HIqoA9jq7EIIg,6603
41
+ opengris_parfun-7.3.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
42
+ opengris_parfun-7.3.0.dist-info/top_level.txt,sha256=CQcSVK2YxLimgnJMefZS3MsRyh9xFpHxXGvoJvZk05A,7
43
+ opengris_parfun-7.3.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.10.2)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -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 2023 Citigroup, Inc.
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,7 @@
1
+ SPDXVersion: SPDX-2.0
2
+ DataLicense: CC0-1.0
3
+ Creator: Citigroup, Inc.
4
+ PackageName: opengris-parfun
5
+ PackageOriginator: Citigroup, Inc.
6
+ PackageHomePage: https://github.com/finos/opengris-parfun
7
+ PackageLicenseDeclared: Apache-2.0
@@ -0,0 +1,7 @@
1
+ OpenGRIS Scaler
2
+ Copyright 2023 - 2025 - Citigroup, Inc.
3
+ Copyright 2025 - FINOS info@finos.org
4
+
5
+ This product includes software developed by Citigroup (https://www.citigroup.com/).
6
+
7
+ This product includes software developed at the Fintech Open Source Foundation (https://www.finos.org/).
@@ -0,0 +1 @@
1
+ parfun
parfun/__init__.py ADDED
@@ -0,0 +1,26 @@
1
+ import sys
2
+
3
+ import parfun.py_list as py_list
4
+ from parfun.about import __version__
5
+ from parfun.decorators import parallel, parfun
6
+ from parfun.entry_point import get_parallel_backend, set_parallel_backend, set_parallel_backend_context
7
+ from parfun.partition.api import all_arguments, multiple_arguments, per_argument
8
+
9
+
10
+ __all__ = (
11
+ "__version__",
12
+ "parallel", "parfun",
13
+ "get_parallel_backend", "set_parallel_backend", "set_parallel_backend_context",
14
+ "all_arguments", "multiple_arguments", "per_argument",
15
+ "py_list",
16
+ )
17
+
18
+
19
+ def __getattr__(name: str):
20
+ # Only load the dataframe module when requested, as it has an optional dependency on Pandas.
21
+ if name == "dataframe":
22
+ import parfun.dataframe as dataframe
23
+ sys.modules[__name__ + ".dataframe"] = dataframe
24
+ return dataframe
25
+
26
+ raise AttributeError(f"module {__name__} has no attribute {name}")
parfun/about.py ADDED
@@ -0,0 +1 @@
1
+ __version__ = "7.3.0"
File without changes
parfun/backend/dask.py ADDED
@@ -0,0 +1,151 @@
1
+ import abc
2
+ from contextlib import contextmanager
3
+ from threading import BoundedSemaphore
4
+ from typing import Generator, Optional
5
+
6
+ try:
7
+ from dask.distributed import Client, Future, LocalCluster, worker_client
8
+ from dask.distributed.client import ClientExecutor
9
+ except ImportError:
10
+ raise ImportError(
11
+ "Dask dependencies missing. Use `pip install 'opengris-parfun[dask]'` to install Dask dependencies."
12
+ )
13
+
14
+ import psutil
15
+
16
+ from parfun.backend.mixins import BackendEngine, BackendSession
17
+ from parfun.backend.profiled_future import ProfiledFuture
18
+ from parfun.profiler.functions import profile, timed_function
19
+
20
+
21
+ class DaskSession(BackendSession):
22
+ # Additional constant scheduling overhead that cannot be accounted for when measuring the task execution duration.
23
+ CONSTANT_SCHEDULING_OVERHEAD = 20_000_000 # 20ms
24
+
25
+ def __init__(self, engine: "DaskBaseBackend", n_workers: int):
26
+ self._engine = engine
27
+ self._concurrent_task_guard = BoundedSemaphore(n_workers)
28
+
29
+ def __enter__(self) -> "DaskSession":
30
+ return self
31
+
32
+ def __exit__(self, exc_type, exc_val, exc_tb) -> None:
33
+ return None
34
+
35
+ def submit(self, fn, *args, **kwargs) -> Optional[ProfiledFuture]:
36
+ with profile() as submit_duration:
37
+ future = ProfiledFuture()
38
+
39
+ acquired = self._concurrent_task_guard.acquire()
40
+ if not acquired:
41
+ return None
42
+
43
+ with self._engine.executor() as executor: # type: ignore[var-annotated]
44
+ underlying_future = executor.submit(timed_function, fn, *args, **kwargs)
45
+
46
+ def on_done_callback(underlying_future: Future):
47
+ assert submit_duration.value is not None
48
+
49
+ if underlying_future.cancelled():
50
+ future.cancel()
51
+ return
52
+
53
+ with profile() as release_duration:
54
+ exception = underlying_future.exception()
55
+
56
+ if exception is None:
57
+ result, function_duration = underlying_future.result()
58
+ else:
59
+ result = None
60
+ function_duration = 0
61
+
62
+ self._concurrent_task_guard.release()
63
+
64
+ task_duration = (
65
+ self.CONSTANT_SCHEDULING_OVERHEAD + submit_duration.value + function_duration + release_duration.value
66
+ )
67
+
68
+ if exception is None:
69
+ future.set_result(result, duration=task_duration)
70
+ else:
71
+ future.set_exception(exception, duration=task_duration)
72
+
73
+ underlying_future.add_done_callback(on_done_callback)
74
+
75
+ return future
76
+
77
+
78
+ class DaskBaseBackend(BackendEngine, metaclass=abc.ABCMeta):
79
+ def __init__(self, n_workers: int) -> None:
80
+ self._n_workers = n_workers
81
+
82
+ def session(self) -> DaskSession:
83
+ return DaskSession(self, self._n_workers)
84
+
85
+ @abc.abstractmethod
86
+ @contextmanager
87
+ def executor(self) -> Generator[ClientExecutor, None, None]:
88
+ raise NotImplementedError
89
+
90
+ def allows_nested_tasks(self) -> bool:
91
+ return False
92
+
93
+
94
+ class DaskRemoteClusterBackend(DaskBaseBackend):
95
+ """Connects to a previously instantiated Dask instance as a backend engine."""
96
+
97
+ def __init__(self, scheduler_address: str):
98
+ self._client = Client(address=scheduler_address)
99
+
100
+ n_workers = len(self._client.scheduler_info()["workers"])
101
+ super().__init__(n_workers)
102
+
103
+ self._executor = self._client.get_executor()
104
+
105
+ @contextmanager
106
+ def executor(self) -> Generator[ClientExecutor, None, None]:
107
+ yield self._executor
108
+
109
+ def get_scheduler_address(self) -> str:
110
+ return self._client.cluster.scheduler_address
111
+
112
+ def disconnect(self, wait: bool = True):
113
+ self._executor.shutdown(wait=wait)
114
+ self._client.close()
115
+
116
+ def shutdown(self):
117
+ pass
118
+
119
+
120
+ class DaskLocalClusterBackend(DaskRemoteClusterBackend):
121
+ """Creates a Dask cluster on the local machine and uses it as a backend engine."""
122
+
123
+ def __init__(
124
+ self, n_workers: int = psutil.cpu_count(logical=False) - 1, dashboard_address=":33333", memory_limit="100GB"
125
+ ):
126
+ self._cluster = LocalCluster(
127
+ n_workers=n_workers, threads_per_worker=1, dashboard_address=dashboard_address, memory_limit=memory_limit
128
+ )
129
+ super().__init__(self._cluster.scheduler_address)
130
+
131
+ def shutdown(self):
132
+ self._cluster.close()
133
+
134
+
135
+ class DaskCurrentBackend(DaskBaseBackend):
136
+ """
137
+ Uses the current Dask worker context to deduce the backend instance.
138
+
139
+ This backend should be used by Dask's worker tasks that desire to access the underlying backend instance.
140
+ """
141
+
142
+ def __init__(self, n_workers: int) -> None:
143
+ super().__init__(n_workers)
144
+
145
+ @contextmanager
146
+ def executor(self) -> Generator[ClientExecutor, None, None]:
147
+ with worker_client() as client:
148
+ yield client.get_executor()
149
+
150
+ def shutdown(self):
151
+ pass