Skip to content

Raise better error when input is not an IVar #477

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

schneems
Copy link
Contributor

@schneems schneems commented Dec 3, 2015

This will show the values received such as:

rgumentError: Not all dependencies are IVars.
Dependencies: [false]
/Users/richardschneeman/.gem/ruby/2.3.0/gems/concurrent-ruby-1.0.0/lib/concurrent/dataflow.rb:61:in `call_dataflow'
/Users/richardschneeman/.gem/ruby/2.3.0/gems/concurrent-ruby-1.0.0/lib/concurrent/dataflow.rb:40:in `dataflow_with'
/Users/richardschneeman/.gem/ruby/2.3.0/gems/concurrent-ruby-1.0.0/lib/concurrent/dataflow.rb:35:in `dataflow'
/Users/richardschneeman/Documents/projects/sprockets/lib/sprockets/manifest.rb:203:in `block in compile'
/Users/richardschneeman/Documents/projects/sprockets/lib/sprockets/manifest.rb:131:in `block (2 levels) in find'
/Users/richardschneeman/Documents/projects/sprockets/lib/sprockets/base.rb:76:in `find_all_linked_assets'
/Users/richardschneeman/Documents/projects/sprockets/lib/sprockets/manifest.rb:130:in `block in find'
/Users/richardschneeman/Documents/projects/sprockets/lib/sprockets/manifest.rb:129:in `each'
/Users/richardschneeman/Documents/projects/sprockets/lib/sprockets/manifest.rb:129:in `find'
/Users/richardschneeman/Documents/projects/sprockets/lib/sprockets/manifest.rb:164:in `compile'
/Users/richardschneeman/.gem/ruby/2.3.0/bundler/gems/sprockets-rails-ad4a43bd1bb1/lib/sprockets/rails/task.rb:68:in `block (3 levels) in define'
/Users/richardschneeman/Documents/projects/sprockets/lib/rake/sprocketstask.rb:147:in `with_logger'
/Users/richardschneeman/.gem/ruby/2.3.0/bundler/gems/sprockets-rails-ad4a43bd1bb1/lib/sprockets/rails/task.rb:67:in `block (2 levels) in define'


def call_dataflow(method, executor, *inputs, &block)
raise ArgumentError.new('an executor must be provided') if executor.nil?
raise ArgumentError.new('no block given') unless block_given?
raise ArgumentError.new('not all dependencies are IVars') unless inputs.all? { |input| input.is_a? IVar }
not_ivars = inputs.map { |input| !input.is_a? IVar }
unless not_ivars.empty?
Copy link
Member

Choose a reason for hiding this comment

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

@schneems Thank you for taking the time to work on this update. There are several failing tests we need to look into. I haven't had an opportunity to pull the code and run the tests locally, but I believe this line is the culprit. Won't the #map function create an array with a number of elements equal to the size of the inputs array? I think #empty? will always return false in this case. Can you please take a look?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that should have been a select, it was right locally but not committed. I'm updating to not allocate an array on every run, will preserve the original logic.

@schneems schneems force-pushed the schneems/better-ivar-error-message branch from 02e2861 to 6a8e4a1 Compare December 3, 2015 12:50
This will show the values received such as:


```
rgumentError: Not all dependencies are IVars.
Dependencies: [false]
/Users/richardschneeman/.gem/ruby/2.3.0/gems/concurrent-ruby-1.0.0/lib/concurrent/dataflow.rb:61:in `call_dataflow'
/Users/richardschneeman/.gem/ruby/2.3.0/gems/concurrent-ruby-1.0.0/lib/concurrent/dataflow.rb:40:in `dataflow_with'
/Users/richardschneeman/.gem/ruby/2.3.0/gems/concurrent-ruby-1.0.0/lib/concurrent/dataflow.rb:35:in `dataflow'
/Users/richardschneeman/Documents/projects/sprockets/lib/sprockets/manifest.rb:203:in `block in compile'
/Users/richardschneeman/Documents/projects/sprockets/lib/sprockets/manifest.rb:131:in `block (2 levels) in find'
/Users/richardschneeman/Documents/projects/sprockets/lib/sprockets/base.rb:76:in `find_all_linked_assets'
/Users/richardschneeman/Documents/projects/sprockets/lib/sprockets/manifest.rb:130:in `block in find'
/Users/richardschneeman/Documents/projects/sprockets/lib/sprockets/manifest.rb:129:in `each'
/Users/richardschneeman/Documents/projects/sprockets/lib/sprockets/manifest.rb:129:in `find'
/Users/richardschneeman/Documents/projects/sprockets/lib/sprockets/manifest.rb:164:in `compile'
/Users/richardschneeman/.gem/ruby/2.3.0/bundler/gems/sprockets-rails-ad4a43bd1bb1/lib/sprockets/rails/task.rb:68:in `block (3 levels) in define'
/Users/richardschneeman/Documents/projects/sprockets/lib/rake/sprocketstask.rb:147:in `with_logger'
/Users/richardschneeman/.gem/ruby/2.3.0/bundler/gems/sprockets-rails-ad4a43bd1bb1/lib/sprockets/rails/task.rb:67:in `block (2 levels) in define'
```
@schneems schneems force-pushed the schneems/better-ivar-error-message branch from 6a8e4a1 to 91c5f04 Compare December 3, 2015 13:08
@schneems
Copy link
Contributor Author

schneems commented Dec 3, 2015

Updated to use the original logic, instead of only showing the non conforming inputs, we can easily show all of the inputs. By not using a select we can avoid allocating an array so speed wont be impacted.

@schneems schneems mentioned this pull request Dec 3, 2015
@schneems
Copy link
Contributor Author

schneems commented Dec 3, 2015

Tests are back to passing

@lucasallan
Copy link
Member

👍

jdantonio added a commit that referenced this pull request Dec 8, 2015
Raise better error when input is not an IVar
@jdantonio jdantonio merged commit 280d9d0 into ruby-concurrency:master Dec 8, 2015
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.

3 participants