Skip to content

Commit 32cf74b

Browse files
committed
Reorg Util Module to .db and .net modules
1 parent 3d4b32e commit 32cf74b

18 files changed

Lines changed: 1807 additions & 1779 deletions

docs/api.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,17 @@ API Reference
2424
:no-inheritance-diagram:
2525
.. automodapi:: swxsoc.util.util
2626
:no-inheritance-diagram:
27+
.. automodapi:: swxsoc.util.grafana
28+
:no-inheritance-diagram:
2729
.. automodapi:: swxsoc.util.validation
2830
:no-inheritance-diagram:
31+
.. automodapi:: swxsoc.net
32+
:no-inheritance-diagram:
33+
.. automodapi:: swxsoc.net.attr
34+
:no-inheritance-diagram:
35+
.. automodapi:: swxsoc.net.client
36+
:no-inheritance-diagram:
37+
.. automodapi:: swxsoc.db
38+
:no-inheritance-diagram:
39+
.. automodapi:: swxsoc.db.timeseries
40+
:no-inheritance-diagram:

docs/user-guide/reading_writing_data.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ Your variable metadata can be found by querying the measurement column directly.
327327
... )
328328
>>> example_sw_data.timeseries['Bx'].meta # doctest: +SKIP
329329

330-
For multiple epoch variables, you have to addess measurements through the `.timeseries` dictionary, keyed by the epoch name:
330+
For multiple epoch variables, you have to addess measurements through the ``.timeseries`` dictionary, keyed by the epoch name:
331331

