[GitHub] [airflow] takunnithan commented on a change in pull request #9556: API Endpoint - DagRuns Batch

2020-07-03 Thread GitBox


takunnithan commented on a change in pull request #9556:
URL: https://github.com/apache/airflow/pull/9556#discussion_r449701317



##
File path: airflow/api_connexion/schemas/dag_run_schema.py
##
@@ -80,15 +80,15 @@ class Meta:
 datetimeformat = 'iso'
 strict = True
 
-page_offset = fields.Int(required=False, missing=0, min=0)
-page_limit = fields.Int(required=False, missing=100, min=1)
-dag_ids = fields.List(fields.Str(), required=False, missing=None)
-execution_date_gte = fields.DateTime(required=False, missing=None)
-execution_date_lte = fields.DateTime(required=False, missing=None)
-start_date_gte = fields.DateTime(required=False, missing=None)
-start_date_lte = fields.DateTime(required=False, missing=None)
-end_date_gte = fields.DateTime(required=False, missing=None)
-end_date_lte = fields.DateTime(required=False, missing=None)
+page_offset = fields.Int(missing=0, min=0)
+page_limit = fields.Int(missing=100, min=1)
+dag_ids = fields.List(fields.Str(), missing=None)
+execution_date_gte = fields.DateTime(missing=None)
+execution_date_lte = fields.DateTime(missing=None)
+start_date_gte = fields.DateTime(missing=None)
+start_date_lte = fields.DateTime(missing=None)
+end_date_gte = fields.DateTime(missing=None)
+end_date_lte = fields.DateTime(missing=None)

Review comment:
   The fields were missing in the deserialized data, when `missing=None` 
was removed.





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:
us...@infra.apache.org




[GitHub] [airflow] takunnithan commented on a change in pull request #9556: API Endpoint - DagRuns Batch

2020-07-03 Thread GitBox


takunnithan commented on a change in pull request #9556:
URL: https://github.com/apache/airflow/pull/9556#discussion_r449696774



##
File path: tests/api_connexion/endpoints/test_dag_run_endpoint.py
##
@@ -346,6 +346,243 @@ def test_end_date_gte_lte(self, url, 
expected_dag_run_ids, session):
 self.assertEqual(dag_run_ids, expected_dag_run_ids)
 
 
+class TestGetDagRunBatch(TestDagRunEndpoint):
+@provide_session
+def test_should_respond_200(self, session):
+dag_runs = self._create_test_dag_run()
+session.add_all(dag_runs)
+session.commit()
+payload = {
+"dag_ids": ["TEST_DAG_ID"],
+}
+response = self.client.post("api/v1/dags/~/dagRuns/list", json=payload)
+assert response.status_code == 200
+self.assertEqual(

Review comment:
   Yes. Replaced `assertEqual` with `assert`





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:
us...@infra.apache.org




[GitHub] [airflow] takunnithan commented on a change in pull request #9556: API Endpoint - DagRuns Batch

2020-07-03 Thread GitBox


takunnithan commented on a change in pull request #9556:
URL: https://github.com/apache/airflow/pull/9556#discussion_r449696638



##
File path: tests/api_connexion/endpoints/test_dag_run_endpoint.py
##
@@ -346,6 +346,243 @@ def test_end_date_gte_lte(self, url, 
expected_dag_run_ids, session):
 self.assertEqual(dag_run_ids, expected_dag_run_ids)
 
 
+class TestGetDagRunBatch(TestDagRunEndpoint):
+@provide_session
+def test_should_respond_200(self, session):
+dag_runs = self._create_test_dag_run()
+session.add_all(dag_runs)
+session.commit()

Review comment:
   Thanks @turbaszek . This is addressed in the latest commit.





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:
us...@infra.apache.org




[GitHub] [airflow] takunnithan commented on a change in pull request #9556: API Endpoint - DagRuns Batch

2020-07-03 Thread GitBox


takunnithan commented on a change in pull request #9556:
URL: https://github.com/apache/airflow/pull/9556#discussion_r449696389



##
File path: airflow/api_connexion/schemas/dag_run_schema.py
##
@@ -72,5 +72,25 @@ class DAGRunCollectionSchema(Schema):
 total_entries = fields.Int()
 
 
+class DagRunsBatchFormSchema(Schema):
+""" Schema to validate and deserialize the Form(request payload) submitted 
to DagRun Batch endpoint"""
+
+class Meta:
+""" Meta """
+datetimeformat = 'iso'
+strict = True
+
+page_offset = fields.Int(required=False, missing=0, min=0)
+page_limit = fields.Int(required=False, missing=100, min=1)
+dag_ids = fields.List(fields.Str(), required=False, missing=None)
+execution_date_gte = fields.DateTime(required=False, missing=None)

Review comment:
   Thanks @ephraimbuddy . I have removed `required=False` from the args. 
But without `missing=None`, the fields were missing in deserialized data.





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:
us...@infra.apache.org




[GitHub] [airflow] takunnithan commented on a change in pull request #9556: API Endpoint - DagRuns Batch

2020-06-30 Thread GitBox


takunnithan commented on a change in pull request #9556:
URL: https://github.com/apache/airflow/pull/9556#discussion_r448088709



##
File path: tests/api_connexion/endpoints/test_dag_run_endpoint.py
##
@@ -346,6 +346,55 @@ def test_end_date_gte_lte(self, url, expected_dag_run_ids, 
session):
 self.assertEqual(dag_run_ids, expected_dag_run_ids)
 
 
+class TestGetDagRunBatch(TestDagRunEndpoint):
+@provide_session
+def test_should_respond_200(self, session):
+dag_runs = self._create_test_dag_run()
+session.add_all(dag_runs)
+session.commit()
+payload = {
+"page_offset": 0,
+"page_limit": 10,
+"dag_ids": ["TEST_DAG_I"],
+"execution_date_gte": "2020-06-24T19:54:56Z",
+"execution_date_lte": self.default_time,
+"start_date_gte": "2020-06-24T19:54:56Z",
+"start_date_lte": self.default_time,
+"end_date_gte": "2020-06-24T19:54:56Z",
+"end_date_lte": self.default_time
+}
+response = self.client.post("api/v1/dags/~/dagRuns/list", json=payload)
+assert response.status_code == 200
+self.assertEqual(
+response.json,
+{
+"dag_runs": [
+{
+'dag_id': 'TEST_DAG_ID',
+'dag_run_id': 'TEST_DAG_RUN_ID_1',
+'end_date': None,
+'state': 'running',
+'execution_date': self.default_time,
+'external_trigger': True,
+'start_date': self.default_time,
+'conf': {},
+},
+{
+'dag_id': 'TEST_DAG_ID',
+'dag_run_id': 'TEST_DAG_RUN_ID_2',
+'end_date': None,
+'state': 'running',
+'execution_date': self.default_time_2,
+'external_trigger': True,
+'start_date': self.default_time,
+'conf': {},
+},
+],
+"total_entries": 2,
+}
+)
+
+

Review comment:
   Thanks @mik-laj





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:
us...@infra.apache.org