ashb commented on code in PR #44562: URL: https://github.com/apache/airflow/pull/44562#discussion_r1869490141
########## task_sdk/src/airflow/sdk/api/client.py: ########## @@ -157,6 +159,16 @@ def get(self, key: str) -> VariableResponse: resp = self.client.get(f"variables/{key}") return VariableResponse.model_validate_json(resp.read()) + def set(self, msg: PutVariable): + """Set an Airflow Variable via the API server.""" + key = msg.key + body = VariablePostBody(**msg.model_dump(exclude_unset=True, include={"value", "description"})) + self.client.put(f"variables/{key}", content=body.model_dump_json()) Review Comment: I don't think the API client should take a parameter of this type as it feels like it's breaking encapsulation (PutVariable is designed to have the info needed from Task to Supervisor), ```suggestion def set(self, key: str, value: str | None, description: str | None = None): """Set an Airflow Variable via the API server.""" body = VariablePostBody(value=value, description=description) self.client.put(f"variables/{key}", content=body.model_dump_json()) ``` -- 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: commits-unsubscr...@airflow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org