Skip to content

[WIP] Adding Query by Ingestion date #153

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions imap_data_access/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def _print_query_results_table(query_results: list[dict]):
"Data Level",
"Descriptor",
"Start Date",
"Ingestion Date",
"Repointing",
"Version",
"Filename",
Expand Down Expand Up @@ -101,6 +102,7 @@ def _print_query_results_table(query_results: list[dict]):
str(item.get("data_level", "")),
str(item.get("descriptor", "")),
str(item.get("start_date", "")),
str(item.get("ingestion_date", "")),
str(item.get("repointing", "")) or "",
str(item.get("version", "")),
os.path.basename(item.get("file_path", "")),
Expand All @@ -126,6 +128,8 @@ def _query_parser(args: argparse.Namespace):
"descriptor",
"start_date",
"end_date",
"ingestion_start_date",
"ingestion_end_date",
"repointing",
"version",
"extension",
Expand Down Expand Up @@ -334,11 +338,24 @@ def main(): # noqa: PLR0915
required=False,
help="End date for a range of file timestamps in YYYYMMDD format",
)
query_parser.add_argument(
"--ingestion-start-date",
type=str,
required=False,
help="Ingestion start date by for files in YYYYMMDD format",
)
query_parser.add_argument(
"--ingestion-end-date",
type=str,
required=False,
help="Ingestion end date for a range of file timestamps in YYYYMMDD format",
)
query_parser.add_argument(
"--repointing",
type=str,
required=False,
help="Repointing number (repoint00000)",

)
query_parser.add_argument(
"--version",
Expand Down
22 changes: 22 additions & 0 deletions imap_data_access/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ def query(
descriptor: Optional[str] = None,
start_date: Optional[str] = None,
end_date: Optional[str] = None,
ingestion_start_date: Optional[str] = None,
ingestion_end_date: Optional[str] = None,
repointing: Optional[Union[str, int]] = None,
version: Optional[str] = None,
extension: Optional[str] = None,
Expand All @@ -117,6 +119,12 @@ def query(
end_date : str, optional
End date in YYYYMMDD format. Note this is to search for all files
with start dates before the requested end_date.
ingestion_start_date : str, optional
Ingestion start date in YYYYMMDD format. Note this is to search
for all files with ingestion start dates on or after this value.
ingestion_end_date : str, optional
Ingestion end date in YYYYMMDD format. Note this is to search
for all files with ingestion start dates before the requested end_date.
repointing : str, optional
Repointing string, in the format 'repoint00000'
version : str, optional
Expand Down Expand Up @@ -174,6 +182,20 @@ def query(
):
raise ValueError("Not a valid end date, use format 'YYYYMMDD'.")

# Check ingestion-start-date
if (
ingestion_start_date is not None
and not file_validation.ImapFilePath.is_valid_date(ingestion_start_date)
):
raise ValueError("Not a valid ingestion start date, use format 'YYYYMMDD'.")

# Check ingestion-end-date
if (
ingestion_end_date is not None
and not file_validation.ImapFilePath.is_valid_date(ingestion_end_date)
):
raise ValueError("Not a valid ingestion end date, use format 'YYYYMMDD'.")

# Check version make sure to include 'latest'
if version is not None and not file_validation.ImapFilePath.is_valid_version(
version
Expand Down
12 changes: 12 additions & 0 deletions tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ def test_download_already_exists(mock_send_request):
"descriptor": "test-description",
"start_date": "20100101",
"end_date": "20100102",
"ingestion_start_date": "20100101",
"ingestion_end_date": "20100102",
"repointing": "repoint00001",
"version": "v000",
"extension": "pkts",
Expand Down Expand Up @@ -241,6 +243,16 @@ def test_query_bad_params(mock_send_request):
),
("start_date", "badInput", "Not a valid start date, use format 'YYYYMMDD'."),
("end_date", "badInput", "Not a valid end date, use format 'YYYYMMDD'."),
(
"ingestion_start_date",
"badInput",
"Not a valid ingestion start date, use format 'YYYYMMDD'.",
),
(
"ingestion_end_date",
"badInput",
"Not a valid ingestion end date, use format 'YYYYMMDD'.",
),
(
"repointing",
"badInput",
Expand Down