Skip to content

Commit

Permalink
Fix time searching (#336)
Browse files Browse the repository at this point in the history
* Add online test for Time search parameter

* Bit of tidying

* Add another constraint to make sure we get the right dataset

* Parametrize the test because that's how we do things

* Revert "Use execTime for fido search (#326)"

This reverts commit 62039c2.

* Use startTime for fido search again, but right this time

* Put the parameters the right way round so it actually works

* Add changelog
  • Loading branch information
SolarDrew authored Feb 26, 2024
1 parent 7063a0e commit b84e9a0
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 9 deletions.
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

0 comments on commit b84e9a0

Please sign in to comment.