How to get changed file dependencies in action

14 views
Skip to first unread message

Daniel Wolf

unread,
Dec 14, 2024, 12:52:08 PM12/14/24
to python-doit
Hi! I'm new to doit, and I'm trying to optimize performance when only some file dependencies have changed.

Let's say I define an action that auto-formats all files of a certain type. So I'd glob for these files and add them to file_dep. This means that if none of the files have changed since the last run, the formatter won't have to run. However, as soon as a single file has changed, the formatter will run, and it will run on all files, including those that haven't changed.

doit knows which of the file dependencies actually changed. It would be great if I could access this information within my action and pass only those files to the formatter. Is there a way to access the list of changed file dependencies from an action?

Jan Vlčinský

unread,
Dec 14, 2024, 4:11:51 PM12/14/24
to pytho...@googlegroups.com

Hi

One way is to make one formatting subtask per file.

Your dodo.py code shall take care of identifying all the files to possibly format and generate a formatting task per such file. No need to take care if it actually needs formatting or not – doit will take care of it.

It assumes your formatter knows, how to format just one file.

 

Jan

 

PS: Another option is to use a formatter, which is so fast that you do not have to optimize number of files processed. For python it would be ruff.

 

---

Honza Vlčinský

jan.vl...@gmail.com | +420-608979040

 

--
You received this message because you are subscribed to the Google Groups "python-doit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-doit...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/python-doit/1aeac775-07a8-4dd9-9146-d67e7468574bn%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages