Hey yall. Is there a way to get the address of the...
# general
d
Hey yall. Is there a way to get the address of the caller in a macro?
h
Like the BUILD file path? The caller doesn't have an address
d
Yes like the BUILD file path
I guess I really meant the definition site calling BUILD address
h
There is not in the current macro system, but it's feasible to add I think. Would need a design for how the user accesses the symbol - probably with a top-level symbol like
buildroot()
? Mind sharing the motivation?
d
Ah yes. At a high-level, the motivation is to provide clean packaging macros, reduce boilerplate, and practice DRY Here is a concrete use case. Say I want to package a spark job into a PEX. But at the same time, I need to define a YAML file to let another system know that there is a new job PEX. (The YAML would also contain a bunch of additional configs). My build file look something like
Copy code
spark_job(
    name="job",
    source="entrypoint.py",
    pex_name="path.to.src.python.my.job.pex",
    cluster_config={...},
    ...
)
Currently I need to specify the pex_name because other wise the job submit system won't know where to find the PEX. With a
buildroot()
, I can easily generate the
pex_name
in my macro
Similar concepts applies to service config generation; think building dockers out of pants and creating deploy targets to k8s. The goal is that I need a way to get the output file path of a target in a macro,
buildroot()
is just a mean to it.