diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index e118955b1f..af696cc22a 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -78,6 +78,7 @@ jobs: - name: List installed packages run: pip list - name: Run unit test + working-directory: ./submarine-sdk/pysubmarine run: pytest -m "not e2e" integration: diff --git a/submarine-sdk/pysubmarine/tests/ml/pytorch/model/conftest.py b/submarine-sdk/pysubmarine/tests/ml/pytorch/model/conftest.py index a425a03c67..4403a06193 100644 --- a/submarine-sdk/pysubmarine/tests/ml/pytorch/model/conftest.py +++ b/submarine-sdk/pysubmarine/tests/ml/pytorch/model/conftest.py @@ -13,8 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os - import pytest # noqa @@ -32,22 +30,22 @@ @pytest.fixture -def get_model_param(tmpdir): - data_file = os.path.join(str(tmpdir), "libsvm.txt") - save_model_dir = os.path.join(str(tmpdir), "experiment") - os.mkdir(save_model_dir) +def get_model_param(tmp_path): + data_file = tmp_path / "libsvm.txt" + save_model_dir = tmp_path / "experiment" + save_model_dir.mkdir() - with open(data_file, "wt") as writer: + with data_file.open("wt") as writer: writer.write(LIBSVM_DATA) params = { "input": { - "train_data": data_file, - "valid_data": data_file, - "test_data": data_file, + "train_data": str(data_file), + "valid_data": str(data_file), + "test_data": str(data_file), "type": "libsvm", }, - "output": {"save_model_dir": save_model_dir, "metric": "roc_auc"}, + "output": {"save_model_dir": str(save_model_dir), "metric": "roc_auc"}, "training": { "batch_size": 4, "num_epochs": 1, @@ -77,4 +75,4 @@ def get_model_param(tmpdir): } yield params - os.remove(data_file) + data_file.unlink() diff --git a/submarine-sdk/pysubmarine/tests/ml/tensorflow/model/conftest.py b/submarine-sdk/pysubmarine/tests/ml/tensorflow/model/conftest.py index 132bdeaee4..027e832567 100644 --- a/submarine-sdk/pysubmarine/tests/ml/tensorflow/model/conftest.py +++ b/submarine-sdk/pysubmarine/tests/ml/tensorflow/model/conftest.py @@ -13,8 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os - import pytest LIBSVM_DATA = """1 1:0 2:0.051495 3:0.5 4:0.1 5:0.113437 6:0.874 7:0.01 8:0.08 9:0.028 10:0 @@ -29,22 +27,22 @@ @pytest.fixture -def get_model_param(tmpdir): - data_file = os.path.join(str(tmpdir), "libsvm.txt") - save_model_dir = os.path.join(str(tmpdir), "experiment") - with open(data_file, "wt") as writer: +def get_model_param(tmp_path): + data_file = tmp_path / "libsvm.txt" + save_model_dir = tmp_path / "experiment" + with data_file.open("wt") as writer: writer.write(LIBSVM_DATA) params = { "input": { - "train_data": data_file, - "valid_data": data_file, - "test_data": data_file, + "train_data": str(data_file), + "valid_data": str(data_file), + "test_data": str(data_file), "type": "libsvm", }, - "output": {"save_model_dir": save_model_dir, "metric": "auc"}, + "output": {"save_model_dir": str(save_model_dir), "metric": "auc"}, "training": {"batch_size": 256, "num_epochs": 1, "field_size": 10, "feature_size": 1000}, } yield params - os.remove(data_file) + data_file.unlink() diff --git a/submarine-sdk/pysubmarine/tests/ml/tensorflow_v2/model/conftest.py b/submarine-sdk/pysubmarine/tests/ml/tensorflow_v2/model/conftest.py index 132bdeaee4..027e832567 100644 --- a/submarine-sdk/pysubmarine/tests/ml/tensorflow_v2/model/conftest.py +++ b/submarine-sdk/pysubmarine/tests/ml/tensorflow_v2/model/conftest.py @@ -13,8 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os - import pytest LIBSVM_DATA = """1 1:0 2:0.051495 3:0.5 4:0.1 5:0.113437 6:0.874 7:0.01 8:0.08 9:0.028 10:0 @@ -29,22 +27,22 @@ @pytest.fixture -def get_model_param(tmpdir): - data_file = os.path.join(str(tmpdir), "libsvm.txt") - save_model_dir = os.path.join(str(tmpdir), "experiment") - with open(data_file, "wt") as writer: +def get_model_param(tmp_path): + data_file = tmp_path / "libsvm.txt" + save_model_dir = tmp_path / "experiment" + with data_file.open("wt") as writer: writer.write(LIBSVM_DATA) params = { "input": { - "train_data": data_file, - "valid_data": data_file, - "test_data": data_file, + "train_data": str(data_file), + "valid_data": str(data_file), + "test_data": str(data_file), "type": "libsvm", }, - "output": {"save_model_dir": save_model_dir, "metric": "auc"}, + "output": {"save_model_dir": str(save_model_dir), "metric": "auc"}, "training": {"batch_size": 256, "num_epochs": 1, "field_size": 10, "feature_size": 1000}, } yield params - os.remove(data_file) + data_file.unlink()