Skip to content

Commit e22bb66

Browse files
authored
feat: set default current-date for collection_from_items script TDE-1298 (#1196)
### Motivation As a basemaps developer, I do not want to set many mandatory CLI arguments. ### Modifications Added the current date / time as a semi-sane default for the --current-date command line argument ### Verification pytest
1 parent ab83041 commit e22bb66

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

scripts/collection_from_items.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import json
33
import os
44
from argparse import Namespace
5+
from datetime import datetime, timezone
56
from typing import TYPE_CHECKING, List
67

78
import shapely.geometry
@@ -10,7 +11,7 @@
1011
from linz_logger import get_log
1112

1213
from scripts.cli.cli_helper import coalesce_multi_single, str_to_gsd
13-
from scripts.datetimes import parse_rfc_3339_datetime
14+
from scripts.datetimes import RFC_3339_DATETIME_FORMAT, parse_rfc_3339_datetime
1415
from scripts.files.files_helper import SUFFIX_FOOTPRINT, SUFFIX_JSON
1516
from scripts.files.fs_s3 import bucket_name_from_path, get_object_parallel_multithreading, list_files_in_uri
1617
from scripts.logging.time_helper import time_in_ms
@@ -114,10 +115,11 @@ def parse_args(args: List[str] | None) -> Namespace:
114115
"--current-datetime",
115116
dest="current_datetime",
116117
help=(
117-
"The datetime that is used as current datetime in the metadata. "
118+
"The datetime to be used as current datetime in the metadata. "
118119
"Format: RFC 3339 UTC datetime, `YYYY-MM-DDThh:mm:ssZ`."
119120
),
120-
required=True,
121+
required=False,
122+
default=datetime.now(timezone.utc).strftime(RFC_3339_DATETIME_FORMAT),
121123
)
122124

123125
return parser.parse_args(args)

scripts/tests/collection_from_items_test.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ def test_should_create_collection_file(item: ImageryItem, fake_linz_slug: str) -
7070
"Placeholder",
7171
"--concurrency",
7272
"25",
73-
"--current-datetime",
74-
any_epoch_datetime_string(),
7573
"--linz-slug",
7674
fake_linz_slug,
7775
]

0 commit comments

Comments
 (0)