pohek321 opened a new issue #19357:
URL: https://github.com/apache/airflow/issues/19357


   ### Apache Airflow Provider(s)
   
   databricks
   
   ### Versions of Apache Airflow Providers
   
   apache-airflow-providers-databricks==1!2.0.2
   
   
   ### Apache Airflow version
   
   2.1.4 (latest released)
   
   ### Operating System
   
   Debian GNU/Linux 11 (bullseye)
   
   ### Deployment
   
   Docker-Compose
   
   ### Deployment details
   
   Running local deployment using Astronomer CLI
   
   ### What happened
   
   When calling the `get_run_state` method from the `DatabricksHook`, I get the 
following error:
   
   `TypeError: Object of type RunState is not JSON serializable`
   
   I think this is due to [the method returning a RunState custom 
class](https://github.com/apache/airflow/blob/main/airflow/providers/databricks/hooks/databricks.py#L275)
 as opposed to a `str` like the rest of the methods in the databricks hook 
(i.e. `get_job_id`, `get_run_page_url`, etc.)
   
   ### What you expected to happen
   
   When calling the `get_run_state` method, simply return the `result_state` or 
`state_message` 
[variables](https://github.com/apache/airflow/blob/main/airflow/providers/databricks/hooks/databricks.py#L287-L288)
 instead of the `RunState` class.
   
   ### How to reproduce
   
   Create a dag that references a databricks deployment and use this task to 
see the error:
   
   ```
       from airflow.providers.databricks.hooks.databricks import DatabricksHook
       run_id = <insert run id from databricks ui here>
   
       def get_run_state(self, run_id: str):
              return self.hook.get_run_state(run_id=run_id)
   
       python_get_run_state = PythonOperator(
           task_id="python_get_run_state",
           python_callable=get_run_state,
           op_kwargs={
               "run_id": str(run_id)
           }
       )
   ```
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


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