ChaiBapchya commented on a change in pull request #25:
URL: https://github.com/apache/incubator-mxnet-ci/pull/25#discussion_r425576336



##########
File path: services/jenkins-pipeline-monitor/handler.py
##########
@@ -0,0 +1,134 @@
+import os
+import boto3
+import json
+import logging
+import secret_manager
+
+from jenkinsapi.jenkins import Jenkins
+
+logging.getLogger().setLevel(logging.INFO)
+logging.getLogger('boto3').setLevel(logging.CRITICAL)
+logging.getLogger('botocore').setLevel(logging.CRITICAL)
+
+
+def get_jenkins_obj(secret):
+    """
+    This method returns an object of Jenkins instantiated using username, 
password
+    """
+    jenkins_url, jenkins_username, jenkins_password = 
os.environ["JENKINS_URL"], secret["jenkins_username"], 
secret["jenkins_password"]
+    return Jenkins(jenkins_url, username=jenkins_username, 
password=jenkins_password)
+
+
+def get_secret():
+    """
+    This method is to get secret value from Secrets Manager
+    """
+    secret = json.loads(secret_manager.get_secret())
+    return secret
+
+
+def get_pipeline_job(jenkinsObj):
+    job = jenkinsObj["restricted-mxnet-cd/mxnet-cd-release-job"]
+    return job
+
+
+def get_latest_build_number(job):
+    return job.get_last_build().get_number()
+
+
+def get_build_from_build_number(job, build_number):
+    return job.get_build(build_number)
+
+
+def get_build_timestamp(build):
+    return build.get_timestamp()
+
+
+def get_build_date(timestamp):
+    return timestamp.date()
+
+
+def is_latest_day_build(current_build, latest_build):
+    current_build_timestamp = get_build_timestamp(current_build)
+    latest_build_timestamp = get_build_timestamp(latest_build)
+    # if 2 builds are within 24 hours and on the same day

Review comment:
       previously i was thinking timezone difference might cause few issues for 
eg
   
   5pm PT would be next day in UTC
   and hence the day would be different. In that case we would have to check 
for 24hours.
   
   Right now, I have put 11:59pm UTC which ensures same day check is enough. 
I'll remove the 24hour diff check.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to