pants: Survive targets without derivations

Review Request #1066 — Created Sept. 23, 2014 and submitted

stuhood
pants
a2625d5...
pants-reviews
areitz, benjyw, jsirois

Walks the full derivation chain for a target (which in the case of a particular target type at Twitter will be 3 entries long.)

Rather than:

Exception caught:
  File "src/python/pants/bin/pants_exe.py", line 205, in <module>
    main()
  File "src/python/pants/bin/pants_exe.py", line 200, in main
    _run()
  File "src/python/pants/bin/pants_exe.py", line 181, in _run
    result = command.run(lock)
  File "src/python/pants/commands/goal_runner.py", line 295, in run
    return engine.execute(context, self.goals)
  File "src/python/pants/engine/engine.py", line 48, in execute
    self.attempt(context, goals)
  File "src/python/pants/engine/round_engine.py", line 184, in attempt
    goal_executor.attempt(explain)
  File "src/python/pants/engine/round_engine.py", line 42, in attempt
    task.execute()
  File "src/python/pants/backend/jvm/tasks/jar_publish.py", line 523, in execute
    self.check_targets(exported_targets)
  File "src/python/pants/backend/jvm/tasks/jar_publish.py", line 760, in check_targets
    derived_target = derived_by_target[invalid_target]

Exception message: ScalaLibrary(SyntheticAddress(.pants.d/gen/scrooge/scrooge/scala-finagle:.pants.d.gen.idl-extract.3rdparty.jvm.com.twitter.<snip>))

...you get:

FAILURE: The following errors must be resolved to publish.
  Cannot publish BuildFileAddress(x/y/src/main/scala/BUILD, scala) due to:
    SyntheticAddress(.pants.d/gen/idl-extract/3rdparty.jvm.com.twitter.<snip>) - Does not provide a binary artifact.
  • 0
  • 0
  • 0
  • 1
  • 1
Description From Last Updated
IT
  1. Ship It!

  2. 
      
ST
  1. After more consideration, this is probably related to the TODO immediately above the fix. Will make that fix instead.

    1. +1
      A Target.family() or Target.derivation_chain() helper may be in order - Andy's new publish stuff would use it as well.

  2. 
      
ST
JS
  1. 
      
  2. src/python/pants/base/target.py (Diff revision 2)
     
     

    Low-hanging fruit for a unit test. There is maybe more than meets the eye since https://github.com/pantsbuild/pants/blob/master/src/python/pants/base/target.py#L399

    That said, we currently have the idea of 1 BuildGraph and dependency edges are modeled with an adjacency list so eq is not exercised in practice except for maybe in tests.

  3. 
      
PA
  1. If this is fixing a known bug, it merits a test.

  2. Almost certainly not what you want. Are you familiar with the graph-trimming properties of the predicate argument to Target.walk?

    1. This is existing code: I just reformatted it.

    2. I see that, but it's still very likely extremely wrong. If you're fixing up this code, you should fix that too.

    3. Not sure I agree... if you think this behaviour is broken, it merits an independent review. This review fixes a much smaller issue which was labeled with a TODO.

    4. Okay, dropping for now, and I reraised this issue on the original CR. Someone familiar with the exact semantics of this code should take a look. I might open up an issue to just eliminate predicate= as an argument entirely, or possibly change the semantics of it if we eliminate all other uses of it first.

  3. 
      
ST
PA
  1. 
      
  2. src/python/pants/base/target.py (Diff revision 3)
     
     

    I prefer more descriptive variable names

  3. 
      
PA
  1. Since this was submitted at 5645f5ff8e59e6f628066417866526960a21c8da, please mark it as such.

  2. 
      
ST
Review request changed

Status: Closed (submitted)

Loading...