Skip to content

Commit

Permalink
Merge pull request #542 from wcmc-its/development
Browse files Browse the repository at this point in the history
Merging the model and other code chanegs to the production.
  • Loading branch information
paulalbert1 authored Feb 3, 2025
2 parents 584ea70 + 0169879 commit 30068d0
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 5 deletions.
20 changes: 19 additions & 1 deletion k8-buildspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@ phases:
- java -version
pre_build:
commands:
# Fetch Docker credentials from AWS Secrets Manager
- echo "Fetching Docker credentials from AWS Secrets Manager"
- SECRET=$(aws secretsmanager get-secret-value --secret-id docker-hub-credentials --query "SecretString" --output text)

# Extract username and password from the JSON response
- DOCKER_USERNAME=$(echo $SECRET | sed -n 's/.*"username":"\([^"]*\)".*/\1/p')
- DOCKER_PASSWORD=$(echo $SECRET | sed -n 's/.*"password":"\([^"]*\)".*/\1/p')

# Print the Docker username to the CodeBuild log
- echo "Docker Username $DOCKER_USERNAME"

# Log in to Docker registry
- echo "Logging in to Docker registry"
- echo "$DOCKER_PASSWORD" | docker login --username $DOCKER_USERNAME --password-stdin

- TAG="$CODEBUILD_BUILD_NUMBER.$(date +%Y-%m-%d.%H.%M.%S).$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | head -c 8)"
- echo $TAG
- sed -i.bak -e 's@CONTAINER_IMAGE@'"$REPOSITORY_URI:$TAG"'@' kubernetes/k8-deployment.yaml
Expand All @@ -31,11 +46,14 @@ phases:
if expr "${BRANCH}" : ".*master" >/dev/null || expr "${BRANCH}" : ".*dev" >/dev/null; then
docker build --tag $REPOSITORY_URI:$TAG .
docker push $REPOSITORY_URI:$TAG
# Log out from the Docker registry to clear credentials
docker logout $REPOSITORY_URI
aws eks update-kubeconfig --name $EKS_CLUSTER_NAME --region us-east-1 --role-arn $EKS_KUBECTL_ROLE_ARN
fi
if expr "${BRANCH}" : ".*master" >/dev/null; then
kubectl set image deployment/reciter-prod reciter=$REPOSITORY_URI:$TAG -n $EKS_CLUSTER_NAME
fi
if expr "${BRANCH}" : ".*dev" >/dev/null; then
kubectl set image deployment/reciter-dev reciter=$REPOSITORY_URI:$TAG -n $EKS_CLUSTER_NAME
fi
fi
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,11 @@ private static double getAuthorsCountScore(AuthorCountEvidence evidence)

private static double getEducationYearScore(EducationYearEvidence evidence) {
return Optional.ofNullable(evidence)
.map(EducationYearEvidence::getDiscrepancyDegreeYearDoctoralScore)
.orElse(0.0);
.map(EducationYearEvidence::getDiscrepancyDegreeYearDoctoralScore)
.filter(score -> score != 0.0)
.orElseGet(() -> Optional.ofNullable(evidence)
.map(EducationYearEvidence::getDiscrepancyDegreeYearBachelorScore)
.orElse(0.0));
}

private static double getEmailMatchScore(EmailEvidence evidence) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,11 @@ private List<ReCiterArticle> executePythonScriptForArticleFeedbackTotal(List<ReC
JSONArray articlesIdentityFeedbackScoreTotal = nnmodel.executeArticleScorePredictor("FeedbackIdentityScore", "feedbackIdentityScoreArticles.py",fileName,feedbackIdentityS3BucketName,isS3UploadRequiredString);
log.info("articlesIdentityFeedbaclScoreTotal length",articlesIdentityFeedbackScoreTotal!=null?articlesIdentityFeedbackScoreTotal.length():0);
if(articlesIdentityFeedbackScoreTotal!=null && articlesIdentityFeedbackScoreTotal.length() > 0)
return mapAuthorshipLikelihoodScore(reCiterArticles, articlesIdentityFeedbackScoreTotal);
{
List<ReCiterArticle> articlesScores = mapAuthorshipLikelihoodScore(reCiterArticles, articlesIdentityFeedbackScoreTotal);
articlesScores.forEach(article -> log.info("articleId :", article.getArticleId(), "authorshipLikelihoodScore : ", article.getAuthorshipLikelihoodScore() ));
return articlesScores;
}


} catch (IOException e) {
Expand Down Expand Up @@ -653,7 +657,10 @@ private static double getAuthorsCountScore(AuthorCountEvidence evidence)
private static double getEducationYearScore(EducationYearEvidence evidence) {
return Optional.ofNullable(evidence)
.map(EducationYearEvidence::getDiscrepancyDegreeYearDoctoralScore)
.orElse(0.0);
.filter(score -> score != 0.0)
.orElseGet(() -> Optional.ofNullable(evidence)
.map(EducationYearEvidence::getDiscrepancyDegreeYearBachelorScore)
.orElse(0.0));
}

private static double getEmailMatchScore(EmailEvidence evidence) {
Expand Down Expand Up @@ -711,6 +718,7 @@ private static List<ReCiterArticle> mapAuthorshipLikelihoodScore(List<ReCiterArt
.map(article -> {
// Find the JSON object that corresponds to this article's ID
ReCiterArticle reCiterArticle = findJSONObjectById(authorshipLikelihoodScoreArray, article);
log.info("After setting the score to article***",reCiterArticle.getAuthorshipLikelihoodScore());
// count the targetAuthors per article
long targetAuthorCount = article.getArticleCoAuthors().getAuthors().stream()
.filter(ReCiterAuthor::isTargetAuthor) // Filter target authors
Expand All @@ -736,11 +744,14 @@ else if (reCiterArticle == null) {
private static ReCiterArticle findJSONObjectById(JSONArray jsonArray, ReCiterArticle article) {
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
log.info("ArticleId from JSONArray: ", jsonObject.getLong("id") , ", Article Id from ReCiterArticle: " , article.getArticleId());
if (jsonObject.getLong("id") == article.getArticleId()) {
/*article.setAuthorshipLikelihoodScore(BigDecimal.valueOf(jsonObject.getDouble("scoreTotal")*100)
.setScale(3, RoundingMode.DOWN)
.doubleValue());*/
log.info("both articleIds are matching and Score is ***",jsonObject.getDouble("scoreTotal"));
article.setAuthorshipLikelihoodScore(jsonObject.getDouble("scoreTotal")*100);
log.info("After setting the score to article***",article.getAuthorshipLikelihoodScore());
return article; // Return the modified article
}
}
Expand Down
Binary file modified src/main/resources/scripts/feedbackIdentityModel.keras
Binary file not shown.
Binary file modified src/main/resources/scripts/feedbackIdentityScaler.save
Binary file not shown.

0 comments on commit 30068d0

Please sign in to comment.