green-match-60388
09/21/2023, 9:40 PMpublish
goal with a new target, airflow_composer_dag
. essentially our workflow with airflow is:
• write a CLI tool in python
• containerize it(docker)
• push to GCR(google cloud registry) or GAR(google artifact registry)
• rsync our dag files/directories(gsutil/gcloud) to GCS
◦ those dag reference and utilize the container from the previous steps
• profit
so, first step was a macro that does the python_source
, pex_binary
, and docker_image
with just one definition. but then i need to "publish" the dag definitions(rsync some python and directories).
so, i think a plugin is the next logical step. start writing a plugin to extend publish
and boy am i lost. got it to where i can add the custom target airflow_composer_dag
to a BUILD
and pants publish src/py/thing:dag
doesn't complain, but the publish
also doesn't do anything. never seems to call my rule
.
source is in the thread. 🧵green-match-60388
09/21/2023, 9:41 PMgreen-match-60388
09/21/2023, 9:43 PMpants publish src/py/thing:dag
could be a file()
target or something similar.gorgeous-winter-99296
09/21/2023, 9:50 PMdef rules():
return [
*collect_rules(),
UnionRule(PublishFieldSet, PublishImageFieldSet),
UnionRule(PublishRequest, PublishImageRequest),
]
With the following definitons:
@dataclass(frozen=True)
class PublishImageRequest(PublishRequest):
pass
@dataclass(frozen=True)
class PublishImageFieldSet(PublishFieldSet):
publish_request_type = PublishImageRequest
required_fields = (
ImageRepository,
ImageTag,
)
repository: ImageRepository
tag: ImageTag
def get_output_data(self) -> PublishOutputData:
return PublishOutputData(
{
"publisher": "skopeo",
**super().get_output_data(),
}
)
Similarly, for packaging:
def rules():
return [
*collect_rules(),
UnionRule(PackageFieldSet, ImageFieldSet),
]
And
@dataclass(frozen=True)
class ImageFieldSet(PackageFieldSet):
required_fields = (ImageRepository,)
repository: ImageRepository
tag: ImageTag
output_path: OutputPathField
digest: ImageDigest
All taken from my OCI plugin, which is at least working well enough for our production uses. https://github.com/tgolsson/pants-backends/tree/main/pants-plugins/oci/pants_backend_oci/goalsgorgeous-winter-99296
09/21/2023, 9:51 PMgorgeous-winter-99296
09/21/2023, 9:53 PMpackage
followed by bash
-scripts. I've personally had uses for a GCS syncer, so if that's what this would be I'd also be interested in using it. 🙂gorgeous-winter-99296
09/21/2023, 9:57 PMgreen-match-60388
09/21/2023, 9:58 PMgorgeous-winter-99296
09/21/2023, 10:00 PM--no-pantsd --no-local-cache
to avoid those pitfalls. Now off for real. :Dgreen-match-60388
09/21/2023, 10:14 PMskopeo
and stuff.