4 hours instead of 2. Will expose a cli param for Max Run time later
This commit is contained in:
parent
65623e486f
commit
3b0fea6379
@ -50,12 +50,15 @@ from pathlib import Path
|
|||||||
from typing import Dict, List
|
from typing import Dict, List
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|
||||||
def tqdm(iterable, *args, **kwargs):
|
def tqdm(iterable, *args, **kwargs):
|
||||||
return iterable
|
return iterable
|
||||||
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
# Configuration
|
# Configuration
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
@ -65,7 +68,7 @@ API_ASSET_URL = "https://images-api.nasa.gov/asset"
|
|||||||
IMG_DIR = Path("images")
|
IMG_DIR = Path("images")
|
||||||
META_DIR = Path("metadata")
|
META_DIR = Path("metadata")
|
||||||
STATE_FILE = Path("last_run.txt")
|
STATE_FILE = Path("last_run.txt")
|
||||||
MAX_RUN_TIME = 2 * 60 * 60 # 2 hours in seconds
|
MAX_RUN_TIME = 4 * 60 * 60 # 4 hours in seconds
|
||||||
|
|
||||||
# Ensure the output directories exist
|
# Ensure the output directories exist
|
||||||
IMG_DIR.mkdir(parents=True, exist_ok=True)
|
IMG_DIR.mkdir(parents=True, exist_ok=True)
|
||||||
@ -77,7 +80,9 @@ META_DIR.mkdir(parents=True, exist_ok=True)
|
|||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
def parse_args() -> argparse.Namespace:
|
def parse_args() -> argparse.Namespace:
|
||||||
"""Parse CLI arguments."""
|
"""Parse CLI arguments."""
|
||||||
parser = argparse.ArgumentParser(description="Download NASA images for a date range")
|
parser = argparse.ArgumentParser(
|
||||||
|
description="Download NASA images for a date range"
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--start",
|
"--start",
|
||||||
type=str,
|
type=str,
|
||||||
@ -252,7 +257,9 @@ def main() -> None:
|
|||||||
try:
|
try:
|
||||||
save_metadata(item, meta_path)
|
save_metadata(item, meta_path)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"[{idx}] Failed to write metadata for {nasa_id}: {e}", file=sys.stderr)
|
print(
|
||||||
|
f"[{idx}] Failed to write metadata for {nasa_id}: {e}", file=sys.stderr
|
||||||
|
)
|
||||||
|
|
||||||
elapsed = time.time() - start_time
|
elapsed = time.time() - start_time
|
||||||
if downloaded:
|
if downloaded:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user