Skip to content

Conversation

@jrichardlai
Copy link
Contributor

@jrichardlai jrichardlai commented Nov 26, 2024

What

Add lazy option to outputs to delay execution of output if not needed in all situation where the op is called.

Example:

class MyOp < ::Subroutine::Op

  outputs :heavy_operation, lazy: true

  protected

  def perform
    output :heavy_operation, -> { some_heavy_operation }
  end

  def some_heavy_operation
    # ...
  end

end

end

outputs[name] = value
outputs[name] = output_configurations[name].lazy? ? LazyExecutor.new(value) : value
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this will mess with op_instance.outputs (which is a hash of all the outputs)

maybe outputs can be a method that calls any lazy outputs for backwards compatibility?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks updated

@jrichardlai jrichardlai force-pushed the lazy-output branch 3 times, most recently from cbabd9e to 6948d35 Compare November 27, 2024 18:05
@jrichardlai jrichardlai merged commit 6494468 into main Jan 31, 2025
2 checks passed
@jrichardlai jrichardlai deleted the lazy-output branch January 31, 2025 22:12
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.

4 participants