Skip to content

Commit

Permalink
refactor: use virtual env in server runtime
Browse files Browse the repository at this point in the history
- include in .env PATH and make docker-compose.yml target depend on .env
- replace deprecated usage of self.assertEquals
https://docs.python.org/3/whatsnew/3.12.html#id3
  • Loading branch information
alee committed Jan 11, 2025
1 parent 76e5077 commit 2fe956a
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 17 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ release-version: .env
$(ENVREPLACE) TEST_BASIC_AUTH_PASSWORD $$(openssl rand -base64 42) .env

.PHONY: docker-compose.yml
docker-compose.yml: base.yml dev.yml staging.yml prod.yml config.mk $(PGPASS_PATH) release-version
docker-compose.yml: base.yml dev.yml staging.yml prod.yml config.mk $(PGPASS_PATH) release-version .env
case "$(DEPLOY_ENVIRONMENT)" in \
dev|staging) docker compose -f base.yml -f $(DEPLOY_ENVIRONMENT).yml config > docker-compose.yml;; \
prod) docker compose -f base.yml -f staging.yml -f $(DEPLOY_ENVIRONMENT).yml config > docker-compose.yml;; \
Expand All @@ -100,7 +100,7 @@ secrets: $(SECRETS_DIR) $(GENERATED_SECRETS)
done

.PHONY: deploy
deploy: build .env
deploy: build
docker compose pull db redis elasticsearch
ifneq ($(DEPLOY_ENVIRONMENT),dev)
docker compose pull nginx
Expand Down
5 changes: 3 additions & 2 deletions deploy/conf/.env.template
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Docker build
# UBUNTU_MIRROR=mirror.arizona.edu
VIRTUAL_ENV=/home/comses/virtualenvs/comses.venv
UBUNTU_MIRROR=archive.ubuntu.com
# set PATH defaults for cron execution
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PATH="${VIRTUAL_ENV}/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

# app settings
RELEASE_VERSION=
Expand All @@ -21,7 +22,7 @@ DISCOURSE_BASE_URL=
DISCOURSE_API_USERNAME=

# elastic search
ES_VERSION=7.17.22
ES_VERSION=7.17.26

# email
EMAIL_SUBJECT_PREFIX="[CoMSES Net]"
Expand Down
2 changes: 1 addition & 1 deletion django/core/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def test_mark_spam(self):
)
event.refresh_from_db()
# non-moderators cannot mark content as spam
self.assertEquals(response.status_code, 403)
self.assertEqual(response.status_code, 403)
self.assertFalse(event.is_marked_spam)
# check moderator
self.client.login(
Expand Down
6 changes: 3 additions & 3 deletions django/home/tests/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,18 @@ def test_convert_timeseries(self):
)
for chart_data in highcharts_timeseries:
# 2012 and 2013 should also be 0
self.assertEquals(
self.assertEqual(
tuple(chart_data["data"][0:2]),
(0, 0),
"2012-13 should be zeroed out",
)
# missing year 2016
self.assertEquals(
self.assertEqual(
chart_data["data"][4],
0,
f"5th entry (2016) should be 0 {chart_data['name']}",
)
self.assertTrue(
chart_data["name"] in OS_NAMES, f"Invalid OS name {chart_data['name']}"
)
self.assertEquals(len(chart_data["data"]), 7, "Should be 7 years of data")
self.assertEqual(len(chart_data["data"]), 7, "Should be 7 years of data")
2 changes: 1 addition & 1 deletion django/library/tests/test_datacite_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def test_mint_new_doi_for_release(self):
self.assertTrue(self.api.is_datacite_available())
release = self.codebase.releases.first()
log, ok = self.api.mint_public_doi(release)
self.assertEquals(log.http_status, 200, "should have successfully minted a DOI")
self.assertEqual(log.http_status, 200, "should have successfully minted a DOI")
self.assertTrue(self.api.doi_matches_pattern(doi))
def test_update_metadata_for_release(self):
Expand Down
8 changes: 4 additions & 4 deletions django/library/tests/test_fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def test_zipfile_saving(self):
fs_api=fs_api,
)
logs, level = msgs.serialize()
self.assertEquals(level, MessageLevels.warning)
self.assertEquals(len(logs), 2)
self.assertEqual(level, MessageLevels.warning)
self.assertEqual(len(logs), 2)
self.assertEqual(
set(
fs_api.list(StagingDirectories.originals, FileCategoryDirectories.code)
Expand Down Expand Up @@ -77,8 +77,8 @@ def test_invalid_zipfile_saving(self):
FileCategoryDirectories.code, content=f, name="invalid.zip"
)
logs, level = msgs.serialize()
self.assertEquals(level, MessageLevels.error)
self.assertEquals(len(logs), 1)
self.assertEqual(level, MessageLevels.error)
self.assertEqual(len(logs), 1)

@classmethod
def tearDownClass(cls):
Expand Down
8 changes: 4 additions & 4 deletions django/library/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ def setUp(self):
)

def test_base_dir(self):
self.assertEquals(
self.assertEqual(
self.c1.base_library_dir,
pathlib.Path(settings.LIBRARY_ROOT, str(self.c1.uuid)),
)
self.assertEquals(
self.assertEqual(
self.c1.base_git_dir,
pathlib.Path(settings.REPOSITORY_ROOT, str(self.c1.uuid)),
)
Expand All @@ -43,8 +43,8 @@ def test_create_release(self):
release = ReleaseSetup.setUpPublishableDraftRelease(self.c1)
release.validate_publishable()
release.publish()
self.assertEquals(self.c1.latest_version, release)
self.assertEquals(
self.assertEqual(self.c1.latest_version, release)
self.assertEqual(
CodebaseRelease.objects.get(
codebase=self.c1, version_number=release.version_number
),
Expand Down
1 change: 1 addition & 0 deletions django/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ elasticsearch>=7.0.0,<8.0.0
html2text>=2016.9.19
jinja2==3.1.4
jsonschema==4.23.0
jwt==1.3.1 # needed for allauth

This comment has been minimized.

Copy link
@sgfost

sgfost Jan 22, 2025

Contributor

I think this is the wrong jwt

https://docs.allauth.org/en/dev/installation/requirements.html

do you remember what prompted adding this in explicitly @alee?

This comment has been minimized.

Copy link
@alee

alee Jan 23, 2025

Author Member

hmm, I think it was a failing build - let's try removing as it should get pulled automatically from allauth? In the IOI research software report webinar right now, I can take a look at it afterwards

This comment has been minimized.

Copy link
@sgfost

sgfost Jan 23, 2025

Contributor

oh right, allauth doesn't include it as a core dependency. I was testing in #791 with pygithub which does. I'll swap it out for pyjwt and make sure it works

markdown==3.7
nltk>=3.8.1,<4.0.0
numpy==1.26.4
Expand Down

0 comments on commit 2fe956a

Please sign in to comment.