Skip to content

Commit

Permalink
feat: set default current-date for collection_from_items script TDE-1298
Browse files Browse the repository at this point in the history
 (#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
  • Loading branch information
paulfouquet authored Nov 28, 2024
1 parent ab83041 commit e22bb66
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 5 additions & 3 deletions scripts/collection_from_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import json
import os
from argparse import Namespace
from datetime import datetime, timezone
from typing import TYPE_CHECKING, List

import shapely.geometry
Expand All @@ -10,7 +11,7 @@
from linz_logger import get_log

from scripts.cli.cli_helper import coalesce_multi_single, str_to_gsd
from scripts.datetimes import parse_rfc_3339_datetime
from scripts.datetimes import RFC_3339_DATETIME_FORMAT, parse_rfc_3339_datetime
from scripts.files.files_helper import SUFFIX_FOOTPRINT, SUFFIX_JSON
from scripts.files.fs_s3 import bucket_name_from_path, get_object_parallel_multithreading, list_files_in_uri
from scripts.logging.time_helper import time_in_ms
Expand Down Expand Up @@ -114,10 +115,11 @@ def parse_args(args: List[str] | None) -> Namespace:
"--current-datetime",
dest="current_datetime",
help=(
"The datetime that is used as current datetime in the metadata. "
"The datetime to be used as current datetime in the metadata. "
"Format: RFC 3339 UTC datetime, `YYYY-MM-DDThh:mm:ssZ`."
),
required=True,
required=False,
default=datetime.now(timezone.utc).strftime(RFC_3339_DATETIME_FORMAT),
)

return parser.parse_args(args)
Expand Down
2 changes: 0 additions & 2 deletions scripts/tests/collection_from_items_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ def test_should_create_collection_file(item: ImageryItem, fake_linz_slug: str) -
"Placeholder",
"--concurrency",
"25",
"--current-datetime",
any_epoch_datetime_string(),
"--linz-slug",
fake_linz_slug,
]
Expand Down

0 comments on commit e22bb66

Please sign in to comment.