From a94e54eb009f610fdbe5c64ac14705cbe2081b48 Mon Sep 17 00:00:00 2001 From: Konstantin Schulz <schulzkx@hu-berlin.de> Date: Thu, 21 Sep 2023 19:28:10 +0200 Subject: [PATCH] adapt setup to Docker Compose v2 --- README.md | 6 +++--- coverage_local.sh | 6 +++--- deploy.sh | 6 +++--- mc_backend/README.md | 5 +++-- mc_backend/mcserver/app/services/customCorpusService.py | 4 ++-- mc_backend/tests.py | 8 +++++++- 6 files changed, 21 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index d041ca0..6bb3398 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ### Docker 1. Install Docker (https://docs.docker.com/v17.12/install/) and - Docker-Compose (https://docs.docker.com/compose/install/). + Docker Compose (https://docs.docker.com/compose/install/). 2. Clone the repository: `git clone https://scm.cms.hu-berlin.de/callidus/machina-callida.git`. 3. Move to the newly created folder: @@ -27,7 +27,7 @@ For installation via command line, see the respective subdirectories (`mc_fronte ### Access to the Docker container -Use `docker-compose down` to stop and remove the currently running containers. +Use `docker compose down` to stop and remove the currently running containers. To access a running container directly, get the container ID via `docker ps` and connect via `docker exec -it CONTAINER_ID bash`. @@ -66,7 +66,7 @@ To update the changelog, use: `git log --oneline --decorate > CHANGELOG` ### Locally To test your code locally, run `./coverage_local.sh` (all components) -or `docker-compose run --rm --entrypoint="./coverage_backend.sh" mcserver` (only backend). +or `docker compose run --rm --entrypoint="./coverage_backend.sh" mcserver` (only backend). To test the GitLab CI locally, run `gitlab-runner exec docker --docker-privileged --env CI_REGISTRY_USER=YOUR_USERNAME JOB_NAME`. Do not forget to insert your actual GitLab username. The `JOB_NAME` should be replaced by an actual job name from the diff --git a/coverage_local.sh b/coverage_local.sh index a052db9..7ad333e 100755 --- a/coverage_local.sh +++ b/coverage_local.sh @@ -1,5 +1,5 @@ -docker-compose build -docker-compose run --rm --entrypoint="npm run test-ci" mc_frontend > ci_frontend.log -docker-compose run --rm --entrypoint="./coverage_backend.sh" mcserver > ci_backend.log +docker compose build +docker compose run --rm --entrypoint="npm run test-ci" mc_frontend > ci_frontend.log +docker compose run --rm --entrypoint="./coverage_backend.sh" mcserver > ci_backend.log ./coverage_ci.sh cat coverage.log diff --git a/deploy.sh b/deploy.sh index cf349bd..60d6c8d 100755 --- a/deploy.sh +++ b/deploy.sh @@ -1,4 +1,4 @@ python3 ./mc_frontend/update_version.py -docker-compose build -docker-compose down -docker-compose up -d +docker compose build +docker compose down +docker compose up -d diff --git a/mc_backend/README.md b/mc_backend/README.md index b75a781..52a7944 100644 --- a/mc_backend/README.md +++ b/mc_backend/README.md @@ -25,6 +25,7 @@ OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES # Dependencies To update outdated dependencies, find the relevant ones by running: `pip list -o` +Then, for each of the listed dependencies, run: `pip install -U <DEPENDENCY_NAME>` Then, for each of the listed dependencies, run: `pip install -U <DEPENDENCY_NAME>` Or combine both commands in one line: `pip list -o --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U` @@ -33,13 +34,13 @@ Or combine both commands in one line: `pip list -o --format=freeze | grep -v '^\ # Database To autogenerate a new migration script: -1. Start the Docker container with the database: `docker-compose up -p 5432:5432 -d db` +1. Start the Docker container with the database: `docker compose up -p 5432:5432 -d db` 2. Create a new migration: `flask db migrate`. 3. Perform a migration... - ... to a newer version: `flask db upgrade`. - ... to an older version: `flask db downgrade`. - If it does nothing or fails, make sure that the environment variable FLASK_APP is set correctly (see https://flask.palletsprojects.com/en/1.1.x/cli/): `export FLASK_APP=app.py` -5. To finish the process, shut down the database container: `docker-compose down` +5. To finish the process, shut down the database container: `docker compose down` ---------------------------------------------------------------- diff --git a/mc_backend/mcserver/app/services/customCorpusService.py b/mc_backend/mcserver/app/services/customCorpusService.py index a00b0c7..15b5dde 100644 --- a/mc_backend/mcserver/app/services/customCorpusService.py +++ b/mc_backend/mcserver/app/services/customCorpusService.py @@ -292,13 +292,13 @@ class CustomCorpusService: if len(cc.text_parts) == 0 or cc.text_parts[-1].citation.label != citation_parts[0]: cc.text_parts.append( TextPart(citation=Citation(level=CitationLevel[cc.corpus.citation_level_1.lower()], - label=citation_parts[0], value=len(cc.text_parts) + 1))) + label=citation_parts[0], value=int(citation_parts[0])))) target_text_parts: List[TextPart] = cc.text_parts[-1].sub_text_parts if cc.corpus.citation_level_2 != CitationLevel.default.value and ( len(target_text_parts) == 0 or target_text_parts[-1].citation.label != citation_parts[1]): target_text_parts.append( TextPart(citation=Citation(level=CitationLevel[cc.corpus.citation_level_2.lower()], - label=citation_parts[1], value=len(target_text_parts) + 1))) + label=citation_parts[1], value=int(citation_parts[1])))) target_text_parts = cc.text_parts[-1].sub_text_parts[-1].sub_text_parts if cc.corpus.citation_level_3 != CitationLevel.default.value: if len(citation_parts) < 3: diff --git a/mc_backend/tests.py b/mc_backend/tests.py index 9f8bc1d..07436b0 100644 --- a/mc_backend/tests.py +++ b/mc_backend/tests.py @@ -41,7 +41,7 @@ from mcserver.app.api.zenodoAPI import remove_older_versions from mcserver.app.models import ResourceType, FileType, ExerciseType, ExerciseData, \ NodeMC, LinkMC, GraphData, Phenomenon, CustomCorpus, AnnisResponse, Solution, DownloadableFile, Language, \ VocabularyCorpus, TextComplexityMeasure, CitationLevel, FrequencyItem, Choice, XapiStatement, ExerciseMC, \ - CorpusMC, make_solution_element_from_salt_id, Sentence, ReferenceableText, Dependency, PartOfSpeech + CorpusMC, make_solution_element_from_salt_id, Sentence, ReferenceableText, Dependency, PartOfSpeech, Citation from mcserver.app.services import AnnotationService, CorpusService, FileService, CustomCorpusService, \ DatabaseService, XMLservice, TextService, FrequencyService, ExerciseService, TextComplexityService, NetworkService from mcserver.config import TestingConfig, Config, DevelopmentConfig @@ -1169,6 +1169,12 @@ class CorpusTestCase(unittest.TestCase): self.assertEqual(len(cc.text_parts), 1) cc.text_parts = [] + def test_init_custom_corpus_caesar_proiel(self): + """ Checks the consistency of citations for text parts from messy parts of the treebank. """ + cc: CustomCorpus = CustomCorpusService.init_custom_corpus(CustomCorpusService.custom_corpora[0]) + target_citation: Citation = cc.text_parts[5].sub_text_parts[19].sub_text_parts[1].citation + self.assertEqual(target_citation.value, int(target_citation.label)) + def test_init_custom_corpus_commentariolus(self): """ Initializes the citation system for Copernicus' Commentariolus. """ cc: CustomCorpus = CustomCorpusService.get_custom_corpus_by_urn( -- GitLab