dafab-client 2.2.0__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 (102) hide show
  1. dafab_client-2.2.0/MANIFEST.in +28 -0
  2. dafab_client-2.2.0/PKG-INFO +122 -0
  3. dafab_client-2.2.0/dafab_client/__init__.py +65 -0
  4. dafab_client-2.2.0/dafab_client/_rucio/__init__.py +1 -0
  5. dafab_client-2.2.0/dafab_client/_rucio/client/__init__.py +15 -0
  6. dafab_client-2.2.0/dafab_client/_rucio/client/accountclient.py +578 -0
  7. dafab_client-2.2.0/dafab_client/_rucio/client/baseclient.py +1070 -0
  8. dafab_client-2.2.0/dafab_client/_rucio/client/client.py +133 -0
  9. dafab_client-2.2.0/dafab_client/_rucio/client/credentialclient.py +110 -0
  10. dafab_client-2.2.0/dafab_client/_rucio/client/didclient.py +1057 -0
  11. dafab_client-2.2.0/dafab_client/_rucio/client/downloadclient.py +2058 -0
  12. dafab_client-2.2.0/dafab_client/_rucio/client/pingclient.py +78 -0
  13. dafab_client-2.2.0/dafab_client/_rucio/client/replicaclient.py +570 -0
  14. dafab_client-2.2.0/dafab_client/_rucio/client/rseclient.py +974 -0
  15. dafab_client-2.2.0/dafab_client/_rucio/client/scopeclient.py +116 -0
  16. dafab_client-2.2.0/dafab_client/_rucio/client/uploadclient.py +1514 -0
  17. dafab_client-2.2.0/dafab_client/_rucio/common/cache.py +110 -0
  18. dafab_client-2.2.0/dafab_client/_rucio/common/checksum.py +168 -0
  19. dafab_client-2.2.0/dafab_client/_rucio/common/client.py +96 -0
  20. dafab_client-2.2.0/dafab_client/_rucio/common/config.py +786 -0
  21. dafab_client-2.2.0/dafab_client/_rucio/common/constants.py +247 -0
  22. dafab_client-2.2.0/dafab_client/_rucio/common/constraints.py +17 -0
  23. dafab_client-2.2.0/dafab_client/_rucio/common/didtype.py +237 -0
  24. dafab_client-2.2.0/dafab_client/_rucio/common/exception.py +1305 -0
  25. dafab_client-2.2.0/dafab_client/_rucio/common/extra.py +31 -0
  26. dafab_client-2.2.0/dafab_client/_rucio/common/filter.py +202 -0
  27. dafab_client-2.2.0/dafab_client/_rucio/common/logging.py +420 -0
  28. dafab_client-2.2.0/dafab_client/_rucio/common/pcache.py +1404 -0
  29. dafab_client-2.2.0/dafab_client/_rucio/common/plugins.py +236 -0
  30. dafab_client-2.2.0/dafab_client/_rucio/common/types.py +481 -0
  31. dafab_client-2.2.0/dafab_client/_rucio/common/utils.py +1886 -0
  32. dafab_client-2.2.0/dafab_client/_rucio/core/rse.py +2080 -0
  33. dafab_client-2.2.0/dafab_client/_rucio/dafab_lib.py +317 -0
  34. dafab_client-2.2.0/dafab_client/_rucio/global_utils.py +101 -0
  35. dafab_client-2.2.0/dafab_client/_rucio/overridden_rucio_client.py +788 -0
  36. dafab_client-2.2.0/dafab_client/_rucio/rse/__init__.py +124 -0
  37. dafab_client-2.2.0/dafab_client/_rucio/rse/protocols/__init__.py +13 -0
  38. dafab_client-2.2.0/dafab_client/_rucio/rse/protocols/gfal.py +708 -0
  39. dafab_client-2.2.0/dafab_client/_rucio/rse/protocols/protocol.py +365 -0
  40. dafab_client-2.2.0/dafab_client/_rucio/rse/protocols/webdav.py +621 -0
  41. dafab_client-2.2.0/dafab_client/_rucio/rse/rsemanager.py +897 -0
  42. dafab_client-2.2.0/dafab_client/_rucio/rse/translation.py +271 -0
  43. dafab_client-2.2.0/dafab_client/_rucio/secrets/user_dafab/config +12 -0
  44. dafab_client-2.2.0/dafab_client/_rucio/secrets/user_dafab/rucio_ca_bundle.pem +167 -0
  45. dafab_client-2.2.0/dafab_client/_rucio/version.py +42 -0
  46. dafab_client-2.2.0/dafab_client/example_notebooks/dafab_dasi_workflows.ipynb +315 -0
  47. dafab_client-2.2.0/dafab_client/example_notebooks/dafab_operator_workflows.ipynb +450 -0
  48. dafab_client-2.2.0/dafab_client/example_notebooks/dafab_simple_user_workflows.ipynb +917 -0
  49. dafab_client-2.2.0/dafab_client/example_notebooks/dafab_skim_workflows.ipynb +497 -0
  50. dafab_client-2.2.0/dafab_client/helpers/System/check_available_accounts.py +179 -0
  51. dafab_client-2.2.0/dafab_client/helpers/System/check_storage.py +96 -0
  52. dafab_client-2.2.0/dafab_client/helpers/__init__.py +15 -0
  53. dafab_client-2.2.0/dafab_client/helpers/check_server_health.py +86 -0
  54. dafab_client-2.2.0/dafab_client/helpers/container_management/ensure_container.py +94 -0
  55. dafab_client-2.2.0/dafab_client/helpers/container_management/list_containers.py +128 -0
  56. dafab_client-2.2.0/dafab_client/helpers/dataset_management/ensure_dataset.py +90 -0
  57. dafab_client-2.2.0/dafab_client/helpers/dataset_management/list_datasets.py +76 -0
  58. dafab_client-2.2.0/dafab_client/helpers/dataset_management/scope_management.py +183 -0
  59. dafab_client-2.2.0/dafab_client/helpers/db_bootstrap/account_manager.py +919 -0
  60. dafab_client-2.2.0/dafab_client/helpers/demo_imports.py +96 -0
  61. dafab_client-2.2.0/dafab_client/helpers/did_management/operations.py +160 -0
  62. dafab_client-2.2.0/dafab_client/helpers/file_management/Deletion/delete_file_of_scope_name.py +68 -0
  63. dafab_client-2.2.0/dafab_client/helpers/file_management/Deletion/delete_replica_of_scope_name.py +74 -0
  64. dafab_client-2.2.0/dafab_client/helpers/file_management/Insertion/upload_file_of_scope_name.py +142 -0
  65. dafab_client-2.2.0/dafab_client/helpers/file_management/Retrieval/download_file_of_scope_name.py +150 -0
  66. dafab_client-2.2.0/dafab_client/helpers/file_management/Workflows/manage_derived_assets.py +1240 -0
  67. dafab_client-2.2.0/dafab_client/helpers/file_management/list_files.py +121 -0
  68. dafab_client-2.2.0/dafab_client/helpers/filtering/filter_by_bbox.py +170 -0
  69. dafab_client-2.2.0/dafab_client/helpers/filtering/filter_by_bbox_and_timerange.py +203 -0
  70. dafab_client-2.2.0/dafab_client/helpers/filtering/filter_by_enhanced_filter.py +119 -0
  71. dafab_client-2.2.0/dafab_client/helpers/filtering/filter_by_relationships.py +207 -0
  72. dafab_client-2.2.0/dafab_client/helpers/filtering/filter_by_timerange.py +159 -0
  73. dafab_client-2.2.0/dafab_client/helpers/filtering/mapper.py +388 -0
  74. dafab_client-2.2.0/dafab_client/helpers/metadata_management/Insertion/set_metadata.py +110 -0
  75. dafab_client-2.2.0/dafab_client/helpers/metadata_management/Operations/common.py +100 -0
  76. dafab_client-2.2.0/dafab_client/helpers/metadata_management/Operations/delete_metadata_for_did.py +41 -0
  77. dafab_client-2.2.0/dafab_client/helpers/metadata_management/Operations/insert_metadata_for_did.py +50 -0
  78. dafab_client-2.2.0/dafab_client/helpers/metadata_management/Operations/update_metadata_for_did.py +50 -0
  79. dafab_client-2.2.0/dafab_client/helpers/metadata_management/Operations/upsert_metadata_for_did.py +50 -0
  80. dafab_client-2.2.0/dafab_client/helpers/metadata_management/Patch/patch_metadata_for_dids.py +104 -0
  81. dafab_client-2.2.0/dafab_client/helpers/metadata_management/Preflight/validate_derived_item_file.py +1707 -0
  82. dafab_client-2.2.0/dafab_client/helpers/metadata_management/Preflight/validate_facet_value_catalog_file.py +438 -0
  83. dafab_client-2.2.0/dafab_client/helpers/metadata_management/Preflight/validate_original_item_file.py +1326 -0
  84. dafab_client-2.2.0/dafab_client/helpers/metadata_management/Retrieval/Complete/get_metadata_for_scope_name.py +141 -0
  85. dafab_client-2.2.0/dafab_client/helpers/metadata_management/Retrieval/Partial/get_single_metadata_for_scope_name.py +116 -0
  86. dafab_client-2.2.0/dafab_client/helpers/metadata_management/Workflows/sync_spatial_bbox_integrity.py +1805 -0
  87. dafab_client-2.2.0/dafab_client/helpers/metadata_management/Workflows/update_derived_item.py +999 -0
  88. dafab_client-2.2.0/dafab_client/helpers/metadata_management/Workflows/update_original_item.py +575 -0
  89. dafab_client-2.2.0/dafab_client/helpers/metadata_management/document_api.py +64 -0
  90. dafab_client-2.2.0/dafab_client/helpers/resources/schemas/Schema_Copernicus_with_dafab.json +4781 -0
  91. dafab_client-2.2.0/dafab_client/helpers/resources/schemas/Schema_DaFab_Facet_Value_Catalog.json +52 -0
  92. dafab_client-2.2.0/dafab_client/helpers/resources/schemas/dafab-smart_agriculture-item.schema.json +413 -0
  93. dafab_client-2.2.0/dafab_client/helpers/resources/schemas/dafab-water_analysis-item.schema.json +1134 -0
  94. dafab_client-2.2.0/dafab_client/helpers/runtime_paths.py +80 -0
  95. dafab_client-2.2.0/dafab_client.egg-info/PKG-INFO +122 -0
  96. dafab_client-2.2.0/dafab_client.egg-info/SOURCES.txt +100 -0
  97. dafab_client-2.2.0/dafab_client.egg-info/dependency_links.txt +1 -0
  98. dafab_client-2.2.0/dafab_client.egg-info/requires.txt +6 -0
  99. dafab_client-2.2.0/dafab_client.egg-info/top_level.txt +1 -0
  100. dafab_client-2.2.0/pyproject.toml +41 -0
  101. dafab_client-2.2.0/readme.md +106 -0
  102. dafab_client-2.2.0/setup.cfg +4 -0
