diff --git a/.github/workflows/sdk.yml b/.github/workflows/sdk.yml index 6dee78a..4cf012e 100644 --- a/.github/workflows/sdk.yml +++ b/.github/workflows/sdk.yml @@ -17,17 +17,15 @@ jobs: uses: actions/setup-python@v3 with: python-version: "3.10" - - name: Set PYTHONPATH - run: echo "PYTHONPATH=$PWD/src/prsdk" >> $GITHUB_ENV - name: Install dependencies run: | python -m pip install --upgrade pip pip install pylint if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Lint with PyLint - run: pylint ./src/prsdk + run: pylint ./prsdk - name: Lint with Flake8 - run: flake8 ./src/prsdk + run: flake8 ./prsdk - name: Run unit tests run: python -m unittest diff --git a/src/prsdk/__init__.py b/prsdk/__init__.py similarity index 100% rename from src/prsdk/__init__.py rename to prsdk/__init__.py diff --git a/src/prsdk/data/torch_data.py b/prsdk/data/torch_data.py similarity index 100% rename from src/prsdk/data/torch_data.py rename to prsdk/data/torch_data.py diff --git a/src/prsdk/persistence/persistors/hf_persistor.py b/prsdk/persistence/persistors/hf_persistor.py similarity index 97% rename from src/prsdk/persistence/persistors/hf_persistor.py rename to prsdk/persistence/persistors/hf_persistor.py index 2ea3994..06354bf 100644 --- a/src/prsdk/persistence/persistors/hf_persistor.py +++ b/prsdk/persistence/persistors/hf_persistor.py @@ -5,7 +5,7 @@ from huggingface_hub import HfApi, snapshot_download -from persistence.persistors.persistor import Persistor +from prsdk.persistence.persistors.persistor import Persistor class HuggingFacePersistor(Persistor): diff --git a/src/prsdk/persistence/persistors/persistor.py b/prsdk/persistence/persistors/persistor.py similarity index 95% rename from src/prsdk/persistence/persistors/persistor.py rename to prsdk/persistence/persistors/persistor.py index c4eb0e8..6fd79fb 100644 --- a/src/prsdk/persistence/persistors/persistor.py +++ b/prsdk/persistence/persistors/persistor.py @@ -6,7 +6,7 @@ from abc import ABC, abstractmethod -from persistence.serializers.serializer import Serializer +from prsdk.persistence.serializers.serializer import Serializer class Persistor(ABC): diff --git a/src/prsdk/persistence/serializers/neural_network_serializer.py b/prsdk/persistence/serializers/neural_network_serializer.py similarity index 93% rename from src/prsdk/persistence/serializers/neural_network_serializer.py rename to prsdk/persistence/serializers/neural_network_serializer.py index 8ac0af9..5951734 100644 --- a/src/prsdk/persistence/serializers/neural_network_serializer.py +++ b/prsdk/persistence/serializers/neural_network_serializer.py @@ -7,9 +7,9 @@ import joblib import torch -from persistence.serializers.serializer import Serializer -from predictors.neural_network.torch_neural_net import TorchNeuralNet -from predictors.neural_network.neural_net_predictor import NeuralNetPredictor +from prsdk.persistence.serializers.serializer import Serializer +from prsdk.predictors.neural_network.torch_neural_net import TorchNeuralNet +from prsdk.predictors.neural_network.neural_net_predictor import NeuralNetPredictor class NeuralNetSerializer(Serializer): diff --git a/src/prsdk/persistence/serializers/serializer.py b/prsdk/persistence/serializers/serializer.py similarity index 100% rename from src/prsdk/persistence/serializers/serializer.py rename to prsdk/persistence/serializers/serializer.py diff --git a/src/prsdk/persistence/serializers/sklearn_serializer.py b/prsdk/persistence/serializers/sklearn_serializer.py similarity index 91% rename from src/prsdk/persistence/serializers/sklearn_serializer.py rename to prsdk/persistence/serializers/sklearn_serializer.py index 1ad01d8..5becc17 100644 --- a/src/prsdk/persistence/serializers/sklearn_serializer.py +++ b/prsdk/persistence/serializers/sklearn_serializer.py @@ -6,8 +6,8 @@ import joblib -from persistence.serializers.serializer import Serializer -from predictors.sklearn_predictors.sklearn_predictor import SKLearnPredictor +from prsdk.persistence.serializers.serializer import Serializer +from prsdk.predictors.sklearn_predictors.sklearn_predictor import SKLearnPredictor class SKLearnSerializer(Serializer): diff --git a/src/prsdk/predictors/neural_network/neural_net_predictor.py b/prsdk/predictors/neural_network/neural_net_predictor.py similarity index 97% rename from src/prsdk/predictors/neural_network/neural_net_predictor.py rename to prsdk/predictors/neural_network/neural_net_predictor.py index 159336f..dcb6796 100644 --- a/src/prsdk/predictors/neural_network/neural_net_predictor.py +++ b/prsdk/predictors/neural_network/neural_net_predictor.py @@ -14,9 +14,9 @@ from torch.utils.data import DataLoader from torch.utils.tensorboard import SummaryWriter -from data.torch_data import TorchDataset -from predictors.predictor import Predictor -from predictors.neural_network.torch_neural_net import TorchNeuralNet +from prsdk.data.torch_data import TorchDataset +from prsdk.predictors.predictor import Predictor +from prsdk.predictors.neural_network.torch_neural_net import TorchNeuralNet # pylint: disable=too-many-instance-attributes @@ -189,7 +189,7 @@ def predict(self, context_actions_df: pd.DataFrame) -> pd.DataFrame: :return: DataFrame of predictions properly labeled and indexed. """ X_test_scaled = self.scaler.transform(context_actions_df[self.features]) - test_ds = TorchDataset(X_test_scaled, np.zeros(len(X_test_scaled))) + test_ds = TorchDataset(X_test_scaled, np.zeros(len(X_test_scaled)), device=self.device) test_dl = DataLoader(test_ds, self.batch_size, shuffle=False) pred_list = [] with torch.no_grad(): diff --git a/src/prsdk/predictors/neural_network/torch_neural_net.py b/prsdk/predictors/neural_network/torch_neural_net.py similarity index 100% rename from src/prsdk/predictors/neural_network/torch_neural_net.py rename to prsdk/predictors/neural_network/torch_neural_net.py diff --git a/src/prsdk/predictors/predictor.py b/prsdk/predictors/predictor.py similarity index 100% rename from src/prsdk/predictors/predictor.py rename to prsdk/predictors/predictor.py diff --git a/src/prsdk/predictors/sklearn_predictors/linear_regression_predictor.py b/prsdk/predictors/sklearn_predictors/linear_regression_predictor.py similarity index 90% rename from src/prsdk/predictors/sklearn_predictors/linear_regression_predictor.py rename to prsdk/predictors/sklearn_predictors/linear_regression_predictor.py index 7ae1e8b..a15869b 100644 --- a/src/prsdk/predictors/sklearn_predictors/linear_regression_predictor.py +++ b/prsdk/predictors/sklearn_predictors/linear_regression_predictor.py @@ -3,7 +3,7 @@ """ from sklearn.linear_model import LinearRegression -from predictors.sklearn_predictors.sklearn_predictor import SKLearnPredictor +from prsdk.predictors.sklearn_predictors.sklearn_predictor import SKLearnPredictor class LinearRegressionPredictor(SKLearnPredictor): diff --git a/src/prsdk/predictors/sklearn_predictors/random_forest_predictor.py b/prsdk/predictors/sklearn_predictors/random_forest_predictor.py similarity index 89% rename from src/prsdk/predictors/sklearn_predictors/random_forest_predictor.py rename to prsdk/predictors/sklearn_predictors/random_forest_predictor.py index 6ffdb2a..84de3ba 100644 --- a/src/prsdk/predictors/sklearn_predictors/random_forest_predictor.py +++ b/prsdk/predictors/sklearn_predictors/random_forest_predictor.py @@ -3,7 +3,7 @@ """ from sklearn.ensemble import RandomForestRegressor -from predictors.sklearn_predictors.sklearn_predictor import SKLearnPredictor +from prsdk.predictors.sklearn_predictors.sklearn_predictor import SKLearnPredictor class RandomForestPredictor(SKLearnPredictor): diff --git a/src/prsdk/predictors/sklearn_predictors/sklearn_predictor.py b/prsdk/predictors/sklearn_predictors/sklearn_predictor.py similarity index 97% rename from src/prsdk/predictors/sklearn_predictors/sklearn_predictor.py rename to prsdk/predictors/sklearn_predictors/sklearn_predictor.py index 142252e..fae031a 100644 --- a/src/prsdk/predictors/sklearn_predictors/sklearn_predictor.py +++ b/prsdk/predictors/sklearn_predictors/sklearn_predictor.py @@ -6,7 +6,7 @@ import pandas as pd -from predictors.predictor import Predictor +from prsdk.predictors.predictor import Predictor class SKLearnPredictor(Predictor, ABC): diff --git a/src/prsdk/prescriptors/prescriptor.py b/prsdk/prescriptors/prescriptor.py similarity index 100% rename from src/prsdk/prescriptors/prescriptor.py rename to prsdk/prescriptors/prescriptor.py diff --git a/tests/persistence/test_hf_persistence.py b/tests/persistence/test_hf_persistence.py index 9d700b5..fcaeb1b 100644 --- a/tests/persistence/test_hf_persistence.py +++ b/tests/persistence/test_hf_persistence.py @@ -8,9 +8,9 @@ import numpy as np import pandas as pd -from persistence.persistors.hf_persistor import HuggingFacePersistor -from persistence.serializers.neural_network_serializer import NeuralNetSerializer -from predictors.neural_network.neural_net_predictor import NeuralNetPredictor +from prsdk.persistence.persistors.hf_persistor import HuggingFacePersistor +from prsdk.persistence.serializers.neural_network_serializer import NeuralNetSerializer +from prsdk.predictors.neural_network.neural_net_predictor import NeuralNetPredictor class TestHuggingFacePersistence(unittest.TestCase): diff --git a/tests/persistence/test_predictor_serialization.py b/tests/persistence/test_predictor_serialization.py index 0cd4513..76270c9 100644 --- a/tests/persistence/test_predictor_serialization.py +++ b/tests/persistence/test_predictor_serialization.py @@ -7,11 +7,11 @@ import pandas as pd -from persistence.serializers.neural_network_serializer import NeuralNetSerializer -from persistence.serializers.sklearn_serializer import SKLearnSerializer -from predictors.neural_network.neural_net_predictor import NeuralNetPredictor -from predictors.sklearn_predictors.linear_regression_predictor import LinearRegressionPredictor -from predictors.sklearn_predictors.random_forest_predictor import RandomForestPredictor +from prsdk.persistence.serializers.neural_network_serializer import NeuralNetSerializer +from prsdk.persistence.serializers.sklearn_serializer import SKLearnSerializer +from prsdk.predictors.neural_network.neural_net_predictor import NeuralNetPredictor +from prsdk.predictors.sklearn_predictors.linear_regression_predictor import LinearRegressionPredictor +from prsdk.predictors.sklearn_predictors.random_forest_predictor import RandomForestPredictor class TestPredictorSerialization(unittest.TestCase): diff --git a/tests/predictors/test_neural_net.py b/tests/predictors/test_neural_net.py index ead24d3..e3df1ad 100644 --- a/tests/predictors/test_neural_net.py +++ b/tests/predictors/test_neural_net.py @@ -5,7 +5,7 @@ import pandas as pd -from predictors.neural_network.neural_net_predictor import NeuralNetPredictor +from prsdk.predictors.neural_network.neural_net_predictor import NeuralNetPredictor class TestNeuralNet(unittest.TestCase): diff --git a/tests/test_dummy.py b/tests/test_dummy.py deleted file mode 100644 index 4b8c8c5..0000000 --- a/tests/test_dummy.py +++ /dev/null @@ -1,17 +0,0 @@ -""" -Dummy test to test Github actions. -""" -import unittest - - -class TestDummy(unittest.TestCase): - """ - A fake test that always returns true. - """ - def test_dummy(self): - """ - A test that always returns true. - """ - # pylint: disable=redundant-unittest-assert - self.assertTrue(True) - # pylint: enable=redundant-unittest-assert