diff --git a/README.md b/README.md index d041ca04683b2723cc8bd58dff230aab27879999..6bb3398cacc5bf11aaa232289429dea97a7ba0a6 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 a052db9456f00924fa1f50789b203a7a8caa31b2..7ad333e87cd8940e99a8c687aab86b043d928b47 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 cf349bd7957da6156032c68d63ece7d176480033..60d6c8dd090723ead7decf4156bba6ad9ad0bc42 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 b75a781433915887cb9ede4b7ce046908662fe4f..52a7944a2e70180e917bc4fb84d2fa480b3424c0 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 a00b0c7a26daedbc323f467216fb11e3df11b02c..15b5dde2953b60d2a7db0713d0c993e04b0d5775 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 9f8bc1d035830640d5342eb4ebdcb688409ca19e..07436b00f304b7dd6b4ca8b92ec2cc8cacbc18dd 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(