hey folks wondering if you can help me out here, i...
# general
w
hey folks wondering if you can help me out here, i have a BUILD file, that contains the following (databricks_job is a custom target) and im getting an ambiguous owner error
Copy code
FAILURE: Owners for Resources(BuildFileAddress(src/adobe_mta/BUILD, config)) are ambiguous.  Found DatabricksJob(BuildFileAddress(src/adobe_mta/BUILD, job)) and 1 others: [PythonLibrary(BuildFileAddress(src/adobe_mta/BUILD, lib))]
Any advice?
Making some progress here. The
DatabricksJob
extends
PythonLibrary
when it isn't really a lib. This was a design decision we made to force the building of the library that the job depends on before deploying it. We weren't really thrilled with that solution but it seemed to work for the time being. How would we configure a Target to build/publish its dependent libs when being triggered?
r
Interesting rabbit hole! From the code, it looks like the function that raises this raises:
Copy code
:raises: `AmbiguousOwnerError` if there is more than one viable exported owner target for a
             given transitive dependency.
Now, this would indicate that both
:lib
and
:job
are exported. I don’t see the code that makes
python_library
exported by default, but let’s assume it is for now. The code that raises that exception (https://github.com/blorente/pants/blob/998e4edbe31c64aeacac5142ad90433fce9a748b/src/python/pants/backend/python/tasks/setup_py.py#L187) iterates not only over the dependency chain, but also over the siblings to calculate potential owners (this function call https://github.com/blorente/pants/blob/master/src/python/pants/backend/python/tasks/setup_py.py#L243, which calls this method: https://github.com/blorente/pants/blob/998e4edbe31c64aeacac5142ad90433fce9a748b/src/python/pants/backend/python/tasks/setup_py.py#L73)
w
hmmmm good looking out, i'll dig into this source
thanks!
r
It’s mostly to keep track myself, but yeah, might give you some clues maybe
w
yeah been swimming in that file for a minute now
thanks again, I'll report back with any interesting findings
r
Cool! Hope you find what you need 🙂
w
so i was able to achieve the results i need by switching https://github.com/pantsbuild/pants/blob/12711f2dc295fdda526cf9fab17146b87154ed08/src/python/pants/backend/python/tasks/setup_py.py#L699 to use
self.context.targets()
when
self._recursive
was set
wonder if that's a change the maintainers might approve
r
It seems sane in this case, but I’m not the most qualified to think about all the ramifications, no too familiar with this part of the code. If you open a PR, I can add reviewers to it 🙂
w
thanks, will do
@red-balloon-89377 just added you: https://github.com/pantsbuild/pants/pull/9035 if you could tage relevant folks it would be appreciated
r
Added 🙂
f
Borja added me as reviewer. I don’t mind the code change, but don’t feel confident that I would catch subtle pitfalls that it may introduce, so will let a greyer beard chime-in 😄
w
yeah im definitely making some assumptions here. FWIW changing it locally seemed to cause no issues, but haven't really run it through its paces. However, seems reasonable that if recursive mode was on, it would package all those things up anyway
Appreciate the once-over
h
I'm a little surprised at this error - it implies that
:lib
and
:job
are both candidates to be the owner of
:config
, but AFAIK an owner has to be exported (that is, has to have a
provides=
clause), and neither of those do in your example. Did you elide those out of the example? I assume you were running
./pants setup-py [target]
?
w
yes they were elided. the
:job
gets a summy setup-py as its not really a python library. The PR i have outstanding allows us to stop subclassing the job as a library and still trigger dependent libs' build and publish steps