@@ -0,0 +1,28 @@
1
+ include pyproject.toml
2
+ include readme.md
3
+
4
+ recursive-include dafab_client *.py
5
+ recursive-include dafab_client/example_notebooks *.ipynb
6
+ recursive-include dafab_client/helpers/resources/schemas *.json
7
+ include dafab_client/_rucio/secrets/user_dafab/config
8
+ include dafab_client/_rucio/secrets/user_dafab/rucio_ca_bundle.pem
9
+
10
+ exclude dafab_client/helpers/System/create_dafab_rse.py
11
+ exclude dafab_client/helpers/System/create_meluxina_s3_rse.py
12
+ exclude dafab_client/helpers/System/filter.py
13
+ exclude dafab_client/helpers/System/test.py
14
+ exclude dafab_client/helpers/dataset_management/remove_dataset.py
15
+ exclude dafab_client/helpers/download_s3_prefix.py
16
+ exclude dafab_client/helpers/metadata_management/Preflight/validate_metadata_file.py
17
+ exclude dafab_client/helpers/metadata_management/Retrieval/get_metadata.py
18
+ exclude dafab_client/helpers/metadata_management/Workflows/initialize_item_metadata.py
19
+ exclude dafab_client/helpers/db_bootstrap/accounts
20
+
21
+ prune tests
22
+ prune docs
23
+ prune demo-data
24
+ prune dev-material
25
+ prune untracked
26
+
27
+ global-exclude __pycache__
28
+ global-exclude *.py[cod]
@@ -0,0 +1,122 @@
1
+ Metadata-Version: 2.4
2
+ Name: dafab_client
3
+ Version: 2.2.0
4
+ Summary: DaFab helper client built on top of Rucio client modules.
5
+ Author: DaFab
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Repository, https://github.com/rucio/rucio
8
+ Requires-Python: >=3.9
9
+ Description-Content-Type: text/markdown
10
+ Requires-Dist: folium<1,>=0.20.0
11
+ Requires-Dist: jsonschema<5,>=4.26.0
12
+ Requires-Dist: packaging<27,>=26.1
13
+ Requires-Dist: requests<3,>=2.33.1
14
+ Requires-Dist: typing_extensions<5,>=4.15
15
+ Requires-Dist: urllib3<3,>=2.6.3
16
+
17
+ # DaFab Client
18
+
19
+ This is the official DaFab client (see https://www.dafab-ai.eu for the project details).
20
+
21
+ ## Install
22
+
23
+ ```bash
24
+ pip install dafab-client
25
+ ```
26
+
27
+ Notes:
28
+ - Runtime requires Python `>=3.9`.
29
+ - Should work on Windows, Linux and macOS.
30
+
31
+ ## Quick Start
32
+
33
+ ```python
34
+ import dafab_client as dc
35
+
36
+ print(dc.ping())
37
+ print(dc.whoami())
38
+ print(dc.list_storages())
39
+ ```
40
+
41
+ All public helpers are available as `dc.<method>`.
42
+
43
+ For examples, you can also copy the packaged simple-user notebook into the current directory:
44
+
45
+ ```bash
46
+ python -c "import dafab_client as dc; print(dc.get_example('user'))"
47
+ ```
48
+
49
+ This overwrites local files if they already exist.
50
+
51
+ ## Simple User API Reference
52
+
53
+ The README focuses on the methods used in `dafab_simple_user_workflows.ipynb`.
54
+ Each method below is also documented in-code via module docstrings.
55
+ For simplicity, only mandatory parameters are listed here.
56
+
57
+ ### Session And Discovery
58
+ - `ping()` : Health check of the connected Rucio/STAC service.
59
+ - `whoami()` : Return authenticated identity/session details.
60
+ - `list_stac_scopes()` : Print visible scopes for the active account.
61
+ - `list_catalogs_and_collections()` : Print catalog/collection container ids in the active scope.
62
+ - `get_catalogs_and_collections()` : Return structured catalog/collection rows.
63
+ - `get_items()` : Return item DID rows.
64
+
65
+ ### Filter And Relationship Queries
66
+ - `get_items_by_enhanced_filter(filter_payload)` : Execute an enhanced STAC filter query.
67
+ - `get_item_ids_by_collection_field(collection_id)` : Resolve item ids by `collection` metadata value.
68
+ - `get_item_ids_by_top_facet_catalog(top_facet_catalog_id)` : Resolve item ids indexed under a top facet catalog.
69
+ - `get_item_ids_by_facet_value_catalog(facet_value_catalog_id)` : Resolve item ids linked from one facet value catalog.
70
+ - `get_related_item_ids_from_original_item(original_item_id)` : Resolve derived item ids linked via `rel=related`.
71
+ - `get_source_original_item_ids_from_derived_item(derived_item_id)` : Resolve original item ids linked via `rel=derived_from`.
72
+ - `get_sibling_derived_item_ids(original_item_id)` : Resolve sibling derived items for one original item.
73
+
74
+ ### Spatial And Temporal Queries
75
+ - `get_items_by_timerange(start_date, end_date)` : Filter items by temporal interval.
76
+ - `get_items_by_bbox(min_long, min_lat, max_long, max_lat)` : Filter items by spatial bounding box.
77
+ - `get_items_by_bbox_and_timerange(bbox, timerange)` : Filter items by combined bbox and time window.
78
+
79
+ ### Metadata Access
80
+ - `extract_metadata_value(value_path)` : Read one metadata value path (requires metadata or `pname` via optional args).
81
+ - `get_bulk_metadata(pname)` : Retrieve full or partial metadata document values.
82
+ - `as_json(data)` : Pretty-print payloads for notebook/debug display.
83
+
84
+ ### Storage And Asset Operations
85
+ - `list_storages()` : Print configured storage endpoints (RSEs).
86
+ - `check_storage(rse_name)` : Fetch one storage endpoint metadata record.
87
+ - `list_item_asset_entries(item_id)` : Inspect an item's `assets` entries.
88
+ - `build_stable_asset_href(item_id, asset_key)` : Build canonical stable asset URL used by DaFab STAC metadata.
89
+ - `download_asset_from_stable_href(stable_href)` : Download content by stable asset URL.
90
+ - `download_item_asset(item_id, asset_key)` : Download one metadata asset by key (URL or attached file resolution).
91
+ - `download_all_derived_item_assets(item_id)` : Download all assets for one derived item.
92
+
93
+ ### Visualization
94
+ - `get_map(metadata_batch)` : Render bbox overlays from metadata to an interactive HTML map.
95
+
96
+
97
+ ## Local Files And Outputs
98
+
99
+ ### Demo-data directory
100
+
101
+ For writable helper outputs, default base directory is:
102
+ - `DAFAB_DEMO_DATA_DIR` (if set), else
103
+ - `<current working directory>/demo-data`
104
+
105
+ `get_map(...)` default output path:
106
+ - `<demo-data-dir>/filters/bbox_map.html`
107
+
108
+ ### Bundled schemas
109
+
110
+ Packaged schema files (used as fallback in validators):
111
+ - `Schema_Copernicus_with_dafab.json`
112
+ - `Schema_DaFab_Facet_Value_Catalog.json`
113
+ - `dafab-smart_agriculture-item.schema.json`
114
+ - `dafab-water_analysis-item.schema.json`
115
+
116
+ ## Logging Defaults
117
+
118
+ Current defaults in `dafab_client._rucio.global_utils`:
119
+ - `debug_mode = False`
120
+ - `minimal_logging = True`
121
+
122
+ So runtime output is intentionally minimal unless logging flags are changed.
@@ -0,0 +1,65 @@
1
+ """Public import namespace for the DaFab client package."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from pathlib import Path
6
+ from shutil import copy2
7
+
8
+ from . import helpers
9
+ from ._rucio.global_utils import get_active_account, set_active_account
10
+
11
+ _ACCOUNT_API = ("get_active_account", "set_active_account")
12
+ _EXAMPLE_NOTEBOOKS_DIR = Path(__file__).resolve().parent / "example_notebooks"
13
+ _EXAMPLE_PROFILE_TO_NOTEBOOK = {
14
+ "user": "dafab_simple_user_workflows.ipynb",
15
+ "admin": "dafab_operator_workflows.ipynb",
16
+ "skim": "dafab_skim_workflows.ipynb",
17
+ "dasi": "dafab_dasi_workflows.ipynb",
18
+ }
19
+ _EXAMPLE_PROFILE_ALIASES = {
20
+ "operator": "admin",
21
+ }
22
+
23
+ __all__ = ("helpers", *_ACCOUNT_API, "get_example", *helpers.__all__)
24
+
25
+
26
+ def get_example(profile: str | None = None, destination: str | Path = ".") -> list[Path]:
27
+ """Copy packaged notebooks into ``destination`` and return copied local paths."""
28
+ if profile is None:
29
+ notebook_names = sorted(set(_EXAMPLE_PROFILE_TO_NOTEBOOK.values()))
30
+ else:
31
+ normalized = str(profile).strip().lower()
32
+ normalized = _EXAMPLE_PROFILE_ALIASES.get(normalized, normalized)
33
+ notebook_name = _EXAMPLE_PROFILE_TO_NOTEBOOK.get(normalized)
34
+ if notebook_name is None:
35
+ valid_profiles = ", ".join(sorted(_EXAMPLE_PROFILE_TO_NOTEBOOK))
36
+ raise ValueError(
37
+ f"Unknown profile '{profile}'. Supported values: {valid_profiles}."
38
+ )
39
+ notebook_names = [notebook_name]
40
+
41
+ target_dir = Path(destination).expanduser().resolve()
42
+ target_dir.mkdir(parents=True, exist_ok=True)
43
+
44
+ copied_paths: list[Path] = []
45
+ for notebook_name in notebook_names:
46
+ source_path = _EXAMPLE_NOTEBOOKS_DIR / notebook_name
47
+ if not source_path.is_file():
48
+ raise FileNotFoundError(f"Missing packaged notebook: {source_path}")
49
+ target_path = target_dir / notebook_name
50
+ copy2(source_path, target_path)
51
+ copied_paths.append(target_path)
52
+
53
+ return copied_paths
54
+
55
+
56
+ def __getattr__(name: str):
57
+ if name in helpers.__all__:
58
+ return getattr(helpers, name)
59
+ if name in _ACCOUNT_API:
60
+ return globals()[name]
61
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
62
+
63
+
64
+ def __dir__() -> list[str]:
65
+ return sorted(set(globals()) | set(__all__))
@@ -0,0 +1 @@
1
+ """Internal vendored Rucio modules used by dafab_client."""
@@ -0,0 +1,15 @@
1
+ # Copyright European Organization for Nuclear Research (CERN) since 2012
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
+ from .client import Client # noqa: F401