You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "tirkarthi (via GitHub)" <gi...@apache.org> on 2025/03/12 07:58:24 UTC
[I] Format timedelta values in API response [airflow]
tirkarthi opened a new issue, #47660:
URL: https://github.com/apache/airflow/issues/47660
### Apache Airflow version
main (development)
### If "Other Airflow 2 version" selected, which one?
_No response_
### What happened?
`timedelta` fields like `dagrun_timeout` are serialized by pydantic to ISO 8601 duration format. Rendering the value in frontend is not intuitive to the users and should probably be formatted as `HH:MM:SS` . E.g. 1 day 15 seconds is serialized as `P1DT15S`
https://docs.pydantic.dev/latest/api/config/#pydantic.config.ConfigDict.ser_json_timedelta
### What you think should happen instead?
_No response_
### How to reproduce
```python
from __future__ import annotations
from datetime import timedelta
import pydantic
class TimedeltaExampleBase(pydantic.BaseModel):
timeout: timedelta
class TimedeltaExampleFloat(TimedeltaExampleBase):
model_config = pydantic.ConfigDict(ser_json_timedelta="float")
class TimedeltaExampleISO(TimedeltaExampleBase):
pass
float_ser = TimedeltaExampleFloat.model_validate({"timeout": timedelta(days=1, seconds=15)})
print(float_ser.model_dump_json())
default_ser = TimedeltaExampleISO.model_validate({"timeout": timedelta(days=1, seconds=15)})
print(default_ser.model_dump_json())
```
Output
```
{"timeout":86415.0}
{"timeout":"P1DT15S"}
```
### Operating System
Ubuntu 20.04
### Versions of Apache Airflow Providers
_No response_
### Deployment
Virtualenv installation
### Deployment details
_No response_
### Anything else?
_No response_
### Are you willing to submit PR?
- [ ] 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: commits-unsubscribe@airflow.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Format timedelta values in API response [airflow]
Posted by "tirkarthi (via GitHub)" <gi...@apache.org>.
tirkarthi commented on issue #47660:
URL: https://github.com/apache/airflow/issues/47660#issuecomment-3178725604
@pierrejeambrun Sorry if it was not clear but my request was to show this in an intuitive format in frontend to users similar to Airflow 2 since currently it's shown in iso 8601 format as per backend. dayjs supports parsing durations using Duration plugin which can format the API response as HH:MM:SS for better readability.
https://day.js.org/docs/en/durations/creating
--
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-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Format timedelta values in API response [airflow]
Posted by "mandeepzemo (via GitHub)" <gi...@apache.org>.
mandeepzemo commented on issue #47660:
URL: https://github.com/apache/airflow/issues/47660#issuecomment-3178082439
@tirkarthi would you please assigned a ticket to me, as i have debugged the issue and resolve as per above requirement.
Sharing the PR for same
https://github.com/apache/airflow/pull/54390
Screenshot
<img width="1512" height="967" alt="Image" src="https://github.com/user-attachments/assets/13840af9-5bac-4324-8e5f-27e9aa42cde5" />
--
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-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Format timedelta values in API response [airflow]
Posted by "mandeepzemo (via GitHub)" <gi...@apache.org>.
mandeepzemo commented on issue #47660:
URL: https://github.com/apache/airflow/issues/47660#issuecomment-3173286555
If its open i like to work on it
--
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-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Format timedelta values in API response [airflow]
Posted by "mandeepzemo (via GitHub)" <gi...@apache.org>.
mandeepzemo commented on issue #47660:
URL: https://github.com/apache/airflow/issues/47660#issuecomment-3173969259
@tirkarthi Not able to reproduce the issue again.
It would be great if you please share the reproduce steps for this issue.
--
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-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Format timedelta values in API response [airflow]
Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun commented on issue #47660:
URL: https://github.com/apache/airflow/issues/47660#issuecomment-3180209426
I just did a quick search and it does not appear that the `dagrun_timeout` is even showed in the UI. ('duration' is already handled properly with `getDuration`)
--
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-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Format timedelta values in API response [airflow]
Posted by "tirkarthi (via GitHub)" <gi...@apache.org>.
tirkarthi commented on issue #47660:
URL: https://github.com/apache/airflow/issues/47660#issuecomment-3178735782
Apologies again I get your point now and misread the ticket. We can repurpose this as frontend only change if okay or create a new one.
--
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-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Format timedelta values in API response [airflow]
Posted by "mandeepzemo (via GitHub)" <gi...@apache.org>.
mandeepzemo commented on issue #47660:
URL: https://github.com/apache/airflow/issues/47660#issuecomment-3177524219
@tirkarthi Thanks, now able to Reproduce it.
--
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-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Format timedelta values in API response [airflow]
Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun commented on issue #47660:
URL: https://github.com/apache/airflow/issues/47660#issuecomment-3178608386
Sorry I'm late commenting on this. As mentioned in the linked PR:
- That would be a breaking change
- FastAPI follows https://datatracker.ietf.org/doc/html/rfc3339 and we probably want to keep following that and not go into custom formatting or duration / period
- I'm sure there are some front-end / js packages or way to parse iso 8601 formatted duration.
I don't think we should do that, closing for now, feel free to re-open if needed.
--
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-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Format timedelta values in API response [airflow]
Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun closed issue #47660: Format timedelta values in API response
URL: https://github.com/apache/airflow/issues/47660
--
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-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Format timedelta values in API response [airflow]
Posted by "tirkarthi (via GitHub)" <gi...@apache.org>.
tirkarthi commented on issue #47660:
URL: https://github.com/apache/airflow/issues/47660#issuecomment-3173990311
You can try the example dag `example_passing_params_via_test_command` . Under details tab the `dagrun_timeout` value in code which is `datetime.timedelta(minutes=4)` is rendered as `PT4M` which is not intuitive. It should be something like `00:04:00` .
http://localhost:8000/dags/example_passing_params_via_test_command/details
--
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-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Format timedelta values in API response [airflow]
Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun commented on issue #47660:
URL: https://github.com/apache/airflow/issues/47660#issuecomment-3180198856
> We can repurpose this as frontend only change if okay or create a new one.
Yes we can definitely re-open and rewrite this to target the UI presentation layer for periods
--
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-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org