-
Notifications
You must be signed in to change notification settings - Fork 0
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
Extract unittests #19
Merged
Merged
Changes from 48 commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
1de5521
removed unecessary import
003a3ab
try to add workflow yml
b4b559d
Add GitHub Actions workflow
3886afa
linted imports
c5a21bf
linted imports
b14e398
updated actions workflow
8ebaeb4
made .toml
199da96
updated actions workflow
41095fe
updated actions workflow
054afaa
updated actions workflow
036e025
updated actions workflow
9f6ce0e
updated actions workflow
625f1c8
tweak ci.yml & setup.py
864e53e
removed logging from requirements as it is a standard lib
88e26f7
modify .yml
823a1cb
modify .yml
920d3b2
modify .yml
29fe2ee
modify .yml
db0b936
modify .yml
678a439
modify .yml
abe2cc6
fix import
5564084
fix import
15d9ea1
switched to lazy formatting for logging
caf7bcf
switched to lazy formatting for logging, changed setup.py python version
329c8ba
switched to lazy formatting for logging
8d667a1
switched to lazy formatting for logging
a6aaafe
switched to lazy formatting for logging
1671d95
aligned tests to match new logging strucutre
78a22de
update workflow name
1befa35
modified .yml so it can generate badges
a4886ea
modified .yml so it can generate badges
312c372
modified .yml so it can generate badges
74d6dea
modified .yml so it can generate badges
256440e
modified .yml so it can generate badges
fd18833
modified .yml so it can generate badges, fixed req.txt
6ff4552
modified .yml so it can generate badges
1c960ed
modified .yml to get it working again
9015d39
modified .yml to get it working again
f2089b0
modified .yml to get it working again
ea0341e
modified .yml to get it working again
2836824
modified .yml to get it working again
005e5fd
modified .yml to get correct coverage version
c0992e2
modified .yml to get correct coverage version
c51788c
modified .yml to get correct coverage version
de278d7
modified .yml to get correct coverage version
cd16d8a
roll back .yml to just run tests
d62aad4
adds a license.txt
d9d938c
Merge branch 'main' into extract_unittests
JoshuaMarden b8d64e4
try to remove logs
743a019
fix .gitignore
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,34 @@ | ||
name: CI | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
run-unittests: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
|
||
- name: Create and activate virtual environment | ||
run: | | ||
python -m venv venv # Create a virtual environment | ||
source venv/bin/activate # Activate the virtual environment | ||
|
||
- name: Install dependencies | ||
run: | | ||
source venv/bin/activate # Ensure the virtual environment is active | ||
pip install --upgrade pip # Upgrade pip within the virtual environment | ||
pip install -r requirements.txt # Install dependencies from requirements.txt | ||
|
||
- name: Set up environment | ||
run: | | ||
source venv/bin/activate # Ensure the virtual environment is active | ||
source ./add_root_to_path.sh # Run the script to modify PYTHONPATH | ||
|
||
- name: Run tests | ||
run: | | ||
source venv/bin/activate # Ensure the virtual environment is active | ||
pytest # Run tests directly with pytest |
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 |
---|---|---|
|
@@ -10,6 +10,7 @@ data/* | |
*.feather | ||
*.log | ||
|
||
|
||
# Python Module Data | ||
#(e.g __pychache__ directories) | ||
__pycache__/ | ||
|
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 J J Marden | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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
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 |
---|---|---|
|
@@ -67,7 +67,7 @@ def fetch_data(self) -> Optional[Dict[str, Any]]: | |
response.raise_for_status() | ||
return response.json() | ||
except requests.exceptions.RequestException as e: | ||
self.logger.error(f"An error occurred: {e}") | ||
self.logger.error("An error occurred: %s", e) | ||
return None | ||
|
||
|
||
|
@@ -103,7 +103,7 @@ def process_data(self, data: Dict[str, Any]) -> Optional[Tuple[pd.DataFrame, Dic | |
""" | ||
|
||
if not data or "data" not in data: | ||
logger.warning("No data found in response.") | ||
self.logger.warning("No data found in response.") | ||
return None | ||
|
||
df = pd.DataFrame(data["data"]) | ||
|
@@ -159,19 +159,14 @@ def execute(self) -> Optional[Tuple[pd.DataFrame, Dict[str, datetime]]]: | |
if result is not None: | ||
df, time_period = result | ||
|
||
self.logger.debug("DataFrame of Demand Data:") | ||
# Log the entire DataFrame as a string | ||
self.logger.debug(df.to_string()) | ||
self.logger.info("Head of the DataFrame:") | ||
self.logger.info("\n" + df.head().to_string()) | ||
self.logger.info("Time Period of Data:") | ||
self.logger.info(time_period) | ||
self.logger.debug("DataFrame of Demand Data:\n%s", df.to_string()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great reduction in Logging! |
||
self.logger.info("Head of the DataFrame:\n%s", df.head().to_string()) | ||
self.logger.info("Time Period of Data: %s", time_period) | ||
|
||
# Saving data locally | ||
self.logger.info("Saving data locally.") | ||
local_save_path = self.data_processor.save_data_locally(df) | ||
self.logger.info(f"Data successfully saved locally at { | ||
local_save_path}.") | ||
self.logger.info("Data successfully saved locally at %s.", local_save_path) | ||
|
||
# Uploading data to S3 | ||
self.logger.info("Preparing to upload data to S3.") | ||
|
@@ -180,8 +175,7 @@ def execute(self) -> Optional[Tuple[pd.DataFrame, Dict[str, datetime]]]: | |
if s3_client: | ||
self.logger.info("S3 client initialized successfully.") | ||
self.data_processor.save_data_to_s3() | ||
self.logger.info(f"Data successfully uploaded to S3 at `{ | ||
self.s3_file_name}`.") | ||
self.logger.info("Data successfully uploaded to S3 at `%s`.", self.s3_file_name) | ||
else: | ||
self.logger.error("Failed to initialize S3 client.") | ||
|
||
|
@@ -191,7 +185,7 @@ def execute(self) -> Optional[Tuple[pd.DataFrame, Dict[str, datetime]]]: | |
else: | ||
self.logger.error("Failed to retrieve data from API.") | ||
except Exception as e: | ||
self.logger.error(f"An error occurred during the execution: {e}") | ||
self.logger.error("An error occurred during the execution: %s", e) | ||
|
||
self.logger.info("Execution of the workflow completed.") | ||
return None | ||
|
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice updating all logs to use %s