Skip to content

Commit

Permalink
Flexible Conda Dependencies (#1109)
Browse files Browse the repository at this point in the history
* avoid hard pinning tethys/python version in the environment.yml file so conda package will have flexible dependencies

* fix datetime syntax that was only supported in python >= 3.11

* fix import syntax that was not python=3.10 compatible

* create a new temp_environment.yml file with python and django pinned for the test setup

* fix sed syntax for macos

* linux and mac compatibility?

* update generated environment yaml file name
  • Loading branch information
sdc50 authored Oct 31, 2024
1 parent 4267324 commit e3b89c5
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 34 deletions.
18 changes: 3 additions & 15 deletions scripts/install_tethys.sh
Original file line number Diff line number Diff line change
Expand Up @@ -363,25 +363,13 @@ then
git checkout ${BRANCH}
fi

if [ -n "${DJANGO_VERSION}" ]
then
echo "Updating environment.yml Django version ${DJANGO_VERSION}..."
sudo sed -i.bak "s/django>=.*/django==${DJANGO_VERSION}/" "${TETHYS_SRC}/environment.yml"
sudo sed -i.bak "s/django>=.*/django==${DJANGO_VERSION}/" "${TETHYS_SRC}/micro_environment.yml"
fi

if [ -n "${PYTHON_VERSION}" ]
then
echo "Updating environment.yml Python version ${PYTHON_VERSION}..."
sudo sed -i.bak "s/django>=.*/python==${PYTHON_VERSION}/" "${TETHYS_SRC}/environment.yml"
sudo sed -i.bak "s/django>=.*/python==${PYTHON_VERSION}/" "${TETHYS_SRC}/micro_environment.yml"
fi

if [ -n "${CREATE_ENV}" ]
then
# create conda env and install Tethys
echo "Setting up the ${CONDA_ENV_NAME} environment..."
conda env create -n ${CONDA_ENV_NAME} -f "${TETHYS_SRC}/environment.yml"
sudo sed "s/python>=.*/python=${PYTHON_VERSION}/" "${TETHYS_SRC}/environment.yml" > "${TETHYS_SRC}/generated_environment.yml"
sudo sed -i.bak "s/django>=.*/django=${DJANGO_VERSION}/" "${TETHYS_SRC}/generated_environment.yml"
conda env create -n ${CONDA_ENV_NAME} -f "${TETHYS_SRC}/generated_environment.yml"
conda activate ${CONDA_ENV_NAME}
pip install -e ${TETHYS_SRC}
else
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest
from unittest import mock
from tethys_compute.views.dask_dashboard import dask_dashboard
from tethys_compute.views.dask_dashboard_view import dask_dashboard


class TestDaskDashBoard(unittest.TestCase):
Expand All @@ -10,8 +10,8 @@ def setUp(self):
def tearDown(self):
pass

@mock.patch("tethys_compute.views.dask_dashboard.render")
@mock.patch("tethys_compute.views.dask_dashboard.DaskScheduler")
@mock.patch("tethys_compute.views.dask_dashboard_view.render")
@mock.patch("tethys_compute.views.dask_dashboard_view.DaskScheduler")
def test_dask_status_link(self, mock_dask_scheduler, mock_render):
mock_dask_object = mock.MagicMock()
mock_dask_object.name = "test_name"
Expand All @@ -32,8 +32,8 @@ def test_dask_status_link(self, mock_dask_scheduler, mock_render):
rts_call_args[0][0][2]["status_link"],
)

@mock.patch("tethys_compute.views.dask_dashboard.render")
@mock.patch("tethys_compute.views.dask_dashboard.DaskScheduler")
@mock.patch("tethys_compute.views.dask_dashboard_view.render")
@mock.patch("tethys_compute.views.dask_dashboard_view.DaskScheduler")
def test_dask_workers_link(self, mock_dask_scheduler, mock_render):
mock_dask_object = mock.MagicMock()
mock_dask_object.name = "test_name"
Expand All @@ -54,8 +54,8 @@ def test_dask_workers_link(self, mock_dask_scheduler, mock_render):
rts_call_args[0][0][2]["workers_link"],
)

@mock.patch("tethys_compute.views.dask_dashboard.render")
@mock.patch("tethys_compute.views.dask_dashboard.DaskScheduler")
@mock.patch("tethys_compute.views.dask_dashboard_view.render")
@mock.patch("tethys_compute.views.dask_dashboard_view.DaskScheduler")
def test_dask_tasks_link(self, mock_dask_scheduler, mock_render):
mock_dask_object = mock.MagicMock()
mock_dask_object.name = "test_name"
Expand All @@ -76,8 +76,8 @@ def test_dask_tasks_link(self, mock_dask_scheduler, mock_render):
rts_call_args[0][0][2]["tasks_link"],
)