332332
>>> sw_data.timeseries['Epoch']['diff_e_flux'].meta.update(
333333
... {"CATDESC": "Differential Electron Flux measured by HERMES"}

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ write_to = "swxsoc/_version.py"
8484
testpaths = [
8585
"swxsoc/tests",
8686
"swxsoc/util/tests",
87+
"swxsoc/net/tests",
88+
"swxsoc/db/tests",
8789
"docs"
8890
]
8991
doctest_plus = "enabled"

swxsoc/db/__init__.py

Whitespace-only changes.

swxsoc/db/tests/__init__.py

Whitespace-only changes.
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Tests util.py that interact with timestream"""
1+
"""Tests for swxsoc.db.timeseries (Timestream recording functions)"""
22

33
import os
44

@@ -11,7 +11,7 @@
1111
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
1212
from moto.timestreamwrite.models import timestreamwrite_backends
1313

14-
from swxsoc.util import util
14+
from swxsoc.db import timeseries
1515

1616

1717
def get_test_db_names():
@@ -77,7 +77,7 @@ def test_record_timeseries_quantity_1col(mocked_timestream):
7777
meta={"name": timeseries_name},
7878
)
7979
ts["temp4"] = [1.0, 4.0, 5.0, 6.0, 4.0] * u.deg_C
80-
util.record_timeseries(ts, instrument_name="test")
80+
timeseries.record_timeseries(ts, instrument_name="test")
8181

8282
database_name, table_name = get_test_db_names()
8383
backend = timestreamwrite_backends[ACCOUNT_ID]["us-east-1"]
@@ -115,7 +115,7 @@ def test_record_timeseries_quantity_1col_array(mocked_timestream):
115115
meta={"name": timeseries_name},
116116
)
117117
ts["temp4_arr"] = np.arange(6 * 5).reshape((5, 6))
118-
util.record_timeseries(ts, instrument_name="test")
118+
timeseries.record_timeseries(ts, instrument_name="test")
119119

120120
database_name, table_name = get_test_db_names()
121121
backend = timestreamwrite_backends[ACCOUNT_ID]["us-east-1"]
@@ -157,7 +157,7 @@ def test_record_timeseries_quantity_multicol(mocked_timestream):
157157
ts["temp4"] = [1.0, 4.0, 5.0, 6.0, 4.0] * u.deg_C
158158
ts["rail5v"] = [5.1, 5.2, 4.9, 4.8, 5.0] * u.volt
159159
ts["status"] = [0, 1, 1, 1, 2]
160-
util.record_timeseries(ts, ts_name=timeseries_name, instrument_name="test")
160+
timeseries.record_timeseries(ts, ts_name=timeseries_name, instrument_name="test")
161161

162162
database_name, table_name = get_test_db_names()
163163
backend = timestreamwrite_backends[ACCOUNT_ID]["us-east-1"]
@@ -224,7 +224,7 @@ def test_record_timeseries_with_nan_values(mocked_timestream):
224224
ts["temp4"] = [1.0, np.nan, 5.0, np.nan, 4.0] * u.deg_C
225225
ts["rail5v"] = [5.1, 5.2, np.nan, 4.8, 5.0] * u.volt
226226

227-
util.record_timeseries(ts, instrument_name="test")
227+
timeseries.record_timeseries(ts, instrument_name="test")
228228

229229
database_name, table_name = get_test_db_names()
230230
backend = timestreamwrite_backends[ACCOUNT_ID]["us-east-1"]
@@ -299,7 +299,7 @@ def test_record_timeseries_with_nan_in_arrays(mocked_timestream):
299299
[[1.0, 2.0, np.nan, 4.0], [5.0, np.nan, 7.0, 8.0], [9.0, 10.0, 11.0, np.nan]]
300300
)
301301

302-
util.record_timeseries(ts, instrument_name="test")
302+
timeseries.record_timeseries(ts, instrument_name="test")
303303

304304
database_name, table_name = get_test_db_names()
305305
backend = timestreamwrite_backends[ACCOUNT_ID]["us-east-1"]
@@ -338,7 +338,7 @@ def test_record_timeseries_with_boolean_values(mocked_timestream):
338338
ts["heater_on"] = [True, False, True, True, False]
339339
ts["safety_flag"] = [False, False, True, False, False]
340340

341-
util.record_timeseries(ts, instrument_name="test")
341+
timeseries.record_timeseries(ts, instrument_name="test")
342342

343343
database_name, table_name = get_test_db_names()
344344
backend = timestreamwrite_backends[ACCOUNT_ID]["us-east-1"]
@@ -389,7 +389,7 @@ def test_record_timeseries_with_numpy_boolean(mocked_timestream):
389389
# Use numpy bool_ type
390390
ts["flag"] = np.array([True, False, True], dtype=np.bool_)
391391

392-
util.record_timeseries(ts, instrument_name="test")
392+
timeseries.record_timeseries(ts, instrument_name="test")
393393

394394
database_name, table_name = get_test_db_names()
395395
backend = timestreamwrite_backends[ACCOUNT_ID]["us-east-1"]
@@ -422,7 +422,7 @@ def test_record_timeseries_with_mixed_types(mocked_timestream):
422422
ts["mode"] = ["nominal", "safe", "nominal"]
423423
ts["count"] = [10, 20, 30]
424424

425-
util.record_timeseries(ts, instrument_name="test")
425+
timeseries.record_timeseries(ts, instrument_name="test")
426426

427427
database_name, table_name = get_test_db_names()
428428
backend = timestreamwrite_backends[ACCOUNT_ID]["us-east-1"]
@@ -466,7 +466,7 @@ def test_record_timeseries_all_nan_column(mocked_timestream):
466466
ts["temp"] = [1.0, 2.0, 3.0] * u.deg_C
467467
ts["bad_sensor"] = [np.nan, np.nan, np.nan] * u.volt
468468

469-
util.record_timeseries(ts, instrument_name="test")
469+
timeseries.record_timeseries(ts, instrument_name="test")
470470

471471
database_name, table_name = get_test_db_names()
472472
backend = timestreamwrite_backends[ACCOUNT_ID]["us-east-1"]
@@ -498,7 +498,7 @@ def test_record_dimension_timestream(mocked_timestream):
498498
measure_value = 25.2
499499
measure_value_type = "DOUBLE"
500500

501-
util._record_dimension_timestream(
501+
timeseries._record_dimension_timestream(
502502
dimensions=dimensions,
503503
instrument_name=instrument_name,
504504
measure_name=measure_name,
@@ -520,7 +520,7 @@ def test_invalid_record_dimension_timestream(mocked_timestream):
520520
{"Name": "Unit", "Value": "Celsius"},
521521
]
522522

523-
util._record_dimension_timestream(
523+
timeseries._record_dimension_timestream(
524524
dimensions=dimensions,
525525
)
526526

@@ -536,7 +536,7 @@ def test_invalid_record_dimension_timestream(mocked_timestream):
536536
def test_invalid_instrument_record_dimension_timestream(mocked_timestream):
537537
dimensions = "invalid"
538538

539-
util._record_dimension_timestream(dimensions=dimensions)
539+
timeseries._record_dimension_timestream(dimensions=dimensions)
540540

541541
database_name, table_name = get_test_db_names()
542542
backend = timestreamwrite_backends[ACCOUNT_ID]["us-east-1"]

0 commit comments

Comments
 (0)