Skip to content

Commit eee0581

Browse files
committed
create docstrings
1 parent 1981e8a commit eee0581

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

data_loader/data_loader.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
1-
import click
2-
import os
31
import json
2+
import os
3+
4+
import click
45
import requests
56

67
DATA_DIR = os.path.join(os.path.dirname(__file__), "setup_data/")
78
STAC_API_BASE_URL = "http://localhost:8083"
89

10+
911
def load_data(filename):
12+
"""Load json data."""
1013
with open(os.path.join(DATA_DIR, filename)) as file:
1114
return json.load(file)
1215

16+
1317
def load_collection(collection_id):
18+
"""Load stac collection into the database."""
1419
collection = load_data("collection.json")
1520
collection["id"] = collection_id
1621
try:
@@ -24,7 +29,9 @@ def load_collection(collection_id):
2429
except requests.ConnectionError:
2530
click.secho("failed to connect")
2631

32+
2733
def load_items():
34+
"""Load stac items into the database."""
2835
feature_collection = load_data("sentinel-s2-l2a-cogs_0_100.json")
2936
collection = "test-collection"
3037
load_collection(collection)
@@ -34,8 +41,10 @@ def load_items():
3441
feature["stac_extensions"] = []
3542
feature["stac_version"] = "1.0.0"
3643
feature["collection"] = "test-collection"
37-
resp = requests.post(f"{STAC_API_BASE_URL}/collections/{collection}/items", json=feature)
38-
44+
resp = requests.post(
45+
f"{STAC_API_BASE_URL}/collections/{collection}/items", json=feature
46+
)
47+
3948
if resp.status_code == 200:
4049
print(f"Status code: {resp.status_code}")
4150
print(f"Added item: {feature['id']}")
@@ -45,4 +54,5 @@ def load_items():
4554
except requests.ConnectionError:
4655
click.secho("failed to connect")
4756

57+
4858
load_items()

0 commit comments

Comments
 (0)