You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "jbampton (via GitHub)" <gi...@apache.org> on 2025/07/26 21:40:11 UTC
[PR] Add pre-commit hook `oxipng` for lossless PNG compression [airflow]
jbampton opened a new pull request, #53787:
URL: https://github.com/apache/airflow/pull/53787
No loss in quality but reduced size
Less data means faster load times etc. saves bandwidth.
Save the planet
https://github.com/oxipng/oxipng
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!--
Thank you for contributing! Please make sure that your code changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.
Feel free to ping committers for the review!
In case of an existing issue, reference it using one of the following:
closes: #ISSUE
related: #ISSUE
How to write a good git commit message:
http://chris.beams.io/posts/git-commit/
-->
<!-- Please keep an empty line above the dashes. -->
---
**^ Add meaningful description above**
Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)** for more information.
In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
In case of backwards incompatible changes please leave a note in a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments).
--
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: [PR] Add pre-commit hook `oxipng` for lossless PNG compression [airflow]
Posted by "jscheffl (via GitHub)" <gi...@apache.org>.
jscheffl commented on PR #53787:
URL: https://github.com/apache/airflow/pull/53787#issuecomment-3137675512
So coming around the CPU and pre-commit check runtime... we could build a list of hashes around the images like we do with other generated content. Might be a bit of engineering/ coding but hashing the files will be faster than re-processing /checking all times
--
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: [PR] Add pre-commit hook `oxipng` for lossless PNG compression [airflow]
Posted by "amoghrajesh (via GitHub)" <gi...@apache.org>.
amoghrajesh commented on code in PR #53787:
URL: https://github.com/apache/airflow/pull/53787#discussion_r2238544754
##########
.pre-commit-config.yaml:
##########
@@ -309,6 +309,12 @@ repos:
name: Check if RST files use double backticks for code
- id: python-no-log-warn
name: Check if there are no deprecate log warn
+ - repo: https://github.com/oxipng/oxipng
+ rev: v9.1.5
+ hooks:
+ - id: oxipng
Review Comment:
+1 agree with the proposal
--
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: [PR] Add pre-commit hook `oxipng` for lossless PNG compression [airflow]
Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun commented on PR #53787:
URL: https://github.com/apache/airflow/pull/53787#issuecomment-3127064428
Static checks need fixing though.
--
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: [PR] Add pre-commit hook `oxipng` for lossless PNG compression [airflow]
Posted by "jbampton (via GitHub)" <gi...@apache.org>.
jbampton closed pull request #53787: Add pre-commit hook `oxipng` for lossless PNG compression
URL: https://github.com/apache/airflow/pull/53787
--
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: [PR] Add pre-commit hook `oxipng` for lossless PNG compression [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #53787:
URL: https://github.com/apache/airflow/pull/53787#issuecomment-3144312229
> So coming around the CPU and pre-commit check runtime... we could build a list of hashes around the images like we do with other generated content. Might be a bit of engineering/ coding but hashing the files will be faster than re-processing /checking all times
Yes. That might a good solution - and one that would require a bit more complex pre-commit script - but we alrady have quite a anumber of those that can be used as reference.
--
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: [PR] Add pre-commit hook `oxipng` for lossless PNG compression [airflow]
Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
uranusjr commented on code in PR #53787:
URL: https://github.com/apache/airflow/pull/53787#discussion_r2238109130
##########
.pre-commit-config.yaml:
##########
@@ -309,6 +309,12 @@ repos:
name: Check if RST files use double backticks for code
- id: python-no-log-warn
name: Check if there are no deprecate log warn
+ - repo: https://github.com/oxipng/oxipng
+ rev: v9.1.5
+ hooks:
+ - id: oxipng
Review Comment:
This should have a better id and name such as `ensure-png-compressed`
--
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: [PR] Add pre-commit hook `oxipng` for lossless PNG compression [airflow]
Posted by "amoghrajesh (via GitHub)" <gi...@apache.org>.
amoghrajesh commented on PR #53787:
URL: https://github.com/apache/airflow/pull/53787#issuecomment-3130718541
Is this just me seeing it when trying to check the files loaded?
<img width="1721" height="667" alt="image" src="https://github.com/user-attachments/assets/fe1a62d5-a89c-4caa-bd3b-36eba1ea0700" />
--
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: [PR] Add pre-commit hook `oxipng` for lossless PNG compression [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #53787:
URL: https://github.com/apache/airflow/pull/53787#issuecomment-3136492481
> @potiuk do you see any downside to this?
One concern I have is that it adds 5 minutes for our static checks (you need to look at the timestamp of the previous pre-commit to see when the pre-commit started and when it endeded is in the line of the pre-commit that we want to check time of running:
<img width="1884" height="104" alt="image" src="https://github.com/user-attachments/assets/d7bac950-65de-45c4-9ce3-7ac6b35ba789" />
I double checked and it sems we have ~ 20% saving overall - so it seems to be worth the effort:
```
⏚ [jarek:~/code/airflow] pre-commit-add-oxipng+ 5s ± find . -name '*.png' -exec du -ch {} + | grep total$
63M total
⏚ [jarek:~/code/airflow] pre-commit-add-oxipng+ ± git checkout main
Switched to branch 'main'
Your branch is up-to-date with 'apache/main'.
⏚ [jarek:~/code/airflow] main+ ± find . -name '*.png' -exec du -ch {} + | grep total$
80M total
```
But when I run it again on those already minified files (with --all-files) and it took 1m46 seconds on my 18-core machine with full CPU used .... resulting with no changes... Which is good because it does not minify already minified files but also it 's not good because it's 5 minutes lost for static checks on every PR (we run static checks with --all-files in our CI).
It seems it's very CPU heavy with our 60 MB of .png files and it's rather a waste of time and build CPU to run them again and again in CI.
There is also a little bit of complexity here because some of those .png files are generated from other pre-commits - so it has to be run as one of the last pre-commit - after generating the images, otherwise the gains from this one might be lost by reganerating the files after. Similarly there are some files used as static dist files that get modified - but they are used when compiling the FAB assets - and in this case the files should be modified BEFORE the fab-assets compilation - otherwise (like in the failing check) the hashes of the .png files change.
So while idea is cool, I think adding is as automated pre-commit is a bit too heavy. This could be turned into a manual precommit (--hook-stage manual) and maybe just running it from time to time to minify them and have maybe some periodic reminder to do so. Could you change it this way @jbampton and add some instructions about it ?
That would also help with not having to deal with interaction with the other pre-commits above - if it's only run manually.
--
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