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

FW-527: AWS upload #13

Merged
merged 28 commits into from
Jan 24, 2025
Merged

FW-527: AWS upload #13

merged 28 commits into from
Jan 24, 2025

Conversation

lewis-chambers
Copy link
Collaborator

Makes the changes needed to track the latest data sent to AWS and send only new data.

Changes

  • Implemented file upload step
    • When run it checks the state file for the last data sent, falling back to 3 hours ago if not in the state file yet. Then it retrieves all data rows after the given time and converts them into CR1000X datalogger style payloads. The payloads are then dropped into the requested s3 bucket and prefix. On successful writes, if the written data timestamp is newer than in the state file, the file is updated (they may be written out of order).
  • Wrote unit tests
  • Wrote end to end tests
  • Implemented a simple CLI for running the code
  • Added logging
  • Added localstack

@richjam
Copy link

richjam commented Jan 24, 2025

test_db, test_messaging, and test_devices are being skipped because it requires config.cfg to exist. Is this still valid, given the docs tell user to create the config file as oracle.cfg?

@lewis-chambers
Copy link
Collaborator Author

lewis-chambers commented Jan 24, 2025

test_db, test_messaging, and test_devices are being skipped because it requires config.cfg to exist. Is this still valid, given the docs tell user to create the config file as oracle.cfg?

The config file was used to link into the Cosmos database for testing and comes from a time when I didn't know I could mimick the connections through mocking. It shouldn't impact the live-cosmos sub-app. They get skipped because the CI wouldn't be able to connect to the database anyway. I'm not keen to patch it because the cosmos swarm will be abandoned soon.

@richjam
Copy link

richjam commented Jan 24, 2025

In liveupload.py, add fallback time to logger message on line 84

logger.debug(f"site {site} not in state. Using fallback time {self._fallback_time}.")

@richjam
Copy link

richjam commented Jan 24, 2025

In liveupload.py, add fallback time to logger message on line 84

logger.debug(f"site {site} not in state. Using fallback time {self._fallback_time}.")

Should/could the fallback time be a command line arg, for testing purposes (and if we wanted to send a bigger chunk of data?) Or the timedelta hours?

src/iotswarm/livecosmos/liveupload.py Outdated Show resolved Hide resolved
src/iotswarm/livecosmos/liveupload.py Outdated Show resolved Hide resolved
src/iotswarm/livecosmos/liveupload.py Outdated Show resolved Hide resolved
src/iotswarm/livecosmos/scripts/cli.py Outdated Show resolved Hide resolved
src/iotswarm/livecosmos/scripts/cli.py Outdated Show resolved Hide resolved
Args:
config_src: A path to the config.cfg file used.
table: A list of tables to upload from.
site: A list of sites to upload from. Grabs sites from the Oracle database if
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
site: A list of sites to upload from. Grabs sites from the Oracle database if
sites: A list of sites to upload from. Grabs sites from the Oracle database if

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is supposed to be site so that you add sites in the CLI like --site SITE1 --site SITE2. It felt odd to have them be plural each time

tests/livecosmos/end_to_end/test_livecosmos.py Outdated Show resolved Hide resolved
tests/livecosmos/test_utils.py Outdated Show resolved Hide resolved
README.MD Outdated Show resolved Hide resolved
src/iotswarm/livecosmos/scripts/cli.py Outdated Show resolved Hide resolved
@lewis-chambers
Copy link
Collaborator Author

In liveupload.py, add fallback time to logger message on line 84
logger.debug(f"site {site} not in state. Using fallback time {self._fallback_time}.")

Should/could the fallback time be a command line arg, for testing purposes (and if we wanted to send a bigger chunk of data?) Or the timedelta hours?

This has been added as an argument now

@lewis-chambers lewis-chambers merged commit ba3a0a1 into main Jan 24, 2025
1 check passed
@lewis-chambers lewis-chambers deleted the feature/FW-527-aws-upload branch January 29, 2025 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants