vantage6-backend-common 4.13.2__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 (27) hide show
  1. vantage6_backend_common-4.13.2/PKG-INFO +231 -0
  2. vantage6_backend_common-4.13.2/setup.cfg +4 -0
  3. vantage6_backend_common-4.13.2/setup.py +49 -0
  4. vantage6_backend_common-4.13.2/vantage6/backend/common/__build__ +1 -0
  5. vantage6_backend_common-4.13.2/vantage6/backend/common/__init__.py +35 -0
  6. vantage6_backend_common-4.13.2/vantage6/backend/common/_version.py +23 -0
  7. vantage6_backend_common-4.13.2/vantage6/backend/common/base.py +489 -0
  8. vantage6_backend_common-4.13.2/vantage6/backend/common/globals.py +16 -0
  9. vantage6_backend_common-4.13.2/vantage6/backend/common/jsonable.py +60 -0
  10. vantage6_backend_common-4.13.2/vantage6/backend/common/mail_service.py +75 -0
  11. vantage6_backend_common-4.13.2/vantage6/backend/common/metrics.py +127 -0
  12. vantage6_backend_common-4.13.2/vantage6/backend/common/permission.py +225 -0
  13. vantage6_backend_common-4.13.2/vantage6/backend/common/permission_models.py +42 -0
  14. vantage6_backend_common-4.13.2/vantage6/backend/common/resource/__init__.py +0 -0
  15. vantage6_backend_common-4.13.2/vantage6/backend/common/resource/error_handling.py +63 -0
  16. vantage6_backend_common-4.13.2/vantage6/backend/common/resource/input_schema.py +86 -0
  17. vantage6_backend_common-4.13.2/vantage6/backend/common/resource/output_schema.py +128 -0
  18. vantage6_backend_common-4.13.2/vantage6/backend/common/resource/pagination.py +315 -0
  19. vantage6_backend_common-4.13.2/vantage6/backend/common/resource/role.py +107 -0
  20. vantage6_backend_common-4.13.2/vantage6/backend/common/services_resources.py +90 -0
  21. vantage6_backend_common-4.13.2/vantage6/backend/common/session.py +4 -0
  22. vantage6_backend_common-4.13.2/vantage6/backend/common/test_context.py +57 -0
  23. vantage6_backend_common-4.13.2/vantage6_backend_common.egg-info/PKG-INFO +231 -0
  24. vantage6_backend_common-4.13.2/vantage6_backend_common.egg-info/SOURCES.txt +25 -0
  25. vantage6_backend_common-4.13.2/vantage6_backend_common.egg-info/dependency_links.txt +1 -0
  26. vantage6_backend_common-4.13.2/vantage6_backend_common.egg-info/requires.txt +11 -0
  27. vantage6_backend_common-4.13.2/vantage6_backend_common.egg-info/top_level.txt +1 -0
