amol- commented on a change in pull request #10650:
URL: https://github.com/apache/arrow/pull/10650#discussion_r669521765



##########
File path: dev/archery/archery/crossbow/reports.py
##########
@@ -121,6 +121,61 @@ def show(self, outstream, asset_callback=None):
                                    asset))
 
 
+class JsonReport(Report):
+
+    HEADER = textwrap.dedent("""
+        Arrow Build Report for Job {job_name}
+
+        All tasks: {all_tasks_url}
+    """)
+
+    TASK = textwrap.dedent("""
+          - {name}:
+            URL: {url}
+    """).strip()
+
+    STATUS_HEADERS = {
+        # from CombinedStatus
+        'error': 'Errored Tasks:',
+        'failure': 'Failed Tasks:',
+        'pending': 'Pending Tasks:',
+        'success': 'Succeeded Tasks:',
+    }
+
+    def __init__(self, job):
+        super().__init__(job)
+
+    def url(self, query):
+        repo_url = self.job.queue.remote_url.strip('.git')
+        return '{}/branches/all?query={}'.format(repo_url, query)
+
+    def todayStr(self):
+        date = datetime.utcnow()
+        return "{}-{}-{}".format(date.year, date.month, date.day)
+
+    def tasksToDict(self, date, tasks):
+        jsonTasks = []
+        for task_name, task in tasks.items():
+            jsonTasks.append({
+                "build" : task_name,
+                "link" : self.url(task.branch),
+                "status" : task.status().combined_state.upper(),
+                "timestamp" : date})
+
+        return jsonTasks
+
+    def getJsonTasks(self):
+        tasks = self.tasksToDict(self.todayStr(), self.job.tasks.items())
+        jsonStr = json.dump(tasks)
+        #TODO remove the print
+        print(jsonStr)
+        return jsonStr
+        
+     #TODO: this just prints to the console for now
+     self.getJsonTasks()

Review comment:
       This is insde the class declaration, so it will be invoked as soon as 
you import the module. I think that was you wanted to do here is invoke it 
inside the `JsonReport.show()`

##########
File path: dev/archery/archery/crossbow/reports.py
##########
@@ -121,6 +121,61 @@ def show(self, outstream, asset_callback=None):
                                    asset))
 
 
+class JsonReport(Report):
+
+    HEADER = textwrap.dedent("""
+        Arrow Build Report for Job {job_name}
+
+        All tasks: {all_tasks_url}
+    """)
+
+    TASK = textwrap.dedent("""
+          - {name}:
+            URL: {url}
+    """).strip()
+
+    STATUS_HEADERS = {
+        # from CombinedStatus
+        'error': 'Errored Tasks:',
+        'failure': 'Failed Tasks:',
+        'pending': 'Pending Tasks:',
+        'success': 'Succeeded Tasks:',
+    }
+
+    def __init__(self, job):
+        super().__init__(job)
+
+    def url(self, query):
+        repo_url = self.job.queue.remote_url.strip('.git')
+        return '{}/branches/all?query={}'.format(repo_url, query)
+
+    def todayStr(self):
+        date = datetime.utcnow()
+        return "{}-{}-{}".format(date.year, date.month, date.day)
+
+    def tasksToDict(self, date, tasks):
+        jsonTasks = []
+        for task_name, task in tasks.items():
+            jsonTasks.append({
+                "build" : task_name,
+                "link" : self.url(task.branch),
+                "status" : task.status().combined_state.upper(),
+                "timestamp" : date})
+
+        return jsonTasks
+
+    def getJsonTasks(self):
+        tasks = self.tasksToDict(self.todayStr(), self.job.tasks.items())
+        jsonStr = json.dump(tasks)
+        #TODO remove the print
+        print(jsonStr)

Review comment:
       I guess this print should be moved into `JsonReport.show()`?




-- 
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.

To unsubscribe, e-mail: [email protected]

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


Reply via email to