Skip to content

Commit 9f90a34

Browse files
committed
fix docstring
1 parent 50c3d26 commit 9f90a34

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

data_loader/data_loader.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
"""Database ingestion script."""
22
import json
33
import os
4+
45
import click
56
import requests
67

78
# Define the directory where your data files are located
89
DATA_DIR = os.path.join(os.path.dirname(__file__), "setup_data/")
910

11+
1012
def load_data(filename):
1113
"""Load json data from a file."""
1214
with open(os.path.join(DATA_DIR, filename)) as file:
1315
return json.load(file)
1416

17+
1518
def load_collection(base_url, collection_id):
1619
"""Load a STAC collection into the database."""
1720
collection = load_data("collection.json")
@@ -27,6 +30,7 @@ def load_collection(base_url, collection_id):
2730
except requests.ConnectionError:
2831
click.secho("Failed to connect", fg="red")
2932

33+
3034
def load_items(base_url, collection_id):
3135
"""Load STAC items into the database."""
3236
feature_collection = load_data("sentinel-s2-l2a-cogs_0_100.json")
@@ -36,7 +40,9 @@ def load_items(base_url, collection_id):
3640
for feature in feature_collection["features"]:
3741
try:
3842
feature["collection"] = collection
39-
resp = requests.post(f"{base_url}/collections/{collection}/items", json=feature)
43+
resp = requests.post(
44+
f"{base_url}/collections/{collection}/items", json=feature
45+
)
4046
if resp.status_code == 200:
4147
click.echo(f"Status code: {resp.status_code}")
4248
click.echo(f"Added item: {feature['id']}")
@@ -46,14 +52,18 @@ def load_items(base_url, collection_id):
4652
except requests.ConnectionError:
4753
click.secho("Failed to connect", fg="red")
4854

55+
4956
@click.command()
50-
@click.option('--base-url', required=True, help='Base URL of the STAC API')
51-
@click.option('--collection-id', default='test-collection', help='ID of the collection to which items are added')
57+
@click.option("--base-url", required=True, help="Base URL of the STAC API")
58+
@click.option(
59+
"--collection-id",
60+
default="test-collection",
61+
help="ID of the collection to which items are added",
62+
)
5263
def main(base_url, collection_id):
53-
"""
54-
Load STAC items into the database.
55-
"""
64+
"""Load STAC items into the database."""
5665
load_items(base_url, collection_id)
5766

58-
if __name__ == '__main__':
67+
68+
if __name__ == "__main__":
5969
main()

0 commit comments

Comments
 (0)