@@ -0,0 +1,231 @@
1
+ Metadata-Version: 2.4
2
+ Name: vantage6_backend_common
3
+ Version: 4.13.2
4
+ Summary: Vantage6 common backend functionalities
5
+ Home-page: https://github.com/vantage6/vantage6
6
+ Requires-Python: >=3.10
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: flask==3.1.1
9
+ Requires-Dist: flask-mail==0.9.1
10
+ Requires-Dist: Flask-RESTful==0.3.10
11
+ Requires-Dist: marshmallow==3.19.0
12
+ Requires-Dist: marshmallow-sqlalchemy==0.29.0
13
+ Requires-Dist: SQLAlchemy==1.4.46
14
+ Requires-Dist: prometheus-client==0.21.1
15
+ Requires-Dist: vantage6-common==4.13.2
16
+ Provides-Extra: dev
17
+ Requires-Dist: coverage==6.4.4; extra == "dev"
18
+ Dynamic: description
19
+ Dynamic: description-content-type
20
+ Dynamic: home-page
21
+ Dynamic: provides-extra
22
+ Dynamic: requires-dist
23
+ Dynamic: requires-python
24
+ Dynamic: summary
25
+
26
+ <h1 align="center">
27
+ <br>
28
+ <a href="https://vantage6.ai"><img src="https://github.com/IKNL/guidelines/blob/master/resources/logos/vantage6.png?raw=true" alt="vantage6" width="350"></a>
29
+ </h1>
30
+
31
+ <h3 align=center> A Privacy Enhancing Technology (PET) Operations platform</h3>
32
+ <h3 align="center">
33
+
34
+ <!-- Badges go here-->
35
+
36
+ [![Release](https://github.com/vantage6/vantage6/actions/workflows/release.yml/badge.svg)](https://github.com/vantage6/vantage6/actions/workflows/release.yml)
37
+ [![PyPI vantage6](https://badge.fury.io/py/vantage6.svg)](https://badge.fury.io/py/vantage6)
38
+ [![Unittests](https://github.com/vantage6/vantage6/actions/workflows/unit_tests.yml/badge.svg)](https://github.com/vantage6/vantage6/actions/workflows/unit_tests.yml)
39
+ [![Coverage Status](https://coveralls.io/repos/github/vantage6/vantage6/badge.svg?branch=main)](https://coveralls.io/github/vantage6/vantage6?branch=main)
40
+ [![Codacy Badge](https://app.codacy.com/project/badge/Grade/2e60ac3b3f284620805f7399cba317be)](https://app.codacy.com/gh/vantage6/vantage6/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
41
+ [![DOI](https://zenodo.org/badge/492818831.svg)](https://zenodo.org/badge/latestdoi/492818831)
42
+ [![Discord](https://img.shields.io/discord/643526403207331841)](https://discord.gg/yAyFf6Y)
43
+ [![Research software directory](https://img.shields.io/badge/rsd-vantage6-deepskyblue)](https://research-software-directory.org/software/vantage6)
44
+
45
+
46
+ </h3>
47
+
48
+ <p align="center">
49
+ <a href="#books-quickstart">Quickstart</a> •
50
+ <a href="#project-structure">Project structure</a> •
51
+ <a href="#gift_heart-join-the-community">Join the community</a> •
52
+ <a href="#scroll-license">License</a> •
53
+ <a href="#black_nib-code-of-conduct">Code of conduct</a> •
54
+ <a href="#black_nib-references">References</a>
55
+ </p>
56
+
57
+ ---
58
+
59
+ This repository is contains all the **vantage6** infrastructure source code. The **vantage6** technology enables to manage and deploy privacy enhancing technologies like Federated Learning (FL) and Multi-Party Computation (MPC). Please visit our [website](https://vantage6.ai) to learn more!
60
+
61
+ You can find more (user) documentation at [readthedocs](https://docs.vantage6.ai). If you have any questions, suggestions or just want to chat about federated learning: join our [Discord)](https://discord.gg/yAyFf6Y) channel.
62
+
63
+ ## Infrastructure overview
64
+
65
+ ![Vantage6 architecture overview](docs/images/overview-infrastructure.png)
66
+
67
+ _A High level overview of the vantage6 infrastructure. Vantage6 has both a
68
+ client-server and peer-to-peer architecture. The client is used by the researcher to
69
+ create (PET) computation requests. It is also used to manage users, organizations and
70
+ collaborations. The server contains users, organizations, collaborations, tasks and
71
+ their results. It provides a central access point for both the clients and nodes. The
72
+ nodes have access to privacy sensitive data and handle computation requests retrieved
73
+ from the server. Computation request are executed as separate containers on the node.
74
+ These containers are connected to containers at other nodes by a VPN network._
75
+
76
+ ## :books: Quickstart
77
+
78
+ ### Requirements
79
+
80
+ The **vantage6** infrastructure is delivered in Docker images. To run these images, you
81
+ need to have [Docker](https://docs.docker.com/get-docker/) installed. To install the
82
+ latest version of the vantage6 CLI, you need to have
83
+ [Python](https://www.python.org/downloads/), we recommend using an environment manager
84
+ like [mini-conda](https://docs.conda.io/en/latest/miniconda.html).
85
+
86
+ Install the latest version of the vantage6 CLI by using:
87
+
88
+ ```bash
89
+ pip install vantage6
90
+ ```
91
+
92
+ This install the `v6` commands, which allows you to manage your nodes and servers. To view all available options, run:
93
+
94
+ ```bash
95
+ v6 --help
96
+ ```
97
+
98
+ For example you can create a local test setup by using:
99
+
100
+ ```bash
101
+ v6 dev create-demo-network
102
+ ```
103
+
104
+ This creates a local network with a server and two nodes. You can start the network by running:
105
+
106
+ ```bash
107
+ v6 dev start-demo-network
108
+ ```
109
+
110
+ This will start the server and nodes in the background. You can view the logs by running:
111
+
112
+ ```bash
113
+ # View node logs
114
+ v6 node attach
115
+
116
+ # View server logs
117
+ v6 server attach
118
+ ```
119
+
120
+ From here you can use the [vantage6-client](https://pypi.org/project/vantage6-client)
121
+ to interact with the server. The demo network has a pre-configured organization with
122
+ the following credentials:
123
+
124
+ - Username: `dev_admin`
125
+ - Password: `password`
126
+
127
+ For example, you can create a new organization by running:
128
+
129
+ ```python
130
+ from vantage6.client import Client
131
+
132
+ client = Client('http://127.0.0.1', 7601, '/api', log_level='debug')
133
+ client.authenticate('dev_admin', 'password')
134
+ client.setup_encryption(None)
135
+
136
+ client.organization.create(
137
+ name='My organization',
138
+ address1='My address',
139
+ address2='My address',
140
+ zipcode='1234AB',
141
+ country='The Netherlands',
142
+ domain='my-organization.com'
143
+ )
144
+ ```
145
+
146
+ You can find more (user) documentation at [readthedocs](https://docs.vantage6.ai)
147
+
148
+ ## Project structure
149
+
150
+ ### PYPI packages
151
+
152
+ This repository is home to 6 PyPi packages:
153
+
154
+ - [vantage6](https://pypi.org/project/vantage6) -> _CLI for managing node and server instances_
155
+ - [vantage6-client](https://pypi.org/project/vantage6-client) -> _Python client for interacting with the vantage6-server_
156
+ - [vantage6-algorithm-tools](https://pypi.org/project/vantage6-algorithm-tools) -> _Python tools to facilitate algorithm development_
157
+ - [vantage6-node](https://pypi.org/project/vantage6-node) -> _Node application package_
158
+ - [vantage6-server](https://pypi.org/project/vantage6-server) -> _Server application package_
159
+ - [vantage6-algorithm-store](https://pypi.org/project/vantage6-algorithm-store) -> _Algorithm store application package_
160
+ - [vantage6-common](https://pypi.org/project/vantage6-common) -> _Package with common vantage6 functions_
161
+ - [vantage6-backend-common](https://pypi.org/project/vantage6-backend-common) -> _Package with functions common to central server and algorithm store_
162
+
163
+ **Note that when using vantage6 you do not install the _server_ and _node_ packages. These are delivered to you in Docker images.**
164
+
165
+ This repository also hosts the code for the vantage6 user interface (UI). The UI
166
+ is an Angular web application that can be used to interact with the vantage6 server
167
+ easily.
168
+
169
+ ### Docker images
170
+
171
+ The vantage6 infrastructure is delivered in Docker images. All Docker images are stored
172
+ in our private [Harbor](https://goharbor.io/) registry. The most important images are:
173
+
174
+ - `harbor2.vantage6.ai/infrastructure/node:VERSION` -> _Node application Docker image_
175
+ - `harbor2.vantage6.ai/infrastructure/server:VERSION` -> _Server application Docker image_
176
+ - `harbor2.vantage6.ai/infrastructure/ui:VERSION` -> _User interface Docker image_
177
+ - `harbor2.vantage6.ai/infrastructure/algorithm-store:VERSION` -> _Algorithm store Docker image_
178
+
179
+ with `VERSION` being the full semantic version of the vantage6 infrastructure, e.g.
180
+ `4.0.0` or `4.1.0rc0`.
181
+
182
+ Several other images are used to support the infrastructure:
183
+
184
+ - `harbor2.vantage6.ai/infrastructure/infrastructure-base:VERSION` -> _Base image for the infrastructure_
185
+ - `harbor2.vantage6.ai/infrastructure/squid:VERSION` -> _Squid proxy image used for the whitelisting service_
186
+ - `harbor2.vantage6.ai/infrastructure/alpine` -> _Alpine image used for vpn traffic forwarding_
187
+ - `harbor2.vantage6.ai/infrastructure/vpn-client` -> _VPN image used to connect to the VPN_
188
+ - `harbor2.vantage6.ai/infrastructure/vpn-configurator` -> _VPN image used for initialization_
189
+ - `harbor2.vantage6.ai/infrastructure/ssh-tunnel` -> _SSH tunnel image used for connecting algorithms to external services_
190
+
191
+ And finally there are some images released for algorithm development:
192
+
193
+ - `harbor2.vantage6.ai/infrastructure/algorithm-base:MAJOR.MINOR` -> _Base image for algorithm development_
194
+ - `harbor2.vantage6.ai/infrastructure/algorithm-ohdsi-base:MAJOR.MINOR` -> _Extended algorithm base image for OHDSI algorithm development_
195
+
196
+ ## :gift_heart: Join the community!
197
+
198
+ We hope to continue developing, improving, and supporting **vantage6** with the help of
199
+ the federated learning community. If you are interested in contributing, first of all,
200
+ thank you! Second, please take a look at our
201
+ [contributing guidelines](https://docs.vantage6.ai/en/main/devops/contribute.html)
202
+ and our [code of conduct](CODE_OF_CONDUCT.md).
203
+
204
+ <a href="https://github.com/vantage6/vantage6/graphs/contributors">
205
+ <img src="https://contrib.rocks/image?repo=vantage6/vantage6" />
206
+ </a>
207
+
208
+ ## :scroll: License
209
+
210
+ This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.
211
+
212
+ ## :black_nib: Code of Conduct
213
+
214
+ Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). **By participating in any way in this project you agree to abide by its terms.**
215
+
216
+ ## :black_nib: References
217
+
218
+ If you are using **vantage6**, please cite this repository as well as the accompanying papers as follows:
219
+
220
+ > - F. Martin, M. Sieswerda, H. Alradhi, et al. vantage6. Available at https://doi.org/10.5281/zenodo.7221216. Accessed on MONTH, 20XX.
221
+ > - A. Moncada-Torres, F. Martin, M. Sieswerda, J. van Soest, G. Gelijnse. VANTAGE6: an open source priVAcy preserviNg federaTed leArninG infrastructurE for Secure Insight eXchange. AMIA Annual Symposium Proceedings, 2020, p. 870-877. [[BibTeX](https://arturomoncadatorres.com/bibtex/moncada-torres2020vantage6.txt), [PDF](https://vantage6.ai/vantage6/)]
222
+ > - D. Smits\*, B. van Beusekom\*, F. Martin, L. Veen, G. Geleijnse, A. Moncada-Torres, An Improved Infrastructure for Privacy-Preserving Analysis of Patient Data, Proceedings of the International Conference of Informatics, Management, and Technology in Healthcare (ICIMTH), vol. 25, 2022, p. 144-147. [[BibTeX](https://arturomoncadatorres.com/bibtex/smits2022improved.txt), [PDF](https://ebooks.iospress.nl/volumearticle/60190)]
223
+
224
+ ---
225
+
226
+ <p align="center">
227
+ <a href="https://vantage6.ai">vantage6.ai</a> •
228
+ <a href="https://discord.gg/yAyFf6Y">Discord</a> •
229
+ <a href="https://vantage6.discourse.group/">Discourse</a> •
230
+ <a href="https://docs.vantage6.ai">User documentation</a>
231
+ </p>
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,49 @@
1
+ import codecs
2
+ import os
3
+
4
+ from os import path
5
+ from setuptools import setup, find_namespace_packages
6
+ from pathlib import Path
7
+
8
+ # get current directory
9
+ here = Path(path.abspath(path.dirname(__file__)))
10
+ parent_dir = here.parent.absolute()
11
+
12
+ # get the long description from the README file
13
+ with codecs.open(path.join(parent_dir, "README.md"), encoding="utf-8") as f:
14
+ long_description = f.read()
15
+
16
+ # Read the API version from disk. This file should be located in the package
17
+ # folder, since it's also used to set the pkg.__version__ variable.
18
+ version_path = os.path.join(here, "vantage6", "backend", "common", "_version.py")
19
+ version_ns = {"__file__": version_path}
20
+ with codecs.open(version_path) as f:
21
+ exec(f.read(), {}, version_ns)
22
+
23
+ # setup the package
24
+ setup(
25
+ name="vantage6_backend_common",
26
+ version=version_ns["__version__"],
27
+ description="Vantage6 common backend functionalities",
28
+ long_description=long_description,
29
+ long_description_content_type="text/markdown",
30
+ url="https://github.com/vantage6/vantage6",
31
+ packages=find_namespace_packages(),
32
+ python_requires=">=3.10",
33
+ install_requires=[
34
+ "flask==3.1.1",
35
+ "flask-mail==0.9.1",
36
+ "Flask-RESTful==0.3.10",
37
+ "marshmallow==3.19.0",
38
+ "marshmallow-sqlalchemy==0.29.0",
39
+ "SQLAlchemy==1.4.46",
40
+ "prometheus-client==0.21.1",
41
+ f'vantage6-common == {version_ns["__version__"]}',
42
+ ],
43
+ extras_require={"dev": ["coverage==6.4.4"]},
44
+ package_data={
45
+ "vantage6.backend.common": [
46
+ "__build__",
47
+ ],
48
+ },
49
+ )
@@ -0,0 +1,35 @@
1
+ """Common functionality for the vantage6 server and algorithm store."""
2
+
3
+ from vantage6.common.globals import DEFAULT_API_PATH
4
+
5
+ # make sure the version is available
6
+ from vantage6.backend.common._version import __version__ # noqa: F401
7
+
8
+
9
+ def get_server_url(
10
+ config: dict, server_url_from_request: str | None = None
11
+ ) -> str | None:
12
+ """ "
13
+ Get the server url from the request data, or from the configuration if it is
14
+ not present in the request.
15
+
16
+ Parameters
17
+ ----------
18
+ config : dict
19
+ Server configuration
20
+ server_url_from_request : str | None
21
+ Server url from the request data.
22
+
23
+ Returns
24
+ -------
25
+ str | None
26
+ The server url
27
+ """
28
+ if server_url_from_request:
29
+ return server_url_from_request
30
+ server_url = config.get("server_url")
31
+ # make sure that the server url ends with the api path
32
+ api_path = config.get("api_path", DEFAULT_API_PATH)
33
+ if server_url and not server_url.endswith(api_path):
34
+ server_url = server_url + api_path
35
+ return server_url
@@ -0,0 +1,23 @@
1
+ import os
2
+ import json
3
+
4
+ here = os.path.abspath(os.path.dirname(__file__))
5
+
6
+ with open(os.path.join(here, "__build__")) as fp:
7
+ __build__ = json.load(fp)
8
+
9
+ # Module version
10
+ version_info = (4, 13, 2, "final", __build__, 0)
11
+
12
+ # Module version stage suffix map
13
+ _specifier_ = {"alpha": "a", "beta": "b", "candidate": "rc", "final": ""}
14
+ version = f"{version_info[0]}.{version_info[1]}.{version_info[2]}"
15
+ pre_release = (
16
+ ""
17
+ if version_info[3] == "final"
18
+ else _specifier_[version_info[3]] + str(version_info[4])
19
+ )
20
+ post_release = "" if not version_info[5] else f".post{version_info[5]}"
21
+
22
+ # Module version accessible using thomas.__version__
23
+ __version__ = f"{version}{pre_release}{post_release}"