-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This pull request covers the inclusion of running the swarm from local data files and addresses the challenges in running the code from an EC2 instance that cannot reach the COSMOS-UK database. * NEW: A class for looping through as .csv file with pandas * NEW: A class for looping through a SQLite database (assumes that it's been sorted first) * NEW: Updated CLI to allow new data sources to be selected. * NEW: Updated documentation
- Loading branch information
1 parent
d0dd449
commit ebb5185
Showing
22 changed files
with
1,456 additions
and
411 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,9 @@ dist/* | |
config.cfg | ||
aws-auth | ||
*.log | ||
*.certs | ||
*.certs* | ||
!.github/* | ||
docs/_* | ||
conf.sh | ||
*.sh | ||
**/*.csv | ||
**/*.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
CLI | ||
=== | ||
|
||
.. click:: iotswarm.scripts.cli:main | ||
:prog: iot-swarm | ||
:nested: full |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
iotswarm.scripts package | ||
================================== | ||
======================== | ||
|
||
Submodules | ||
---------- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
"""This script is responsible for building an SQL data file from the CSV files used | ||
by the cosmos network. | ||
The files are stored in AWS S3 and should be downloaded into this directory before continuing. | ||
They are: | ||
* LEVEL_1_NMDB_1HOUR_DATA_TABLE.csv | ||
* LEVEL_1_SOILMET_30MIN_DATA_TABLE.csv | ||
* LEVEL_1_PRECIP_1MIN_DATA_TABLE.csv | ||
* LEVEL_1_PRECIP_RAINE_1MIN_DATA_TABLE.csv | ||
Once installed, run this script to generate the .db file. | ||
""" | ||
|
||
from iotswarm.utils import build_database_from_csv | ||
from pathlib import Path | ||
from glob import glob | ||
from iotswarm.queries import CosmosTable | ||
|
||
|
||
def main( | ||
csv_dir: str | Path = Path(__file__).parent, | ||
database_output: str | Path = Path(Path(__file__).parent, "cosmos.db"), | ||
): | ||
"""Reads exported cosmos DB files from CSV format. Assumes that the files | ||
look like: LEVEL_1_SOILMET_30MIN_DATA_TABLE.csv | ||
Args: | ||
csv_dir: Directory where the csv files are stored. | ||
database_output: Output destination of the csv_data. | ||
""" | ||
csv_files = glob("*.csv", root_dir=csv_dir) | ||
|
||
tables = [CosmosTable[x.removesuffix("_DATA_TABLE.csv")] for x in csv_files] | ||
|
||
for table, file in zip(tables, csv_files): | ||
file = Path(csv_dir, file) | ||
build_database_from_csv(file, database_output, table.value, sort_by="DATE_TIME") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
import autosemver | ||
|
||
try: | ||
__version__ = autosemver.packaging.get_current_version( | ||
project_name="iot-device-simulator" | ||
) | ||
__version__ = autosemver.packaging.get_current_version(project_name="iot-swarm") | ||
except: | ||
__version__ = "unknown version" |
Oops, something went wrong.