Skip to content

Commit

Permalink
WIP hatch
Browse files Browse the repository at this point in the history
  • Loading branch information
fabricebrito committed Aug 30, 2024
1 parent 4fd8e7d commit 19a414e
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 6 deletions.
15 changes: 12 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"]
1 change: 1 addition & 0 deletions calrissian/__about__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version="0.17.3"
90 changes: 90 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"

6 changes: 4 additions & 2 deletions tests/test_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion tests/test_k8s.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 19a414e

Please sign in to comment.