You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2019/06/20 11:19:00 UTC

[jira] [Commented] (AIRFLOW-4048) HttpSensor provide context to response_check

    [ https://issues.apache.org/jira/browse/AIRFLOW-4048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16868455#comment-16868455 ] 

ASF GitHub Bot commented on AIRFLOW-4048:
-----------------------------------------

ashb commented on pull request #4890: [AIRFLOW-4048] HttpSensor provide-context to response_check
URL: https://github.com/apache/airflow/pull/4890
 
 
   
 
----------------------------------------------------------------
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:
users@infra.apache.org


> HttpSensor provide context to response_check
> --------------------------------------------
>
>                 Key: AIRFLOW-4048
>                 URL: https://issues.apache.org/jira/browse/AIRFLOW-4048
>             Project: Apache Airflow
>          Issue Type: Improvement
>            Reporter: raphael auv
>            Assignee: raphael auv
>            Priority: Minor
>             Fix For: 1.10.4
>
>
> Actually the response_check do not get by parameter the context , with a simple , provide_context option at the constructor , we could provide the context to the response_check function
> actual code :
> {code:java}
>    ...
>  
>    def poke(self, context):
>         self.log.info('Poking: %s', self.endpoint)
>         try:
>             response = self.hook.run(self.endpoint,
>                                      data=self.request_params,
>                                      headers=self.headers,
>                                      extra_options=self.extra_options)
>             if self.response_check:
>                 # run content check on response
>                 return self.response_check(response)
> {code}
>  
>  futur code:
> {code:java}
>    def __init__(self,
>                  endpoint,
>                  http_conn_id='http_default',
>                  method='GET',
>                  request_params=None,
>                  headers=None,
>                  response_check=None,
>                  extra_options=None
>                  provide_context=False, *args, **kwargs):
>         super(HttpSensor, self).__init__(*args, **kwargs)
>         ...
>         self.provide_context = provide_context
>     def poke(self, context):
>         self.log.info('Poking: %s', self.endpoint)
>         try:
>             response = self.hook.run(self.endpoint,
>                                      data=self.request_params,
>                                      headers=self.headers,
>                                      extra_options=self.extra_options)
>             if self.response_check:
>                 # run content check on response
>                 response_check_kwargs = {}
>                if self.provide_context:
>                    response_check_kwargs["context"] = context
>                return self.response_check(response, **response_check_kwargs)
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)