rs-client-libraries 0.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.
- rs_client_libraries-0.2/LICENSE +201 -0
- rs_client_libraries-0.2/PKG-INFO +44 -0
- rs_client_libraries-0.2/README.adoc +2 -0
- rs_client_libraries-0.2/pyproject.toml +145 -0
- rs_client_libraries-0.2/rs_client/__init__.py +18 -0
- rs_client_libraries-0.2/rs_client/ogcapi/__init__.py +15 -0
- rs_client_libraries-0.2/rs_client/ogcapi/dpr_client.py +231 -0
- rs_client_libraries-0.2/rs_client/ogcapi/ogcapi_client.py +282 -0
- rs_client_libraries-0.2/rs_client/ogcapi/staging_client.py +178 -0
- rs_client_libraries-0.2/rs_client/rs_client.py +277 -0
- rs_client_libraries-0.2/rs_client/stac/__init__.py +15 -0
- rs_client_libraries-0.2/rs_client/stac/auxip_client.py +70 -0
- rs_client_libraries-0.2/rs_client/stac/cadip_client.py +70 -0
- rs_client_libraries-0.2/rs_client/stac/catalog_client.py +479 -0
- rs_client_libraries-0.2/rs_client/stac/stac_base.py +313 -0
- rs_client_libraries-0.2/rs_common/__init__.py +20 -0
- rs_client_libraries-0.2/rs_common/config.py +69 -0
- rs_client_libraries-0.2/rs_common/init_opentelemetry.py +250 -0
- rs_client_libraries-0.2/rs_common/logging.py +107 -0
- rs_client_libraries-0.2/rs_common/prefect_utils.py +407 -0
- rs_client_libraries-0.2/rs_common/utils.py +70 -0
- rs_client_libraries-0.2/rs_workflows/__init__.py +15 -0
- rs_client_libraries-0.2/rs_workflows/auxip_flow.py +70 -0
- rs_client_libraries-0.2/rs_workflows/cadip_flow.py +69 -0
- rs_client_libraries-0.2/rs_workflows/catalog_flow.py +71 -0
- rs_client_libraries-0.2/rs_workflows/dpr_flow.py +272 -0
- rs_client_libraries-0.2/rs_workflows/flow_utils.py +127 -0
- rs_client_libraries-0.2/rs_workflows/on_demand_processing.py +243 -0
- rs_client_libraries-0.2/rs_workflows/staging_flow.py +78 -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,44 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: rs-client-libraries
|
|
3
|
+
Version: 0.2
|
|
4
|
+
Summary: Copernicus Sentinel rs-client library and processing workflows.
|
|
5
|
+
License: Apache-2.0
|
|
6
|
+
Keywords: stac,copernicus,sentinel,processing
|
|
7
|
+
Author: ESA under contract with Airbus and CS
|
|
8
|
+
Author-email: ops_coprs@airbus.com
|
|
9
|
+
Requires-Python: >=3.11,<4.0
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Framework :: OpenTelemetry
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Image Processing
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Requires-Dist: cachetools (>=5.5.2,<6.0.0)
|
|
22
|
+
Requires-Dist: click (==8.1.8)
|
|
23
|
+
Requires-Dist: openapi-core (>=0.19.5,<0.20.0)
|
|
24
|
+
Requires-Dist: opentelemetry-distro (>=0.57b0,<0.58)
|
|
25
|
+
Requires-Dist: opentelemetry-exporter-otlp (>=1.36.0,<2.0.0)
|
|
26
|
+
Requires-Dist: opentelemetry-instrumentation-aws-lambda (>=0.57b0,<0.58)
|
|
27
|
+
Requires-Dist: opentelemetry-test-utils (>=0.57b0,<0.58)
|
|
28
|
+
Requires-Dist: prefect[aws] (==3.2.13)
|
|
29
|
+
Requires-Dist: protobuf (>=5.29.5)
|
|
30
|
+
Requires-Dist: pystac (>=1.13.0,<2.0.0)
|
|
31
|
+
Requires-Dist: pystac-client (>=0.9.0,<0.10.0)
|
|
32
|
+
Requires-Dist: python-dateutil (>=2.9.0.post0,<3.0.0)
|
|
33
|
+
Requires-Dist: python-logging-loki (>=0.3.1,<0.4.0)
|
|
34
|
+
Requires-Dist: requests (>=2.32.4,<3.0.0)
|
|
35
|
+
Requires-Dist: stac-pydantic (>=3.4.0,<4.0.0)
|
|
36
|
+
Requires-Dist: urllib3 (>=2.5.0)
|
|
37
|
+
Project-URL: Documentation, https://home.rs-python.eu/rs-documentation/rs-client-libraries/docs/doc/
|
|
38
|
+
Project-URL: Homepage, https://home.rs-python.eu/
|
|
39
|
+
Project-URL: Repository, https://github.com/RS-PYTHON/rs-client-libraries
|
|
40
|
+
Description-Content-Type: text/plain
|
|
41
|
+
|
|
42
|
+
# rs-client-libraries
|
|
43
|
+
This repository contains all the prefect flows allowing to build Copernicus processing chains.
|
|
44
|
+
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "rs-client-libraries"
|
|
3
|
+
dynamic = ["version"] # see: https://github.com/mtkennerly/poetry-dynamic-versioning
|
|
4
|
+
|
|
5
|
+
[tool.poetry]
|
|
6
|
+
name = "rs-client-libraries"
|
|
7
|
+
version = "0.2"
|
|
8
|
+
description = "Copernicus Sentinel rs-client library and processing workflows."
|
|
9
|
+
license = "Apache-2.0"
|
|
10
|
+
authors = ["ESA under contract with Airbus and CS <ops_coprs@airbus.com>"]
|
|
11
|
+
readme = "README.adoc"
|
|
12
|
+
homepage = "https://home.rs-python.eu/"
|
|
13
|
+
repository = "https://github.com/RS-PYTHON/rs-client-libraries"
|
|
14
|
+
documentation = "https://home.rs-python.eu/rs-documentation/rs-client-libraries/docs/doc/"
|
|
15
|
+
keywords = ["stac", "copernicus", "sentinel", "processing"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 3 - Alpha",
|
|
18
|
+
"Framework :: OpenTelemetry",
|
|
19
|
+
"Intended Audience :: Developers",
|
|
20
|
+
"Intended Audience :: Science/Research",
|
|
21
|
+
"License :: OSI Approved :: Apache Software License",
|
|
22
|
+
"Programming Language :: Python :: 3.11",
|
|
23
|
+
"Topic :: Scientific/Engineering :: Image Processing",
|
|
24
|
+
"Topic :: Software Development :: Libraries :: Python Modules"
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
packages = [
|
|
28
|
+
{ include = "rs_client" },
|
|
29
|
+
{ include = "rs_common" },
|
|
30
|
+
{ include = "rs_workflows" },
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
# Add configuration files to the .whl package
|
|
34
|
+
include = [
|
|
35
|
+
{ path = "config", format = ["wheel"] }
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
[tool.poetry.dependencies]
|
|
39
|
+
python = "^3.11"
|
|
40
|
+
opentelemetry-distro = "^0.57b0" # then run 'poetry run opentelemetry-bootstrap -a install'
|
|
41
|
+
opentelemetry-instrumentation-aws-lambda = "^0.57b0"
|
|
42
|
+
opentelemetry-test-utils = "^0.57b0"
|
|
43
|
+
opentelemetry-exporter-otlp = "^1.36.0"
|
|
44
|
+
protobuf = ">=5.29.5"
|
|
45
|
+
python-logging-loki = "^0.3.1" # to avoid otl error: No module named 'logging_loki'
|
|
46
|
+
cachetools = "^5.5.2"
|
|
47
|
+
pystac = "^1.13.0"
|
|
48
|
+
pystac-client = "^0.9.0"
|
|
49
|
+
python-dateutil = "^2.9.0.post0"
|
|
50
|
+
stac-pydantic = "^3.4.0"
|
|
51
|
+
openapi-core = "^0.19.5"
|
|
52
|
+
click = "8.1.8"
|
|
53
|
+
prefect = { version = "3.2.13", extras = ["aws"] }
|
|
54
|
+
requests = "^2.32.4"
|
|
55
|
+
urllib3 = ">=2.5.0"
|
|
56
|
+
|
|
57
|
+
[tool.poetry.group.dev]
|
|
58
|
+
optional = true
|
|
59
|
+
|
|
60
|
+
[tool.poetry.group.dev.dependencies]
|
|
61
|
+
pytest = "^8.3.5"
|
|
62
|
+
pytest-cov = "^6.2.1"
|
|
63
|
+
pytest-mock = "^3.14.0"
|
|
64
|
+
pytest-error-for-skips = "^2.0.2"
|
|
65
|
+
black = "==25.1.0"
|
|
66
|
+
mypy = "^1.16.0"
|
|
67
|
+
pre-commit = "^4.1.0"
|
|
68
|
+
bandit = "^1.8.3"
|
|
69
|
+
safety = "^3.5.2"
|
|
70
|
+
pylint = "^3.3.4"
|
|
71
|
+
pytest-docker = "^3.1.2"
|
|
72
|
+
sphinx = "^8.1.3"
|
|
73
|
+
sphinx-rtd-theme = "^3.0.2"
|
|
74
|
+
flake8 = "^7.1.1"
|
|
75
|
+
flake8-pyproject = "^1.2.3"
|
|
76
|
+
responses = "^0.25.7"
|
|
77
|
+
starlette = "^0.47.2"
|
|
78
|
+
pytest-asyncio = "^1.1.0"
|
|
79
|
+
|
|
80
|
+
[tool.poetry.group.demo.dependencies] # for hybrid mode
|
|
81
|
+
jupyterlab = "^4.2.1"
|
|
82
|
+
boto3 = "^1.38.34"
|
|
83
|
+
papermill = "^2.6.0"
|
|
84
|
+
tornado = "^6.5" # fix trivy vulnerability
|
|
85
|
+
|
|
86
|
+
[tool.poetry.requires-plugins]
|
|
87
|
+
poetry-dynamic-versioning = { version = ">=1.0.0,<2.0.0", extras = ["plugin"] }
|
|
88
|
+
|
|
89
|
+
[tool.poetry-dynamic-versioning]
|
|
90
|
+
enable = false
|
|
91
|
+
metadata = false
|
|
92
|
+
|
|
93
|
+
[build-system]
|
|
94
|
+
requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning>=1.0.0,<2.0.0"]
|
|
95
|
+
build-backend = "poetry_dynamic_versioning.backend"
|
|
96
|
+
|
|
97
|
+
[tool.black]
|
|
98
|
+
line-length = 120
|
|
99
|
+
|
|
100
|
+
[tool.pytest.ini_options]
|
|
101
|
+
markers = [
|
|
102
|
+
"unit", # mark a test as unittest
|
|
103
|
+
"integration", # mark a test as integration test
|
|
104
|
+
]
|
|
105
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
106
|
+
asyncio_mode = "auto"
|
|
107
|
+
|
|
108
|
+
[tool.mypy]
|
|
109
|
+
warn_redundant_casts = true
|
|
110
|
+
# Force analyze of partially annotate function signatures
|
|
111
|
+
check_untyped_defs = true
|
|
112
|
+
ignore_missing_imports = true
|
|
113
|
+
disable_error_code = ["call-overload"]
|
|
114
|
+
|
|
115
|
+
[tool.flake8]
|
|
116
|
+
max-line-length = 120
|
|
117
|
+
# per-file-ignores = [
|
|
118
|
+
# '__init__.py:F401',
|
|
119
|
+
# ]
|
|
120
|
+
|
|
121
|
+
[tool.pylint.messages_control]
|
|
122
|
+
max-line-length=120
|
|
123
|
+
disable = [
|
|
124
|
+
"logging-fstring-interpolation",
|
|
125
|
+
"global-statement",
|
|
126
|
+
"too-many-arguments",
|
|
127
|
+
"too-many-positional-arguments",
|
|
128
|
+
"not-context-manager",
|
|
129
|
+
"too-many-locals",
|
|
130
|
+
"too-many-branches",
|
|
131
|
+
"too-many-statements",
|
|
132
|
+
]
|
|
133
|
+
|
|
134
|
+
[tool.pylint.MASTER]
|
|
135
|
+
ignore-paths = '^docs/.*$'
|
|
136
|
+
|
|
137
|
+
[tool.pylint.MISCELLANEOUS]
|
|
138
|
+
notes = ["XXX"] # no errors on TODO and FIXME
|
|
139
|
+
|
|
140
|
+
[tool.pylint.SIMILARITIES]
|
|
141
|
+
# Minimum lines number of a similarity FIXME.
|
|
142
|
+
min-similarity-lines=10
|
|
143
|
+
|
|
144
|
+
[tool.bandit.assert_used]
|
|
145
|
+
skips = ['*/test_*.py']
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Copyright 2024 CS Group
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
"""rsclient main module."""
|
|
16
|
+
|
|
17
|
+
# Set automatically by running `poetry dynamic-versioning`
|
|
18
|
+
__version__ = "0.2"
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Copyright 2024 CS Group
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
"""ogc api modules."""
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
# Copyright 2024 CS Group
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
"""Use "DPR as a service" implemented by rs-dpr-service"""
|
|
16
|
+
|
|
17
|
+
import ast
|
|
18
|
+
import os.path as osp
|
|
19
|
+
import tempfile
|
|
20
|
+
|
|
21
|
+
import yaml
|
|
22
|
+
from openapi_core import OpenAPI # Spec, validate_request, validate_response
|
|
23
|
+
|
|
24
|
+
from rs_client.ogcapi.ogcapi_client import OgcApiClient
|
|
25
|
+
from rs_common import prefect_utils
|
|
26
|
+
from rs_common.utils import get_href_service
|
|
27
|
+
|
|
28
|
+
PATH_TO_YAML_OPENAPI = osp.realpath(
|
|
29
|
+
osp.join(
|
|
30
|
+
osp.dirname(__file__),
|
|
31
|
+
"../../config",
|
|
32
|
+
"staging_templates",
|
|
33
|
+
"yaml",
|
|
34
|
+
"dpr_openapi_schema.yaml",
|
|
35
|
+
),
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class DprClient(OgcApiClient):
|
|
40
|
+
"""Implement the OGC API client for 'DPR as a service'."""
|
|
41
|
+
|
|
42
|
+
##########################################
|
|
43
|
+
# Override parent methods and attributes #
|
|
44
|
+
##########################################
|
|
45
|
+
|
|
46
|
+
# Init the OpenAPI instance from config file
|
|
47
|
+
openapi = OpenAPI.from_file_path(PATH_TO_YAML_OPENAPI)
|
|
48
|
+
|
|
49
|
+
@property
|
|
50
|
+
def endpoint_prefix(self) -> str:
|
|
51
|
+
"""Return the endpoints prefix, if any."""
|
|
52
|
+
return "dpr/"
|
|
53
|
+
|
|
54
|
+
@property
|
|
55
|
+
def href_service(self) -> str:
|
|
56
|
+
"""
|
|
57
|
+
Return the rs-dpr-service URL hostname.
|
|
58
|
+
This URL can be overwritten using the RSPY_HOST_DPR_SERVICE env variable (used e.g. for local mode).
|
|
59
|
+
Otherwise it should just be the RS-Server URL.
|
|
60
|
+
"""
|
|
61
|
+
return get_href_service(self.rs_server_href, "RSPY_HOST_DPR_SERVICE")
|
|
62
|
+
|
|
63
|
+
def run_process(
|
|
64
|
+
self,
|
|
65
|
+
process: str,
|
|
66
|
+
s3_config_dir: str,
|
|
67
|
+
payload_subpath: str,
|
|
68
|
+
s3_report_dir: str | None,
|
|
69
|
+
use_dpr_mockup: bool = False,
|
|
70
|
+
) -> dict:
|
|
71
|
+
"""Method to start the process from rs-client - Call the endpoint /processes/{process}/execution
|
|
72
|
+
|
|
73
|
+
Args:
|
|
74
|
+
process: Process name
|
|
75
|
+
s3_config_dir: S3 bucket folder that contains the payload and configuration files to pass to the processor
|
|
76
|
+
payload_subpath: Payload file path, relative to the config folder
|
|
77
|
+
s3_report_dir: S3 bucket folder were the processor report files will be written (optional). All the eopf
|
|
78
|
+
local files written in the local "./reports" directory will be pushed to this S3 bucket folder.
|
|
79
|
+
use_dpr_mockup: Use the real or the mockup DPR processor ?
|
|
80
|
+
|
|
81
|
+
Return:
|
|
82
|
+
job_id (int, str): Returns the status code of the request + the identifier
|
|
83
|
+
(or None if endpoint fails) of the running job
|
|
84
|
+
"""
|
|
85
|
+
|
|
86
|
+
# Data to pass to the real processor
|
|
87
|
+
data = {}
|
|
88
|
+
if not use_dpr_mockup:
|
|
89
|
+
data = {
|
|
90
|
+
"s3_config_dir": s3_config_dir,
|
|
91
|
+
"payload_subpath": payload_subpath,
|
|
92
|
+
"s3_report_dir": s3_report_dir,
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
# For the mockup processor, pass the payload contents.
|
|
96
|
+
# Download the payload file into a temp file.
|
|
97
|
+
else:
|
|
98
|
+
with tempfile.NamedTemporaryFile() as temp:
|
|
99
|
+
prefect_utils.s3_download_file( # type: ignore
|
|
100
|
+
osp.join(s3_config_dir, payload_subpath),
|
|
101
|
+
temp.name,
|
|
102
|
+
_sync=True, # type: ignore
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
# Read it as a yaml file
|
|
106
|
+
with open(temp.name, encoding="utf-8") as opened:
|
|
107
|
+
data = yaml.safe_load(opened)
|
|
108
|
+
|
|
109
|
+
# Add extra info
|
|
110
|
+
data.update({"use_mockup": use_dpr_mockup})
|
|
111
|
+
|
|
112
|
+
# Call the parent method
|
|
113
|
+
return super()._run_process(process, data)
|
|
114
|
+
|
|
115
|
+
def run_conv_safe_zarr(self, payload: dict):
|
|
116
|
+
"""Method to start the safe to zarr conversion process from rs-client -
|
|
117
|
+
Call the endpoint /processes/conv_safe_zarr/execution
|
|
118
|
+
|
|
119
|
+
Args:
|
|
120
|
+
payload: Dictionary to pass to the processor,
|
|
121
|
+
containing input_safe_path - the s3 path of legacy product and
|
|
122
|
+
output_zarr_dir_path - the s3 path for the new zarr
|
|
123
|
+
Return:
|
|
124
|
+
job_id (int, str): Returns the status code of the request + the identifier
|
|
125
|
+
(or None if endpoint fails) of the running job
|
|
126
|
+
"""
|
|
127
|
+
return super()._run_process("conv_safe_zarr", payload)
|
|
128
|
+
|
|
129
|
+
def wait_for_job(self, *args, **kwargs) -> list[dict]: # type: ignore
|
|
130
|
+
"""
|
|
131
|
+
Wait for job to finish.
|
|
132
|
+
|
|
133
|
+
Returns:
|
|
134
|
+
EOPF results
|
|
135
|
+
"""
|
|
136
|
+
# Call parent method and parse results
|
|
137
|
+
job_status = super().wait_for_job(*args, **kwargs)
|
|
138
|
+
return ast.literal_eval(job_status["message"])
|
|
139
|
+
|
|
140
|
+
######################################################
|
|
141
|
+
# These endpoints are not implemented by the service #
|
|
142
|
+
######################################################
|
|
143
|
+
|
|
144
|
+
def get_processes(self) -> dict:
|
|
145
|
+
raise NotImplementedError
|
|
146
|
+
|
|
147
|
+
def get_jobs(self) -> dict:
|
|
148
|
+
raise NotImplementedError
|
|
149
|
+
|
|
150
|
+
def delete_job(self, _: str) -> dict:
|
|
151
|
+
raise NotImplementedError
|
|
152
|
+
|
|
153
|
+
def get_job_results(self, _: str) -> dict:
|
|
154
|
+
raise NotImplementedError
|
|
155
|
+
|
|
156
|
+
####################
|
|
157
|
+
# Specific methods #
|
|
158
|
+
####################
|
|
159
|
+
|
|
160
|
+
async def update_configuration(self, local_path: str, s3_path: str, is_payload: bool = False, **kwargs):
|
|
161
|
+
"""
|
|
162
|
+
Update local configuration file depending on the environment, upload it to the s3 bucket,
|
|
163
|
+
and initialize output bucket folders.
|
|
164
|
+
|
|
165
|
+
Args:
|
|
166
|
+
local_path: Local configuration file path
|
|
167
|
+
s3_path: S3 bucket path where to upload to modified updated configuration file
|
|
168
|
+
is_payload: Specific behavior for the processor payload files
|
|
169
|
+
kwargs: Specific environment variables to expand in the configuration file
|
|
170
|
+
"""
|
|
171
|
+
|
|
172
|
+
to_expand = {}
|
|
173
|
+
|
|
174
|
+
if self.local_mode:
|
|
175
|
+
# In local mode, replace the S3_xxx_CLUSTER env vars, by the env vars from the ~/.s3cfg
|
|
176
|
+
# config file, that contains access to the "real" s3 bucket
|
|
177
|
+
to_expand = {
|
|
178
|
+
"S3_ACCESSKEY_CLUSTER": "${access_key}",
|
|
179
|
+
"S3_SECRETKEY_CLUSTER": "${secret_key}",
|
|
180
|
+
"S3_ENDPOINT_CLUSTER": "${host_bucket}",
|
|
181
|
+
"S3_REGION_CLUSTER": "${bucket_location}",
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
else:
|
|
185
|
+
# In cluster mode, just use the "real" s3 bucket
|
|
186
|
+
to_expand = {
|
|
187
|
+
"S3_ACCESSKEY_CLUSTER": "${S3_ACCESSKEY}",
|
|
188
|
+
"S3_SECRETKEY_CLUSTER": "${S3_SECRETKEY}",
|
|
189
|
+
"S3_ENDPOINT_CLUSTER": "${S3_ENDPOINT}",
|
|
190
|
+
"S3_REGION_CLUSTER": "${S3_REGION}",
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
# Also expand the user-given parameters
|
|
194
|
+
to_expand.update(kwargs)
|
|
195
|
+
|
|
196
|
+
# Open the input local file
|
|
197
|
+
with open(local_path, encoding="utf-8") as opened:
|
|
198
|
+
contents = opened.read()
|
|
199
|
+
|
|
200
|
+
# Expand the env vars as $key, ${key} or %key%
|
|
201
|
+
for key, value in to_expand.items():
|
|
202
|
+
for key2 in f"${key}", f"${{{key}}}", f"%{key}%":
|
|
203
|
+
contents = contents.replace(key2, str(value))
|
|
204
|
+
|
|
205
|
+
# Read the payload contents
|
|
206
|
+
if is_payload:
|
|
207
|
+
payload = yaml.safe_load(contents)
|
|
208
|
+
|
|
209
|
+
# We need to create the output S3 folder with a dummy file before running DPR
|
|
210
|
+
for output_product in payload["I/O"]["output_products"]:
|
|
211
|
+
s3_output_dir = output_product["path"]
|
|
212
|
+
s3_empty_file = f"{s3_output_dir}/.empty"
|
|
213
|
+
self.logger.info(f"Write empty file: {self.logger.level} {s3_empty_file!r}")
|
|
214
|
+
await prefect_utils.s3_upload_empty_file(s3_empty_file)
|
|
215
|
+
|
|
216
|
+
# Change the dask authentication for local mode
|
|
217
|
+
cluster_config = payload["dask_context"]["cluster_config"]
|
|
218
|
+
if self.local_mode:
|
|
219
|
+
cluster_config["auth"] = cluster_config["auth_local_mode"]
|
|
220
|
+
del cluster_config["auth_local_mode"]
|
|
221
|
+
|
|
222
|
+
# yaml to str conversion
|
|
223
|
+
contents = yaml.dump(payload, default_flow_style=False, sort_keys=False)
|
|
224
|
+
|
|
225
|
+
# Write the modified contents to a temp file
|
|
226
|
+
with tempfile.NamedTemporaryFile() as tmp:
|
|
227
|
+
tmp.write(contents.encode("utf-8"))
|
|
228
|
+
tmp.flush()
|
|
229
|
+
|
|
230
|
+
# Upload the temp file to the s3 bucket
|
|
231
|
+
return await prefect_utils.s3_upload_file(tmp.name, s3_path)
|