@mock.patch("tethys_compute.views.dask_dashboard.render")
@mock.patch("tethys_compute.views.dask_dashboard.DaskScheduler")
@mock.patch("tethys_compute.views.dask_dashboard_view.render")
@mock.patch("tethys_compute.views.dask_dashboard_view.DaskScheduler")
def test_dask_profile_link(self, mock_dask_scheduler, mock_render):
mock_dask_object = mock.MagicMock()
mock_dask_object.name = "test_name"
Expand All @@ -98,8 +98,8 @@ def test_dask_profile_link(self, mock_dask_scheduler, mock_render):
rts_call_args[0][0][2]["profile_link"],
)

@mock.patch("tethys_compute.views.dask_dashboard.render")
@mock.patch("tethys_compute.views.dask_dashboard.DaskScheduler")
@mock.patch("tethys_compute.views.dask_dashboard_view.render")
@mock.patch("tethys_compute.views.dask_dashboard_view.DaskScheduler")
def test_dask_graph_link(self, mock_dask_scheduler, mock_render):
mock_dask_object = mock.MagicMock()
mock_dask_object.name = "test_name"
Expand All @@ -120,8 +120,8 @@ def test_dask_graph_link(self, mock_dask_scheduler, mock_render):
rts_call_args[0][0][2]["graph_link"],
)

@mock.patch("tethys_compute.views.dask_dashboard.render")
@mock.patch("tethys_compute.views.dask_dashboard.DaskScheduler")
@mock.patch("tethys_compute.views.dask_dashboard_view.render")
@mock.patch("tethys_compute.views.dask_dashboard_view.DaskScheduler")
def test_dask_system_link(self, mock_dask_scheduler, mock_render):
mock_dask_object = mock.MagicMock()
mock_dask_object.name = "test_name"
Expand All @@ -142,8 +142,8 @@ def test_dask_system_link(self, mock_dask_scheduler, mock_render):
rts_call_args[0][0][2]["systems_link"],
)

@mock.patch("tethys_compute.views.dask_dashboard.render")
@mock.patch("tethys_compute.views.dask_dashboard.DaskScheduler")
@mock.patch("tethys_compute.views.dask_dashboard_view.render")
@mock.patch("tethys_compute.views.dask_dashboard_view.DaskScheduler")
def test_dask_groups_link(self, mock_dask_scheduler, mock_render):
mock_dask_object = mock.MagicMock()
mock_dask_object.name = "test_name"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test_tethys_global_settings_context_single_app_mode(
mock_setting.as_dict.assert_called_once()
mock_terms.get_active_terms_list.assert_called_once()
mock_terms.get_active_list.assert_not_called()
now = dt.datetime.now(dt.UTC)
now = dt.datetime.now(dt.timezone.utc)

expected_context = {
"site_defaults": {"copyright": f"Copyright © {now:%Y} Your Organization"},
Expand Down Expand Up @@ -99,7 +99,7 @@ def test_tethys_global_settings_context_single_app_mode_no_app(
mock_setting.as_dict.assert_called_once()
mock_terms.get_active_terms_list.assert_called_once()
mock_terms.get_active_list.assert_not_called()
now = dt.datetime.now(dt.UTC)
now = dt.datetime.now(dt.timezone.utc)

expected_context = {
"site_defaults": {"copyright": f"Copyright © {now:%Y} Your Organization"},
Expand Down
2 changes: 1 addition & 1 deletion tethys_compute/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"""

# flake8: noqa
from .dask_dashboard import dask_dashboard
from .dask_dashboard_view import dask_dashboard
from .update_status import (
get_job,
do_job_action,
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tethys_gizmos/gizmo_options/datatable_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class DataTableView(TethysGizmoOptions):
""" # noqa: E501

# UNSUPPORTED_EXTENSIONS = ('autoFill', 'select', 'keyTable', 'rowReorder')
# SUPPORTED_EXTENSIONS = ('buttons', 'colReorder', 'fizedColumns',
# SUPPORTED_EXTENSIONS = ('buttons', 'colReorder', 'fixedColumns',
# 'fixedHeader', 'responsive', 'scroller')
gizmo_name = "datatable_view"
version = vendor_static_dependencies["datatables"].version
Expand Down

0 comments on commit e3b89c5

Please sign in to comment.