Skip to content

Commit 1462405

Browse files
committed
Update Sample Server Script
1 parent 36267cd commit 1462405

8 files changed

Lines changed: 32 additions & 7 deletions

File tree

deployment/provider-ebird-init/.env

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ BASE_URL = "http://provider-ebird:17193"
44
SAMPLE_BASE_URL = "http://sample-server:80/api"
55
X_API_KEY = "managementApiKeyProviderEbird"
66
SAMPLES_SERVER_ADMIN_TOKEN="2e21999e5a55"
7-
PROVIDER_ID="provider-ebird"
7+
PROVIDER_ID="provider-ebird"
8+
SAMPLE_CONTENT_URL = "http://sample-server:80/samples"

deployment/provider-ebird-init/scripts/ebird_assets.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ def build_asset(url, metadata, desc, name, api_key, province=None):
99
display_name = name.format(region=province) if province else name
1010
current_time = datetime.now(timezone.utc).replace(microsecond=0).isoformat().replace("+00:00", "Z")
1111

12+
keywords = metadata["keywords"][:]
13+
14+
if province is not None:
15+
keywords.append(province.upper())
16+
17+
18+
1219
return asset_id, {
1320
"@id": asset_id,
1421
"@type": "dcat:Dataset",
@@ -26,6 +33,7 @@ def build_asset(url, metadata, desc, name, api_key, province=None):
2633
"cbm:hasSample": f"sample-{asset_id}",
2734
"dct:title": display_name,
2835
"dct:description": desc,
36+
"dcat:keyword": keywords,
2937
"edc:contenttype": "application/json",
3038
"dct:modified": current_time,
3139
"dct:issued": current_time,
@@ -49,14 +57,20 @@ def build_sample_asset(metadata, name, desc, asset_id, sample_base_url, provider
4957
"""Create sample asset definition dict."""
5058
display_name = name.format(region=province) if province else name
5159
current_time = datetime.now(timezone.utc).replace(microsecond=0).isoformat()
60+
61+
keywords = metadata["keywords"][:]
62+
63+
if province is not None:
64+
keywords.append(province.upper())
65+
5266
return {
5367
"@id": f"sample-{asset_id}",
5468
"@type": "cbm:Sample",
5569
"dcat:distribution": [
5670
{
5771
"@type": "dcat:Distribution",
5872
"dct:format": {"@id": "HttpData"},
59-
"dcat:accessURL": f"{sample_base_url}/samples/{provider_id}/{asset_id}",
73+
"dcat:accessURL": f"{sample_base_url}/{provider_id}/{asset_id}",
6074
"edc:proxyPath": "true",
6175
"authKey": "x-api-key",
6276
"authCode": provider_share_token,
@@ -66,6 +80,7 @@ def build_sample_asset(metadata, name, desc, asset_id, sample_base_url, provider
6680
"cbm:isSampleOf": asset_id,
6781
"dct:title": display_name,
6882
"dct:description": desc,
83+
"dcat:keyword": keywords,
6984
"dct:issued": current_time,
7085
"dct:modified": current_time,
7186
"edc:contenttype": "application/json",

deployment/provider-ebird-init/scripts/main.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
SAMPLES_SERVER_ADMIN_TOKEN = os.getenv("SAMPLES_SERVER_ADMIN_TOKEN")
2626

2727
SAMPLE_BASE_URL = os.getenv("SAMPLE_BASE_URL")
28+
SAMPLE_CONTENT_URL = os.getenv("SAMPLE_CONTENT_URL")
2829
POLICY_DEFINITIONS_URL = f"{BASE_URL}/management/v3/policydefinitions"
2930
CONTRACT_DEFINITIONS_URL = f"{BASE_URL}/management/v3/contractdefinitions"
3031
ASSETS_URL = f"{BASE_URL}/management/v3/assets-cbm"
@@ -203,7 +204,7 @@ def create_asset_and_sample(metadata, url, name, desc, province=None, response_t
203204
"PUT", PROVIDER_TOKEN, sample, response_type, asset_id
204205
)
205206
sample_payload = build_sample_asset(metadata=metadata, name=name, desc=desc,
206-
asset_id=asset_id, sample_base_url=SAMPLE_BASE_URL,
207+
asset_id=asset_id, sample_base_url=SAMPLE_CONTENT_URL,
207208
provider_id=PROVIDER_ID,
208209
provider_share_token=PROVIDER_SHARE_TOKEN,
209210
province=province)
@@ -232,8 +233,12 @@ def main():
232233
)
233234

234235
PROVIDER_PASS, PROVIDER_SHARE_TOKEN = provider_result
236+
237+
logging.info(f"\033[1;34mCREATED PROVIDER\033[0m")
235238
PROVIDER_TOKEN = provider_login(base_url=SAMPLE_BASE_URL, provider_id=PROVIDER_ID, password=PROVIDER_PASS)
236-
239+
240+
logging.info(f"\033[1;34mPROVIDER LOGIN\033[0m")
241+
237242

238243
for config in ASSET_CONFIGS:
239244
metadata = get_metadata(config["metadata_file"])

deployment/provider-ebird-init/scripts/metadata/hotspot_metadata.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"title": "Species Observation Data",
33
"description": "Data on species observed in various locations",
4+
"keywords": ["ECOLOGY", "BIRD", "BIODIVERSITY"],
45
"theme": "Biodiversity",
56
"columns": [
67
{

deployment/provider-ebird-init/scripts/metadata/observation_metadata.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"title": "Bird Observation Data",
33
"description": "Data on various bird species observed in different locations",
4+
"keywords": ["ECOLOGY", "BIRD", "BIODIVERSITY"],
45
"theme": "Wildlife",
56
"columns": [
67
{

deployment/provider-ebird-init/scripts/metadata/recent_checklist_feed_metadata.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"title": "Observation Records",
33
"description": "Records of species observations with location details",
4+
"keywords": ["ECOLOGY", "BIRD", "BIODIVERSITY"],
45
"theme": "Biodiversity",
56
"columns": [
67
{

deployment/samples-server/postgres/init.sql

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@ CREATE TABLE IF NOT EXISTS samples (
2626
id VARCHAR(36) PRIMARY KEY,
2727
asset_id VARCHAR(255),
2828
path VARCHAR(255),
29-
29+
has_header BOOLEAN NOT NULL DEFAULT FALSE,
30+
3031
provider_id VARCHAR(36) NOT NULL,
3132

3233
CONSTRAINT fk_provider
3334
FOREIGN KEY (provider_id)
3435
REFERENCES providers(provider_id)
3536
ON DELETE CASCADE
36-
);
37+
);

providers/provider-ebird/docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ services:
3131

3232
api:
3333
container_name: api
34-
image: ghcr.io/wake-ua/ds-api-samples:ee17751
34+
image: ghcr.io/wake-ua/ds-api-samples:20260312
3535
volumes:
3636
- ${SAMPLES_ROOT}/samples:/samples/
3737
restart: always

0 commit comments

Comments
 (0)