diff --git a/Dockerfile b/Dockerfile index c1f8357..8c061ad 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,9 +5,6 @@ LABEL maintainer="dan.leehr@duke.edu" RUN apt-get update && apt-get install -y nodejs RUN mkdir -p /app -COPY . /app -RUN pip install /app -WORKDIR /app # Create a default user and home directory ENV HOME=/home/calrissian @@ -19,4 +16,16 @@ RUN useradd -u 1001 -r -g 0 -m -d ${HOME} -s /sbin/nologin \ chmod g+rwx ${HOME} USER calrissian +RUN pip install hatch +ENV PATH="${HOME}/.local/bin:${PATH}" + +COPY . /app +WORKDIR /app + +ENV VIRTUAL_ENV=/app/envs/calrissian +ENV PATH="$VIRTUAL_ENV/bin:$PATH" + +RUN hatch env prune && \ + hatch env create prod + CMD ["calrissian"] diff --git a/calrissian/__about__.py b/calrissian/__about__.py new file mode 100644 index 0000000..9ded119 --- /dev/null +++ b/calrissian/__about__.py @@ -0,0 +1 @@ +version="0.17.3" \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..e791a0a --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,90 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "calrissian" +dynamic = ["version"] +description = 'CWL runner for Kubernetes' +readme = "README.md" +requires-python = ">=3.8" +license = "MIT" +keywords = [] +authors = [ + { name = "Fabrice Brito", email = "fabrice.brito@terradue.com" }, +] +classifiers = [ + "Development Status :: 4 - Beta", + "Programming Language :: Python", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", +] +dependencies = [] + +[project.urls] +Documentation = "https://github.com/Duke-GCB/calrissian#readme" +Issues = "https://github.com/Duke-GCB/calrissian/issues" +Source = "https://github.com/Duke-GCB/calrissian" + +[tool.hatch.version] +path = "calrissian/__about__.py" + +[tool.hatch.envs.types] +extra-dependencies = [ + "mypy>=1.0.0", +] +[tool.hatch.envs.types.scripts] +check = "mypy --install-types --non-interactive {args:src/calrissian tests}" + +[tool.coverage.run] +source_pkgs = ["calrissian", "tests"] +branch = true +parallel = true +omit = [ + "calrissian/__about__.py", +] + +[tool.coverage.paths] +calrissian = ["calrissian"] +tests = ["tests"] + +[tool.coverage.report] +exclude_lines = [ + "no cov", + "if __name__ == .__main__.:", + "if TYPE_CHECKING:", +] + + +[tool.hatch.envs.default] +skip-install = false +dependencies = [ + "urllib3==1.26.18", + "kubernetes==28.1.0", + "cwltool==3.1.20231114134824", + "tenacity==8.2.3", + "importlib-metadata==6.8.0", + "msgpack==1.0.7", + "typing-extensions==4.8.0", + "freezegun==1.2.2" +] + +[tool.hatch.envs.prod] +path = "/app/envs/calrissian" + + + +[project.scripts] +calrissian = "calrissian.main:main" + +[tool.hatch.envs.test] +skip-install = false + +dependencies = [ + "nose2" +] + +[tool.hatch.envs.test.env-vars] +RETRY_ATTEMPTS="0" + diff --git a/tests/test_job.py b/tests/test_job.py index 13410a4..50f6bf9 100644 --- a/tests/test_job.py +++ b/tests/test_job.py @@ -520,7 +520,8 @@ def test_makes_tmpdir_when_not_exists(self, mock_os, mock_volume_builder, mock_c job = self.make_job() job.make_tmpdir() self.assertTrue(mock_os.path.exists.called) - self.assertTrue(mock_os.makedirs.called_with(job.tmpdir)) + #self.assertTrue(mock_os.makedirs.assert_called_with(job.tmpdir)) + mock_os.makedirs.assert_called_with(job.tmpdir) @patch('calrissian.job.os') def test_not_make_tmpdir_when_exists(self, mock_os, mock_volume_builder, mock_client): @@ -681,7 +682,8 @@ def test_execute_kubernetes_pod(self, mock_volume_builder, mock_client): job = self.make_job() k8s_pod = Mock() job.execute_kubernetes_pod(k8s_pod) - self.assertTrue(mock_client.return_value.submit_pod.called_with(k8s_pod)) + # self.assertTrue(mock_client.return_value.submit_pod.assert_called_with(k8s_pod)) + mock_client.return_value.submit_pod.assert_called_with(k8s_pod) def test_add_file_or_directory_volume_ro(self, mock_volume_builder, mock_client): mock_add_volume_binding = mock_volume_builder.return_value.add_volume_binding diff --git a/tests/test_k8s.py b/tests/test_k8s.py index 85e6971..3c2bf6b 100644 --- a/tests/test_k8s.py +++ b/tests/test_k8s.py @@ -95,7 +95,6 @@ def test_wait_calls_watch_pod_with_pod_name_field_selector(self, mock_watch, moc mock_stream = mock_watch.Watch.return_value.stream self.assertEqual(mock_stream.call_args, call(kc.core_api_instance.list_namespaced_pod, kc.namespace, field_selector='metadata.name=test123')) - @patch('calrissian.k8s.watch', autospec=True) def test_wait_calls_watch_pod_with_imcomplete_status(self, mock_watch, mock_get_namespace, mock_client): self.setup_mock_watch(mock_watch)