Skip to content
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

Fix time searching #336

Merged
merged 9 commits into from
Feb 26, 2024
1 change: 1 addition & 0 deletions changelog/336.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Correct Fido time searching to use `endTimeMin` and `startTimeMax` (in the correct order) so that searching returns any dataset with a partially or completely overlapping time range.
4 changes: 2 additions & 2 deletions dkist/net/attr_walker.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ def iterate_over_and(wlk, tree, params):
# SunPy Attrs
@walker.add_applier(Time)
def _(wlk, attr, params):
return params.update({'execTimeMin': attr.start.isot,
'execTimeMax': attr.end.isot})
return params.update({'endTimeMin': attr.start.isot,
'startTimeMax': attr.end.isot})


@walker.add_applier(Instrument)
Expand Down
2 changes: 1 addition & 1 deletion dkist/net/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def api_param_names():
Excludes ones with input dependant query params
"""
return {
a.Time: ('execTimeMin', 'execTimeMax'),
a.Time: ('endTimeMin', 'startTimeMax'),
a.Instrument: ('instrumentNames',),
a.Wavelength: ('wavelengthRanges',),
a.Physobs: ('hasAllStokes',),
Expand Down
12 changes: 6 additions & 6 deletions dkist/net/tests/test_attr_walker.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ def test_and_simple(query_and_simple):
assert out == [
{
"instrumentNames": "VBI",
"execTimeMin": "2020-06-01T00:00:00.000",
"execTimeMax": "2020-06-02T00:00:00.000",
"endTimeMin": "2020-06-01T00:00:00.000",
"startTimeMax": "2020-06-02T00:00:00.000",
}
]

Expand All @@ -181,12 +181,12 @@ def test_or_instrument(query_or_instrument):
assert out == [
{
"instrumentNames": "VBI",
"execTimeMin": "2020-06-01T00:00:00.000",
"execTimeMax": "2020-06-02T00:00:00.000",
"endTimeMin": "2020-06-01T00:00:00.000",
"startTimeMax": "2020-06-02T00:00:00.000",
},
{
"instrumentNames": "VISP",
"execTimeMin": "2020-06-01T00:00:00.000",
"execTimeMax": "2020-06-02T00:00:00.000",
"endTimeMin": "2020-06-01T00:00:00.000",
"startTimeMax": "2020-06-02T00:00:00.000",
}
]
13 changes: 13 additions & 0 deletions dkist/net/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@ def test_search(client):
res = client.search(a.Time("2019/01/01", "2021/01/01"))


@pytest.mark.remote_data
@pytest.mark.parametrize("time", [
a.Time("2022/12/27 19:55", "2022/12/27 20:01"), # Time range overlaps the end of the dataset
a.Time("2022/12/27 19:26", "2022/12/27 19:30"), # Time range overlaps the start of the dataset
a.Time("2022/12/27 19:30", "2022/12/27 19:35"), # Time range within the dataset
a.Time("2022/12/27 19:26", "2022/12/27 20:01"), # Time range contains dataset
])
def test_search_by_time(client, time):
res = client.search(time, a.Instrument("VBI"))
assert len(res) == 1
assert res[0]["Primary Proposal ID"] == "pid_1_50"
assert res[0]["Start Time"].value == '2022-12-27T19:27:42.338' and res[0]["End Time"].value == '2022-12-27T20:00:09.005'

@pytest.fixture
def empty_query_response():
return DKISTQueryResponseTable()
Expand Down