fresh-cat-90827
06/27/2021, 8:09 AMdocformatter
one and tweaking it to use vulture
. All works fine — there is a lot to learn, but I think the approach taken when structuring plugin code is fairly intuitive for a newcomer.
I have a specific question about the flake8
linter available out-of-the-box with Pants. The nice thing about flake8
is that there are tons of plugins (https://github.com/DmytroLitvinov/awesome-flake8-extensions#clean-code) which means that after installing any of those into a Python environment that has flake8
installed, those plugins will be picked up by the flake8
and their rules will run as well.
I wonder what would be a smart thing to do to bring flake8
plugins support in Pants into my monorepo? The flake8
requirement is specified at https://github.com/pantsbuild/pants/blob/release_2.5.1rc3/src/python/pants/backend/python/lint/flake8/subsystem.py#L18 so I wonder how could I extend it to use multiple flake8
plugins (each being a PyPI package) when ./pants lint
goal is run?witty-crayon-22786
07/09/2021, 4:28 PMwitty-crayon-22786
07/09/2021, 4:28 PMwitty-crayon-22786
07/09/2021, 4:29 PMwitty-crayon-22786
07/09/2021, 4:29 PMwitty-crayon-22786
07/09/2021, 4:29 PMwitty-crayon-22786
07/09/2021, 4:29 PMwitty-crayon-22786
07/09/2021, 4:29 PMwitty-crayon-22786
07/09/2021, 4:29 PMfresh-cat-90827
07/10/2021, 9:16 PMcurved-television-6568
07/15/2021, 5:14 PMaverage-australia-85137
07/21/2021, 4:04 PMGet
and then exiting)
@rule(level=LogLevel.DEBUG)
async def package_into_image(
field_set: DockerPackageFieldSet,
union_membership: UnionMembership,
) -> BuiltPackage:
target_name = field_set.address.target_name
transitive_targets = await Get(
TransitiveTargets, TransitiveTargetsRequest([field_set.address])
)
for t in transitive_targets.dependencies:
if type(t) is RelocatedFiles:
s = await Get(
SourceFiles,
SourceFilesRequest,
SourceFilesRequest(
sources_fields=[t.get(Sources)],
for_sources_types=[RelocatedFilesSources],
)
)
<http://logger.info|logger.info>('relocated files: %s', s.snapshot.files)
return BuiltPackage(
digest=s.snapshot.digest,
artifacts=([BuiltPackageArtifact(f, ()) for f in s.snapshot.files]),
)
has output:
[nate@ragin-cajun pants-docker]$ ./pants package test_docker:dockerized_flask_app
12:04:18.11 [INFO] relocated files: ()
curved-television-6568
07/22/2021, 9:01 AMexample-python
repo, and manage to run a local built version of pants
. However, when I try to load in the experimental docker package, it fails…fresh-cat-90827
07/24/2021, 3:57 PMdebian_package
that would let users create a Debian package from a PEX file. This has been my preferred way to distribute PEX files so far. I package PEX files and then run a few lines of Bash that produce Debian packages as part of the CI pipeline.
However, I think it could have been a useful feature to have available OOTB as another binary artifact target so that people don’t need to rely on custom shell scripts. I’ve described the idea in here: https://github.com/pantsbuild/pants/issues/12421. Keen to know what you think.brave-advantage-95797
07/26/2021, 7:05 PMproud-dentist-22844
08/04/2021, 2:18 PMGoalSubsystem
, how can I iterate over the options (in my @goal_rule
)? subsystem.options
I want to get all of the options registered for my subsystem that have modified values.witty-crayon-22786
08/07/2021, 5:13 PMterraform
backend? is it usable?ambitious-actor-36781
08/10/2021, 3:40 AM--no-dynamic-ui
ambitious-actor-36781
08/10/2021, 7:31 AMDockerfile
, files from any other unbuilt dependencies, a and the outputs of other package
targets. (minimal requirement is a .pex
file, and a .sh
script built into an image)
Have gotten the latter working and running find
inside a chroot reveals the .pex
file (great!)
.
./examples.docker_image
./examples.docker_image/hello-world.pex'
Struggling to get the former bits working, and I've tried enough things from the examples in the docs I'm a bit lost.
WIP code here: https://github.com/xlevus/pants2-plugins/pull/1/filesambitious-actor-36781
08/10/2021, 10:15 PMProcesResult
by giving it a Process
input is from reading the docs.witty-crayon-22786
08/17/2021, 6:32 PMrapid-bird-79300
08/20/2021, 11:03 PMfind_needle
plugin in the testing docs and pushed an example here: https://github.com/njgrisafi/pants-example/tree/find-needle
getting a test error:
request = HydrateSourcesRequest(field=<class 'pants.engine.target.Sources'>(alias='sources', address=//:t1, value={repr(self.value)}, default={repr(self.default)}), for_sources_types=(<class 'pants.engine.target.Sources'>,), enable_codegen=False)
def mock_hydrate_sources(request: HydrateSourcesRequest) -> HydratedSources:
# Our rule only looks at `HydratedSources.snapshot.files`, so we mock all other fields. We
# include the file `needle.txt` for the target `:t2`, but no other targets.
files = (
("needle.txt", "foo.txt")
if request.field.address.target_name == "t2"
else ("foo.txt", "bar.txt")
)
> mock_snapshot = Snapshot(EMPTY_DIGEST, files=files, dirs=())
E TypeError: PySnapshot.__new__()() takes at most 0 arguments (3 given)
Any ideas why this is?average-australia-85137
08/24/2021, 8:30 PMaverage-australia-85137
09/01/2021, 4:30 PMsendwave
module? this seems like i’ve just done something very dumb again but i’ve been brushing up against it all morning… anyway if anyone has any ideas I could use a fresh set of eyesaverage-australia-85137
09/01/2021, 4:31 PMambitious-actor-36781
09/03/2021, 12:36 AMrequests
looks good
[TwinePublishRequest(package_field_set=PythonDistributionFieldSet(address=Address(examples/pypi_repository:example_package), provides=<class 'pants.backend.python.target_types.PythonProvidesField'>(alias='provides', value=<pants.backend.python.macros.python_artifact.PythonArtifact object at 0x7f9ff81a2e80>, default=None)), field_set=TwineFieldSet(address=Address(examples/pypi_repository:example_package)))]
but when I get to oof
I get:
12:32:01.88 [ERROR] Encountered 5 rule graph errors:
No installed rules return the type PrePublishRequest, and it was not provided by potential callers of @rule(xlvs.pants.publish.publish_subsystem:51:to_publish_request(PrePublishRequest) -> PublishRequest, gets=[Get(BuiltPackage, ArchiveFieldSet), Get(BuiltPackage, PexBinaryFieldSet), Get(BuiltPackage, PythonDistributionFieldSet), Get(BuiltPackage, DockerImageFieldSet)]).
If that type should be computed by a rule, ensure that that rule is installed.
If it should be provided by a caller, ensure that it is included in any relevant Query or Get.
No source of dependency Get(BuiltPackage, ArchiveFieldSet) for @rule(xlvs.pants.publish.publish_subsystem:51:to_publish_request(PrePublishRequest) -> PublishRequest, gets=[Get(BuiltPackage, ArchiveFieldSet), Get(BuiltPackage, PexBinaryFieldSet), Get(BuiltPackage, PythonDistributionFieldSet), Get(BuiltPackage, DockerImageFieldSet)]). All potential sources were eliminated: []
No source of dependency Get(BuiltPackage, DockerImageFieldSet) for @rule(xlvs.pants.publish.publish_subsystem:51:to_publish_request(PrePublishRequest) -> PublishRequest, gets=[Get(BuiltPackage, ArchiveFieldSet), Get(BuiltPackage, PexBinaryFieldSet), Get(BuiltPackage, PythonDistributionFieldSet), Get(BuiltPackage, DockerImageFieldSet)]). All potential sources were eliminated: []
No source of dependency Get(BuiltPackage, PexBinaryFieldSet) for @rule(xlvs.pants.publish.publish_subsystem:51:to_publish_request(PrePublishRequest) -> PublishRequest, gets=[Get(BuiltPackage, ArchiveFieldSet), Get(BuiltPackage, PexBinaryFieldSet), Get(BuiltPackage, PythonDistributionFieldSet), Get(BuiltPackage, DockerImageFieldSet)]). All potential sources were eliminated: []
No source of dependency Get(BuiltPackage, PythonDistributionFieldSet) for @rule(xlvs.pants.publish.publish_subsystem:51:to_publish_request(PrePublishRequest) -> PublishRequest, gets=[Get(BuiltPackage, ArchiveFieldSet), Get(BuiltPackage, PexBinaryFieldSet), Get(BuiltPackage, PythonDistributionFieldSet), Get(BuiltPackage, DockerImageFieldSet)]). All potential sources were eliminated: []
I'm not requesting a PrePublishRequest
?? I'm doing Get(PublishRequest, PrePublishRequest, request)
[edit] Solvedcurved-television-6568
09/03/2021, 10:36 AMFileContent
I happened to pass a str
rather than bytes
. What happens was…. deadlock (or something, the tests time out). No warning or nothing. I’m sure mypy would catch this, but it took me a while to figure out why it wouldn’t work.. (as an empty string worked just fine, but that’s most likely an edge case, then…)curved-television-6568
09/03/2021, 2:48 PMpants_requirement
for plugins to be a bit too narrow for our use case. Locking down each version of the plugin to a single pants version is a bit hard.. I’d like a little more flexibility, so I opted for:
#pants_requirement(name="pants", dist="pantsbuild.pants")
python_requirement_library(
name="pants",
requirements=["pantsbuild.pants >=2.6.0, <3.0"],
module_mapping={
"pantsbuild.pants": ["pants"],
},
)
Instead.. sure enough, if there are breaking changes before 3.0, we’ll have to address them, but this will at least not require us to release a new version of the plugin for every pants release.
Am I missing something, like, do I shoot my self horrible in the foot by doing this?
(it is not a in-repo plugin, but stand alone, pushed to a cheese chop registry)ambitious-actor-36781
09/06/2021, 2:32 AMpants publish
I've got it to the point that it 'works' and can push python_distribution
targets to pypi_repository
targets.
would be great if someone could spare a few minutes to sanity-check it,
https://github.com/xlevus/pants2-plugins/pull/2/filesambitious-actor-36781
09/07/2021, 2:15 AMNo installed rules return the type DockerPublishRequest, and it was not provided by potential callers of @rule(xlvs.pants.publish.docker.docker_push:8:publish_docker_image(DockerPublishRequest) -> PublishedPackageSet).
If that type should be computed by a rule, ensure that that rule is installed.
If it should be provided by a caller, ensure that it is included in any relevant Query or Get.
No installed rules return the type PypiPublishRequest, and it was not provided by potential callers of @rule(xlvs.pants.publish.aws_s3.s3_upload:7:upload_s3(PypiPublishRequest) -> PublishedPackageSet).
If that type should be computed by a rule, ensure that that rule is installed.
If it should be provided by a caller, ensure that it is included in any relevant Query or Get.
Yet, with the MultiGet
call uncommented,
my prints are:
>> DockerPublishRequest(built_package=BuiltPackage(digest=Digest('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', 0), artifacts=()), fieldset=DockerPublishFieldSet(address=Address(examples/container_registry:image)))
Publishing 'examples/pypi_repository:example_package' to 'examples/pypi_repository:privatepypi'.
>> PypiPublishRequest(built_package=BuiltPackage(digest=Digest('66de45797a5ab5514223ade6a42dfd721b0099cf27860cc8a66c15eba606b3b3', 105), artifacts=(BuiltPackageArtifact(relpath='xlvs-pants2-pypi-example-0.0.1', extra_log_lines=()),)), fieldset=PublishTargetFieldSet(address=Address(examples/pypi_repository:example_package)))
Publishing 'examples/pypi_repository:example_package' to 'examples/pypi_repository:s3_bucket'.
>> S3PublishRequest(built_package=BuiltPackage(digest=Digest('66de45797a5ab5514223ade6a42dfd721b0099cf27860cc8a66c15eba606b3b3', 105), artifacts=(BuiltPackageArtifact(relpath='xlvs-pants2-pypi-example-0.0.1', extra_log_lines=()),)), fieldset=PublishTargetFieldSet(address=Address(examples/pypi_repository:example_package)))
FrozenOrderedSet([<class 'xlvs.pants.publish.python.targets.PypiPublishRequest'>, <class 'xlvs.pants.publish.docker.targets.DockerPublishRequest'>, <class 'xlvs.pants.publish.aws_s3.targets.S3PublishRequest'>])
Which looks like:
• My publish_request
type are the right subclasses.
• my PublishRequest
subclasses are a part of the UnionMembership