diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d0e95c856d5bec12a2d2543832ab522ce90180ba..87586ccc6eadcd4bbfcdc8a7db11b493526e52c8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,29 +1,46 @@ -stages: # List of stages for jobs, and their order of execution - - build +stages: + - train - test - deploy -build-job: # This job runs in the build stage, which runs first. - stage: build - script: - - echo "Compiling the code..." - - echo "Compile complete." +variables: + MODEL_PATH: "distilbert-finetuned-ner" + +before_script: + # Ensure the required Python version and pip are set up + - apt-get update && apt-get install -y python3 python3-pip + - python3 -m pip install --upgrade pip + - pip3 install -r requirements.txt -unit-test-job: # This job runs in the test stage. - stage: test # It only starts when the job in the build stage completes successfully. +train: + stage: train script: - - echo "Running unit tests... This will take about 60 seconds." - - echo "Code coverage is 90%" + - python3 train_model.py + artifacts: + paths: + - $MODEL_PATH # Save the trained model as an artifact -lint-test-job: # This job also runs in the test stage. - stage: test # It can run at the same time as unit-test-job (in parallel). +test: + stage: test script: - - echo "Linting code... This will take about 10 seconds." - - echo "No lint issues found." + - echo "Testing the model..." + # Ensure Flask is installed + - pip3 install flask + # Run the Flask app in the background + - nohup python3 app.py & + - sleep 10 # Wait for the server to start + # Run the tests + - curl -X POST http://localhost:5003/predict -H "Content-Type: application/json" -d '{"tokens": ["For", "this", "purpose", "the", "Gothenburg", "Young", "Persons", "Empowerment", "Scale", "(", "GYPES", ")", "was", "developed", "."]}' + - curl -X POST http://localhost:5003/stress_test -H "Content-Type: application/json" -d '{"tokens": ["For", "this", "purpose", "the", "Gothenburg", "Young", "Persons", "Empowerment", "Scale", "(", "GYPES", ")", "was", "developed", "."]}' + - curl -X POST http://localhost:5003/run_stress_test -H "Content-Type: application/json" -d '{"num_requests": 50}' + - curl -X GET http://localhost:5003/get_latest_results + dependencies: + - train -deploy-job: # This job runs in the deploy stage. - stage: deploy # It only runs when *both* jobs in the test stage complete successfully. - environment: production +deploy: + stage: deploy script: - - echo "Deploying application..." - - echo "Application successfully deployed." + - echo "Deploying model..." + # Deployment steps go here, for example, uploading the model to a server + dependencies: + - train