diff --git a/k8-buildspec.yml b/k8-buildspec.yml index a29f0f13..f6bdf15b 100644 --- a/k8-buildspec.yml +++ b/k8-buildspec.yml @@ -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 @@ -31,6 +46,8 @@ 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 @@ -38,4 +55,5 @@ phases: fi if expr "${BRANCH}" : ".*dev" >/dev/null; then kubectl set image deployment/reciter-dev reciter=$REPOSITORY_URI:$TAG -n $EKS_CLUSTER_NAME - fi \ No newline at end of file + + fi diff --git a/src/main/java/reciter/algorithm/cluster/article/scorer/ReCiterArticleScorer.java b/src/main/java/reciter/algorithm/cluster/article/scorer/ReCiterArticleScorer.java index c3166060..7b44f54c 100644 --- a/src/main/java/reciter/algorithm/cluster/article/scorer/ReCiterArticleScorer.java +++ b/src/main/java/reciter/algorithm/cluster/article/scorer/ReCiterArticleScorer.java @@ -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) { diff --git a/src/main/java/reciter/algorithm/feedback/article/scorer/ReciterFeedbackArticleScorer.java b/src/main/java/reciter/algorithm/feedback/article/scorer/ReciterFeedbackArticleScorer.java index b917f3fe..81d9642f 100644 --- a/src/main/java/reciter/algorithm/feedback/article/scorer/ReciterFeedbackArticleScorer.java +++ b/src/main/java/reciter/algorithm/feedback/article/scorer/ReciterFeedbackArticleScorer.java @@ -576,7 +576,11 @@ private List executePythonScriptForArticleFeedbackTotal(List 0) - return mapAuthorshipLikelihoodScore(reCiterArticles, articlesIdentityFeedbackScoreTotal); + { + List articlesScores = mapAuthorshipLikelihoodScore(reCiterArticles, articlesIdentityFeedbackScoreTotal); + articlesScores.forEach(article -> log.info("articleId :", article.getArticleId(), "authorshipLikelihoodScore : ", article.getAuthorshipLikelihoodScore() )); + return articlesScores; + } } catch (IOException e) { @@ -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) { @@ -711,6 +718,7 @@ private static List mapAuthorshipLikelihoodScore(List { // 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 @@ -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 } } diff --git a/src/main/resources/scripts/feedbackIdentityModel.keras b/src/main/resources/scripts/feedbackIdentityModel.keras index fbae8430..c1f53cbe 100644 Binary files a/src/main/resources/scripts/feedbackIdentityModel.keras and b/src/main/resources/scripts/feedbackIdentityModel.keras differ diff --git a/src/main/resources/scripts/feedbackIdentityScaler.save b/src/main/resources/scripts/feedbackIdentityScaler.save index 5d7d111c..dec6573d 100644 Binary files a/src/main/resources/scripts/feedbackIdentityScaler.save and b/src/main/resources/scripts/feedbackIdentityScaler.save differ