Skip to content

Commit

Permalink
merge develop into working branch
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmednasserswe committed Nov 4, 2024
2 parents 0bc3bbc + 83e6360 commit 28150d4
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
15 changes: 8 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,27 @@ before_install:
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
before_script:
- mkdir -p ~/.docker/cli-plugins/ && curl -SL https://github.com/docker/compose/releases/download/v2.30.1/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose && chmod +x ~/.docker/cli-plugins/docker-compose && docker compose version
- ./cc-test-reporter before-build
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- docker-compose build --pull
- docker-compose -f docker-compose.yml -f docker-test.yml up -d
- docker-compose logs -t -f &
- docker compose build
- docker compose -f docker-compose.yml -f docker-test.yml up -d
- docker compose logs -t -f &
- echo "Waiting for Elasticsearch indexes..." && until curl --silent --fail -I "http://localhost:9200/alegre_similarity_test"; do sleep 1; done
- until curl --silent --fail -I "http://localhost:3100"; do sleep 1; done
- echo "Waiting for model servers..." && while [[ ! '2' =~ $(redis-cli -n 1 SCARD 'SharedModel') ]]; do sleep 1; done
#comment until fix timeout curl: (28) Operation timed out
# - docker-compose exec alegre bash -c "curl --max-time 600.0 -OL https://raw.githubusercontent.com/meedan/check-api/develop/spec/pacts/check_api-alegre.json"
# - docker compose exec alegre bash -c "curl --max-time 600.0 -OL https://raw.githubusercontent.com/meedan/check-api/develop/spec/pacts/check_api-alegre.json"
jobs:
include:
- stage: tests
name: unit-tests
script: docker-compose exec alegre make test
script: docker compose exec alegre make test
- stage: tests
name: contract-testing
script: docker-compose exec alegre make contract_testing
script: docker compose exec alegre make contract_testing
after_script:
- docker-compose exec alegre coverage xml
- docker compose exec alegre coverage xml
- if [[ "$TRAVIS_PULL_REQUEST" == "false" && "$TRAVIS_JOB_NAME" != "contract-testing" ]]; then ./cc-test-reporter after-build -t coverage.py -r $CC_TEST_REPORTER_ID --exit-code $TRAVIS_TEST_RESULT; fi
notifications:
slack:
Expand Down
1 change: 0 additions & 1 deletion app/main/lib/elastic_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ def get_blocked_presto_response(task, model, modality):
obj, temporary = get_object(task, model)
doc_id = obj["doc_id"]
callback_url = Presto.add_item_callback_url(app.config['ALEGRE_HOST'], modality)
app.logger.info(f"Object for {task} of model {model} with id of {doc_id} has requires_encoding value of {requires_encoding(obj)}")
if requires_encoding(obj):
blocked_results = []
for model_key in obj.pop("models", []):
Expand Down
1 change: 0 additions & 1 deletion app/main/lib/media_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ def get_blocked_presto_response(task, model, modality):
callback_url = Presto.add_item_callback_url(app.config['ALEGRE_HOST'], modality)
if task.get("doc_id") is None:
task["doc_id"] = str(uuid.uuid4())
app.logger.error(f"Object for {task} of model {model} with id of {obj.id} has requires_encoding value of {obj.requires_encoding}")
if obj.requires_encoding:
response = get_presto_request_response(modality, callback_url, task)
# Warning: this is a blocking hold to wait until we get a response in
Expand Down
2 changes: 1 addition & 1 deletion app/main/lib/similarity.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def callback_add_item(item, similarity_type):
elif similarity_type == "text":
function = callback_add_text
if function:
response = function(item)
response = {"item": function(item)}
app.logger.info(f"[Alegre Similarity] CallbackAddItem: [Item {item}, Similarity type: {similarity_type}] Response looks like {response}")
return response
else:
Expand Down
4 changes: 2 additions & 2 deletions app/main/lib/text_similarity.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def get_model_and_threshold(search_params):
if 'per_model_threshold' in search_params and isinstance(search_params['per_model_threshold'], list) and [e for e in search_params['per_model_threshold'] if e["model"] == model_key]:
threshold = [e for e in search_params['per_model_threshold'] if e["model"] == model_key][0]["value"]
if threshold is None:
app.logger.error(
app.logger.warn(
f"[Alegre Similarity] get_model_and_threshold - no threshold was specified, backing down to default of 0.9 - search_params is {search_params}")
threshold = 0.9
return model_key, threshold
Expand Down Expand Up @@ -194,7 +194,7 @@ def return_sources(results):
and should noisily break since it would have other downstream consequences.
"""
#TODO: remove underscore version after dependencies updated https://meedan.atlassian.net/browse/CV2-5546
return [dict(**r["_source"], **{"_id": r["_id"], "id": r["_id"], "index": r["_index"], "_score": r["_score"],"score": r["_score"]}) for r in results]
return [dict(**r["_source"], **{"_id": r["_id"], "id": r["_id"], "index": r["_index"], "_score": r["_score"], "score": r["_score"]}) for r in results]

def strip_vectors(results):
for result in results:
Expand Down

0 comments on commit 28150d4

Please sign in to comment.