[ 
https://issues.apache.org/jira/browse/AIRFLOW-4048?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

raphael auv updated AIRFLOW-4048:
---------------------------------
    Description: 
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}
 

 
{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}

  was:
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}
 

 
{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
                response_check_kwargs = {}
               if self.provide_context:
                   response_check_kwargs["context"] = context

               return self.response_check(response, **response_check_kwargs)


{code}


> 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.0
>
>
> 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}
>  
>  
> {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)

Reply via email to