Skip to content
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

TargetDefinitionException when using globs with resources= in a PythonLibrary #3506

Closed
kwlzn opened this issue May 26, 2016 · 8 comments
Closed
Assignees

Comments

@kwlzn
Copy link
Member

kwlzn commented May 26, 2016

with a target like:

python_library(
  ...
  sources = rglobs('*.py'),
  resources = rglobs('*.yaml', '*.zip'),
  dependencies = [...]
)

the following error is seen on a ./pants --enable-v2-engine list:

Exception caught: (<class 'pants.base.exceptions.TargetDefinitionException'>)
  File ".../src/python/pants/bin/pants_exe.py", line 50, in <module>
    main()
  File ".../src/python/pants/bin/pants_exe.py", line 44, in main
    PantsRunner(exiter).run()
  File ".../src/python/pants/bin/pants_runner.py", line 56, in run
    options_bootstrapper=options_bootstrapper)
  File ".../src/python/pants/bin/pants_runner.py", line 46, in _run
    return LocalPantsRunner(exiter, args, env, options_bootstrapper=options_bootstrapper).run()
  File ".../src/python/pants/bin/local_pants_runner.py", line 53, in run
    self._maybe_profiled(self._run)
  File ".../src/python/pants/bin/local_pants_runner.py", line 50, in _maybe_profiled
    runner()
  File ".../src/python/pants/bin/local_pants_runner.py", line 93, in _run
    self._exiter).setup()
  File ".../src/python/pants/bin/goal_runner.py", line 84, in __init__
    build_graph)
  File ".../src/python/pants/bin/goal_runner.py", line 99, in _select_buildgraph
    return graph_helper.create_graph(root_specs)
  File ".../src/python/pants/bin/engine_initializer.py", line 64, in create_graph
    for _ in graph.inject_specs_closure(spec_roots):  # Ensure the entire generator is unrolled.
  File ".../src/python/pants/engine/legacy/graph.py", line 163, in inject_specs_closure
    for address in self._inject(specs):
  File ".../src/python/pants/engine/legacy/graph.py", line 182, in _inject
    self._index(legacy_target_roots)
  File ".../src/python/pants/engine/legacy/graph.py", line 72, in _index
    new_targets.append(self._index_target(state.value))
  File ".../src/python/pants/engine/legacy/graph.py", line 102, in _index_target
    target = self._instantiate_target(legacy_target.adaptor)
  File ".../src/python/pants/engine/legacy/graph.py", line 131, in _instantiate_target
    'Failed to instantiate Target with type {}: {}'.format(target_cls, e))

Exception message: Invalid target .../xyz:xyz-lib: Failed to instantiate Target with type <class 'pants.backend.python.targets.python_library.PythonLibrary'>: create_fileset_with_spec() argument after * must be a sequence, not RGlobs

commenting out the resources = rglobs('*.yaml', '*.zip') eliminates the error.

@kwlzn kwlzn added the engine label May 26, 2016
@baroquebobcat
Copy link
Contributor

From the code for python_target, I was under the impression that we were getting rid of resources= on python targets. Also, does anyone use the resource_targets kwarg?

@kwlzn
Copy link
Member Author

kwlzn commented May 27, 2016

hmm, afaik resources= is heavily used in python targets in our monorepo. is resource_targets= the intended replacement?

@baroquebobcat
Copy link
Contributor

There's a comment, but it never got documented, so I'd guess not.

@stuhood stuhood self-assigned this May 31, 2016
@stuhood
Copy link
Member

stuhood commented May 31, 2016

A big push in the area of deprecating resources isn't a good idea right now, because in the engine experiments, it became pretty clear that you don't actually need target types once you're consuming products by type... could just have a target with both python and resources sources to resolve this.

EDIT: Opened #3560 on this topic.

@stuhood
Copy link
Member

stuhood commented Jun 3, 2016

Will work on this today.

@stuhood
Copy link
Member

stuhood commented Jun 7, 2016

Reviewable here: https://rbcommons.com/s/twitter/r/3979/ ... also, found #3563, as mentioned above.

stuhood added a commit that referenced this issue Jun 7, 2016
This fixes [#3506](#3506), which is caused by our conversion of the `globs/rglobs` objects without capturing them later.

- Capture the `resources=globs` argument for Python targets
- Open tickets to design the migration path to typed Sources

Testing Done:
http://jenkins.pantsbuild.org/job/pantsbuild/job/pants/branch/PR-3566/2/

Bugs closed: 3506, 3566

Reviewed at https://rbcommons.com/s/twitter/r/3979/
@stuhood
Copy link
Member

stuhood commented Jun 7, 2016

Merged as 04e4457

@stuhood
Copy link
Member

stuhood commented Jun 28, 2016

7a63b45

@stuhood stuhood closed this as completed Jun 28, 2016
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

No branches or pull requests

3 participants