Skip to content

Conversation

arminsumo
Copy link

@arminsumo arminsumo commented Sep 5, 2025

Improve the documentation around Anonymous Tasks, and give some extra examples of complex task usage.
addresses #5812

@arminsumo arminsumo force-pushed the document-more-complex-task-usecases branch from 96ba435 to 465fe94 Compare September 5, 2025 14:57
@arminsumo arminsumo force-pushed the document-more-complex-task-usecases branch from 465fe94 to 025a6ed Compare September 5, 2025 14:57
@arminsumo
Copy link
Author

I also discovered a potential bug during this. If that is actually intended behavior, I can include it in the documentation
#5812 (comment)

@@ -23,6 +23,9 @@ def printFileData(fileName: String) = Task.Command {
// anywhere and passed around any way you want, until you finally make use of them
// within a downstream task or command.
//
// Anonymous tasks work well when parameters are known at task definition time. Dynamically
// generated inputs can not be used with Anonymous Tasks, as this would break caching.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"as this would break caching." is wrong. It's not about caching, but definition/dependency order.

Since we need to know the parameters before creating the task, but the tasks need to be created before we can start evaluation, we have a classic hen-or-egg problem.

Copy link
Member

@lefou lefou Sep 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are three strategies to resolve this:

  • define the values outside of a task, so Mill knows how to create the anonymous tasks before evaluation starts
  • put the value itself into a task, so it can be properly ordered to be evaluated before it's dependencies
  • Make it not a task but a normal def

@arminsumo arminsumo requested a review from lefou September 8, 2025 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants