Skip to content

Commit 17162a8

Browse files
committed
changed server option to domain to be more consistent
1 parent f83c339 commit 17162a8

16 files changed

+92
-97
lines changed

sliderule/icesat2.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -769,10 +769,11 @@ def atl06p(parm, asset=DEFAULT_ASSET, version=DEFAULT_ICESAT2_SDP_VERSION, callb
769769
rsps = sliderule.source("atl06p", rqst, stream=True, callbacks=callbacks)
770770

771771
# Check for Output Options
772-
if parm["output"] and parm["output"]["open_on_complete"]:
773-
df = geopandas.pd.read_parquet(parm["output"]["path"])
774-
profiles[atl06p.__name__] = time.perf_counter() - tstart
775-
return df
772+
if "output" in parm and "open_on_complete" in parm["output"]:
773+
if parm["output"]["open_on_complete"]:
774+
df = geopandas.pd.read_parquet(parm["output"]["path"])
775+
profiles[atl06p.__name__] = time.perf_counter() - tstart
776+
return df
776777

777778
# Flatten Responses
778779
tstart_flatten = time.perf_counter()

sliderule/sliderule.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ def source (api, parm={}, stream=False, callbacks={}, path="/source"):
467467
except requests.exceptions.SSLError as e:
468468
raise FatalError("Unable to verify SSL certificate: {}".format(e))
469469
except requests.ConnectionError as e:
470-
raise FatalError("Failed to connect to endpoint {}".format(url))
470+
raise FatalError("Connection error to endpoint {}".format(url))
471471
except requests.Timeout as e:
472472
raise TransientError("Timed-out waiting for response from endpoint {}".format(url))
473473
except requests.exceptions.ChunkedEncodingError as e:

tests/conftest.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import pytest
22

33
def pytest_addoption(parser):
4-
parser.addoption("--server", action="store", default="slideruleearth.io")
4+
parser.addoption("--domain", action="store", default="slideruleearth.io")
55
parser.addoption("--asset", action="store", default="nsidc-s3")
66
parser.addoption("--organization", action="store", default="sliderule")
77

88
@pytest.fixture(scope='session')
9-
def server(request):
10-
server_value = request.config.option.server
11-
if server_value is None:
9+
def domain(request):
10+
domain_value = request.config.option.domain
11+
if domain_value is None:
1212
pytest.skip()
13-
return server_value
13+
return domain_value
1414

1515
@pytest.fixture(scope='session')
1616
def asset(request):

tests/test_algorithm.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
@pytest.mark.network
1010
class TestAlgorithm:
11-
def test_atl06(self, server, asset, organization):
12-
icesat2.init(server, organization=organization)
11+
def test_atl06(self, domain, asset, organization):
12+
icesat2.init(domain, organization=organization)
1313
resource = "ATL03_20181019065445_03150111_004_01.h5"
1414
parms = { "cnf": "atl03_high",
1515
"ats": 20.0,
@@ -22,8 +22,8 @@ def test_atl06(self, server, asset, organization):
2222
assert min(gdf["cycle"]) == 1
2323
assert len(gdf["h_mean"]) == 622423
2424

25-
def test_atl06p(self, server, asset, organization):
26-
icesat2.init(server, organization=organization)
25+
def test_atl06p(self, domain, asset, organization):
26+
icesat2.init(domain, organization=organization)
2727
resource = "ATL03_20181019065445_03150111_004_01.h5"
2828
parms = { "cnf": "atl03_high",
2929
"ats": 20.0,
@@ -36,8 +36,8 @@ def test_atl06p(self, server, asset, organization):
3636
assert min(gdf["cycle"]) == 1
3737
assert len(gdf["h_mean"]) == 622423
3838

39-
def test_atl03s(self, server, asset, organization):
40-
icesat2.init(server, organization=organization)
39+
def test_atl03s(self, domain, asset, organization):
40+
icesat2.init(domain, organization=organization)
4141
resource = "ATL03_20181019065445_03150111_004_01.h5"
4242
region = [ { "lat": -80.75, "lon": -70.00 },
4343
{ "lat": -81.00, "lon": -70.00 },
@@ -60,8 +60,8 @@ def test_atl03s(self, server, asset, organization):
6060
assert min(gdf["cycle"]) == 1
6161
assert len(gdf["height"]) == 488673
6262

63-
def test_atl03sp(self, server, asset, organization):
64-
icesat2.init(server, organization=organization)
63+
def test_atl03sp(self, domain, asset, organization):
64+
icesat2.init(domain, organization=organization)
6565
resource = "ATL03_20181019065445_03150111_004_01.h5"
6666
region = [ { "lat": -80.75, "lon": -70.00 },
6767
{ "lat": -81.00, "lon": -70.00 },
@@ -84,8 +84,8 @@ def test_atl03sp(self, server, asset, organization):
8484
assert min(gdf["cycle"]) == 1
8585
assert len(gdf["height"]) == 488673
8686

87-
def test_atl08(self, server, asset, organization):
88-
icesat2.init(server, organization=organization)
87+
def test_atl08(self, domain, asset, organization):
88+
icesat2.init(domain, organization=organization)
8989
resource = "ATL03_20181213075606_11560106_004_01.h5"
9090
track = 1
9191
region = [ {"lon": -108.3435200747503, "lat": 38.89102961045247},
@@ -113,8 +113,8 @@ def test_atl08(self, server, asset, organization):
113113
assert len(gdf[gdf["atl08_class"] == 3]) == 18958
114114
assert len(gdf[gdf["atl08_class"] == 4]) == 16050
115115

116-
def test_gs(self, server, asset, organization):
117-
icesat2.init(server, organization=organization)
116+
def test_gs(self, domain, asset, organization):
117+
icesat2.init(domain, organization=organization)
118118
resource_prefix = "20210114170723_03311012_004_01.h5"
119119
region = [ {"lon": 126.54560629670780, "lat": -70.28232209449946},
120120
{"lon": 114.29798416287946, "lat": -70.08880029415151},

tests/test_ancillary.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
@pytest.mark.network
1313
class TestRemote:
1414

15-
def test_geo(self, server, asset, organization):
16-
icesat2.init(server, organization=organization)
15+
def test_geo(self, domain, asset, organization):
16+
icesat2.init(domain, organization=organization)
1717
region = icesat2.toregion(os.path.join(TESTDIR, "data/grandmesa.geojson"))
1818
parms = {
1919
"poly": region["poly"],
@@ -24,8 +24,8 @@ def test_geo(self, server, asset, organization):
2424
assert len(gdf["solar_elevation"]) == 1180
2525
assert gdf['solar_elevation'].describe()["min"] - 20.803468704223633 < 0.0000001
2626

27-
def test_ph(self, server, asset, organization):
28-
icesat2.init(server, organization=organization)
27+
def test_ph(self, domain, asset, organization):
28+
icesat2.init(domain, organization=organization)
2929
region = icesat2.toregion(os.path.join(TESTDIR, "data/grandmesa.geojson"))
3030
parms = {
3131
"poly": region["poly"],

tests/test_api.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
@pytest.mark.network
1111
class TestApi:
12-
def test_time(self, server, organization):
13-
icesat2.init(server, organization=organization)
12+
def test_time(self, domain, organization):
13+
icesat2.init(domain, organization=organization)
1414
rqst = {
1515
"time": "NOW",
1616
"input": "NOW",
@@ -28,8 +28,8 @@ def test_time(self, server, organization):
2828
again = d["time"]
2929
assert now == again
3030

31-
def test_geospatial1(self, server, asset, organization):
32-
icesat2.init(server, organization=organization)
31+
def test_geospatial1(self, domain, asset, organization):
32+
icesat2.init(domain, organization=organization)
3333
test = {
3434
"asset": asset,
3535
"pole": "north",
@@ -73,8 +73,8 @@ def test_geospatial1(self, server, asset, organization):
7373
assert d["lat"] == 40.0 and d["lon"] == 60.0
7474
assert d["x"] == 0.466307658155 and d["y"] == 0.80766855588292
7575

76-
def test_geospatial2(self, server, asset, organization):
77-
icesat2.init(server, organization=organization)
76+
def test_geospatial2(self, domain, asset, organization):
77+
icesat2.init(domain, organization=organization)
7878
test = {
7979
"asset": asset,
8080
"pole": "north",
@@ -86,8 +86,8 @@ def test_geospatial2(self, server, asset, organization):
8686
d = sliderule.source("geo", test)
8787
assert abs(d["lat"] - 30.0) < 0.0001 and d["lon"] == 100.0
8888

89-
def test_geospatial3(self, server, asset, organization):
90-
icesat2.init(server, organization=organization)
89+
def test_geospatial3(self, domain, asset, organization):
90+
icesat2.init(domain, organization=organization)
9191
test = {
9292
"asset": asset,
9393
"pole": "north",
@@ -99,8 +99,8 @@ def test_geospatial3(self, server, asset, organization):
9999
d = sliderule.source("geo", test)
100100
assert abs(d["lat"] - 30.0) < 0.0001 and d["lon"] == -100.0
101101

102-
def test_geospatial4(self, server, asset, organization):
103-
icesat2.init(server, organization=organization)
102+
def test_geospatial4(self, domain, asset, organization):
103+
icesat2.init(domain, organization=organization)
104104
test = {
105105
"asset": asset,
106106
"pole": "north",
@@ -112,16 +112,16 @@ def test_geospatial4(self, server, asset, organization):
112112
d = sliderule.source("geo", test)
113113
assert abs(d["lat"] - 30.0) < 0.0001 and d["lon"] == -80.0
114114

115-
def test_definition(self, server, organization):
116-
icesat2.init(server, organization=organization)
115+
def test_definition(self, domain, organization):
116+
icesat2.init(domain, organization=organization)
117117
rqst = {
118118
"rectype": "atl06rec.elevation",
119119
}
120120
d = sliderule.source("definition", rqst)
121121
assert d["delta_time"]["offset"] == 256
122122

123-
def test_version(self, server, organization):
124-
icesat2.init(server, organization=organization)
123+
def test_version(self, domain, organization):
124+
icesat2.init(domain, organization=organization)
125125
rsps = sliderule.source("version", {})
126126
assert 'server' in rsps
127127
assert 'version' in rsps['server']

tests/test_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ def test_gps2utc(self):
1919

2020
@pytest.mark.network
2121
class TestRemote:
22-
def test_check_version(self, server, organization):
23-
sliderule.set_url(server)
22+
def test_check_version(self, domain, organization):
23+
sliderule.set_url(domain)
2424
sliderule.authenticate(organization)
2525
sliderule.check_version(plugins=['icesat2'])
2626

tests/test_geojson.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
@pytest.mark.network
1111
class TestGeoJson:
12-
def test_atl06(self, server, asset, organization):
13-
icesat2.init(server, organization=organization)
12+
def test_atl06(self, domain, asset, organization):
13+
icesat2.init(domain, organization=organization)
1414
for testfile in ["data/grandmesa.geojson", "data/grandmesa.shp"]:
1515
region = icesat2.toregion(os.path.join(TESTDIR, testfile))
1616
parms = {

tests/test_h5.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212

1313
@pytest.mark.network
1414
class TestApi:
15-
def test_happy_case(self, server, asset, organization):
16-
icesat2.init(server, organization=organization)
15+
def test_happy_case(self, domain, asset, organization):
16+
icesat2.init(domain, organization=organization)
1717
epoch_offset = icesat2.h5("ancillary_data/atlas_sdp_gps_epoch", ATL03_FILE1, asset)[0]
1818
assert epoch_offset == 1198800018.0
1919

20-
def test_h5_types(self, server, asset, organization):
21-
icesat2.init(server, organization=organization)
20+
def test_h5_types(self, domain, asset, organization):
21+
icesat2.init(domain, organization=organization)
2222
heights_64 = icesat2.h5("/gt1l/land_ice_segments/h_li", ATL06_FILE1, asset)
2323
expected_64 = [45.95665, 45.999374, 46.017857, 46.015575, 46.067562, 46.099796, 46.14037, 46.105526, 46.096024, 46.12297]
2424
heights_32 = icesat2.h5("/gt1l/land_ice_segments/h_li", ATL06_FILE2, asset)
@@ -28,22 +28,22 @@ def test_h5_types(self, server, asset, organization):
2828
for c in zip(heights_64, expected_64, heights_32, expected_32, bckgrd_32nf, expected_32nf):
2929
assert (round(c[0]) == round(c[1])) and (round(c[2]) == round(c[3])) and (round(c[4]) == round(c[5]))
3030

31-
def test_variable_length(self, server, asset, organization):
32-
icesat2.init(server, organization=organization)
31+
def test_variable_length(self, domain, asset, organization):
32+
icesat2.init(domain, organization=organization)
3333
v = icesat2.h5("/gt1r/geolocation/segment_ph_cnt", ATL03_FILE1, asset)
3434
assert v[0] == 258 and v[1] == 256 and v[2] == 273
3535

36-
def test_invalid_file(self, server, asset, organization):
37-
icesat2.init(server, organization=organization)
36+
def test_invalid_file(self, domain, asset, organization):
37+
icesat2.init(domain, organization=organization)
3838
v = icesat2.h5("/gt1r/geolocation/segment_ph_cnt", INVALID_FILE, asset)
3939
assert len(v) == 0
4040

41-
def test_invalid_asset(self, server, organization):
42-
icesat2.init(server, organization=organization)
41+
def test_invalid_asset(self, domain, organization):
42+
icesat2.init(domain, organization=organization)
4343
v = icesat2.h5("/gt1r/geolocation/segment_ph_cnt", ATL03_FILE1, "invalid-asset")
4444
assert len(v) == 0
4545

46-
def test_invalid_path(self, server, asset, organization):
47-
icesat2.init(server, organization=organization)
46+
def test_invalid_path(self, domain, asset, organization):
47+
icesat2.init(domain, organization=organization)
4848
v = icesat2.h5("/gt1r/invalid-path", ATL03_FILE1, asset)
4949
assert len(v) == 0

tests/test_h5p.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
@pytest.mark.network
1010
class TestApi:
11-
def test_happy_case(self, server, asset, organization):
12-
icesat2.init(server, organization=organization)
11+
def test_happy_case(self, domain, asset, organization):
12+
icesat2.init(domain, organization=organization)
1313
datasets = [
1414
{"dataset": "/gt1l/land_ice_segments/h_li", "numrows": 5},
1515
{"dataset": "/gt1r/land_ice_segments/h_li", "numrows": 5},
@@ -28,20 +28,20 @@ def test_happy_case(self, server, asset, organization):
2828
for index in range(len(expected[dataset])):
2929
assert round(rsps[dataset][index]) == round(expected[dataset][index])
3030

31-
def test_invalid_file(self, server, asset, organization):
32-
icesat2.init(server, organization=organization)
31+
def test_invalid_file(self, domain, asset, organization):
32+
icesat2.init(domain, organization=organization)
3333
datasets = [ {"dataset": "/gt3r/land_ice_segments/h_li", "numrows": 5} ]
3434
rsps = icesat2.h5p(datasets, "invalid_file.h5", asset)
3535
assert len(rsps) == 0
3636

37-
def test_invalid_asset(self, server, organization):
38-
icesat2.init(server, organization=organization)
37+
def test_invalid_asset(self, domain, organization):
38+
icesat2.init(domain, organization=organization)
3939
datasets = [ {"dataset": "/gt3r/land_ice_segments/h_li", "numrows": 5} ]
4040
rsps = icesat2.h5p(datasets, ATL06_FILE1, "invalid-asset")
4141
assert len(rsps) == 0
4242

43-
def test_invalid_dataset(self, server, asset, organization):
44-
icesat2.init(server, organization=organization)
43+
def test_invalid_dataset(self, domain, asset, organization):
44+
icesat2.init(domain, organization=organization)
4545
datasets = [ {"dataset": "/gt3r/invalid", "numrows": 5} ]
4646
rsps = icesat2.h5p(datasets, ATL06_FILE1, asset)
4747
assert len(rsps) == 0

0 commit comments

Comments
 (0)