-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c51697e
commit cdf8fc2
Showing
10 changed files
with
72 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
[![Pytest](https://github.com/Thomas-George-T/Ecommerce-Data-MLOps/actions/workflows/pytest.yml/badge.svg)](https://github.com/Thomas-George-T/Ecommerce-Data-MLOps/actions/workflows/pytest.yml) | ||
|
||
|
||
# MLOps-Ecomm | ||
Work in Progress |
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 |
---|---|---|
|
@@ -3,4 +3,6 @@ numpy | |
pandas | ||
pytest | ||
ipykernel | ||
mlflow | ||
mlflow | ||
requests | ||
zipfile |
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 @@ | ||
import requests | ||
import zipfile | ||
|
||
def ingest_data(): | ||
|
||
file_url = "https://archive.ics.uci.edu/static/public/352/online+retail.zip" | ||
|
||
# Send an HTTP GET request to the URL | ||
response = requests.get(file_url) | ||
|
||
# Check if the request was successful (status code 200) | ||
if response.status_code == 200: | ||
# Save file to data | ||
with open("data/data.zip", "wb") as file: | ||
file.write(response.content) | ||
print("File downloaded successfully.") | ||
else: | ||
print(f"Failed to download the file. Status code: {response.status_code}") | ||
|
||
|
||
def unzip_file(): | ||
zip_filename ='data/data.zip' | ||
extract_to = 'data/' | ||
try: | ||
with zipfile.ZipFile(zip_filename, 'r') as zip_ref: | ||
zip_ref.extractall(extract_to) | ||
print(f"File {zip_filename} successfully unzipped to {extract_to}") | ||
except Exception as e: | ||
print(f"Failed to unzip {zip_filename}: {e}") | ||
|
||
|
||
if __name__ == "__main__": | ||
ingest_data() | ||
unzip_file() |
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,32 @@ | ||
import requests | ||
import pytest | ||
from src import datapipeline | ||
|
||
def test_ingest_data(mocker): | ||
# arrange: | ||
# mocked dependencies | ||
mock_print = mocker.MagicMock(name='print') | ||
mocker.patch('src.datapipeline.print', new=mock_print) | ||
|
||
# act: invoking the tested code | ||
datapipeline.ingest_data() | ||
|
||
# assert: | ||
assert 1 == mock_print.call_count | ||
|
||
|
||
def test_unzip_file(mocker): | ||
# arrange: | ||
# mocked dependencies | ||
mock_ZipFile = mocker.MagicMock(name='ZipFile') | ||
mocker.patch('src.datapipeline.zipfile.ZipFile', new=mock_ZipFile) | ||
mock_print = mocker.MagicMock(name='print') | ||
mocker.patch('src.datapipeline.print', new=mock_print) | ||
mock_Exception = mocker.MagicMock(name='Exception') | ||
mocker.patch('src.datapipeline.Exception', new=mock_Exception) | ||
|
||
# act: invoking the tested code | ||
datapipeline.unzip_file() | ||
|
||
# assert: | ||
mock_Exception.assert_not_called() |