Hey, trying to write some tests for my plugin - ho...
# general
r
Hey, trying to write some tests for my plugin - how do I use a subsystem in the rule runner? I'm following the guide here: https://www.pantsbuild.org/docs/rules-api-testing#approach-3-rulerunner-integration-tests-for-rules
w
in general there should not be any explicit steps necessary to use a Subsystem…
rule_runner.request
will have access to subsystems required by the
@rules
you are running.
are you seeing an error?
h
There are many examples in the Pants repo, if you grep for
rule_runner.request
r
Getting rule graph errors:
Copy code
E       ValueError: Encountered 7 rule graph errors:
E         No installed rules return the type DagsterLocationConfigFieldSet, and it was not provided by potential callers of @rule(plugins.dagster.goals:65:package_locations(DagsterLocationConfigFieldSet, DagsterSubsystem, UnionMembership, DistDir) -> BuiltPackage, gets=[Get(Digest, [PathGlobs]), Get(DigestContents, [Digest]), Get(Digest, [CreateDigest])]).
E           If that type should be computed by a rule, ensure that that rule is installed.
E           If it should be provided by a caller, ensure that it is included in any relevant Query or Get.
E         No installed rules return the type DistDir, and it was not provided by potential callers of @rule(plugins.dagster.goals:65:package_locations(DagsterLocationConfigFieldSet, DagsterSubsystem, UnionMembership, DistDir) -> BuiltPackage, gets=[Get(Digest, [PathGlobs]), Get(DigestContents, [Digest]), Get(Digest, [CreateDigest])]).
E           If that type should be computed by a rule, ensure that that rule is installed.
E           If it should be provided by a caller, ensure that it is included in any relevant Query or Get.
E         No source of dependency DagsterSubsystem for @rule(plugins.dagster.goals:65:package_locations(DagsterLocationConfigFieldSet, DagsterSubsystem, UnionMembership, DistDir) -> BuiltPackage, gets=[Get(Digest, [PathGlobs]), Get(DigestContents, [Digest]), Get(Digest, [CreateDigest])]). All potential sources were eliminated: []
E         No source of dependency Get(Digest, [CreateDigest]) for @rule(plugins.dagster.goals:65:package_locations(DagsterLocationConfigFieldSet, DagsterSubsystem, UnionMembership, DistDir) -> BuiltPackage, gets=[Get(Digest, [PathGlobs]), Get(DigestContents, [Digest]), Get(Digest, [CreateDigest])]). All potential sources were eliminated: []
E         No source of dependency Get(Digest, [PathGlobs]) for @rule(plugins.dagster.goals:65:package_locations(DagsterLocationConfigFieldSet, DagsterSubsystem, UnionMembership, DistDir) -> BuiltPackage, gets=[Get(Digest, [PathGlobs]), Get(DigestContents, [Digest]), Get(Digest, [CreateDigest])]). All potential sources were eliminated: []
E         No source of dependency Get(DigestContents, [Digest]) for @rule(plugins.dagster.goals:65:package_locations(DagsterLocationConfigFieldSet, DagsterSubsystem, UnionMembership, DistDir) -> BuiltPackage, gets=[Get(Digest, [PathGlobs]), Get(DigestContents, [Digest]), Get(Digest, [CreateDigest])]). All potential sources were eliminated: []
E         No source of dependency UnionMembership for @rule(plugins.dagster.goals:65:package_locations(DagsterLocationConfigFieldSet, DagsterSubsystem, UnionMembership, DistDir) -> BuiltPackage, gets=[Get(Digest, [PathGlobs]), Get(DigestContents, [Digest]), Get(Digest, [CreateDigest])]). All potential sources were eliminated: []
Do I need the full list of params for the
QueryRule
or just what I'm going to pass the
rule_runner.request
?
I need to figure out why the github search function never works for me lol
w
it may be necessary to add
*DagsterSubsystem.rules()
to the list of rules you construct the RuleRunner with.
r
They're in there
Copy code
rule_runner = RuleRunner(
        target_types=[DagsterLocationConfigTarget],
        rules=[*dagster_goal_rules(), *dagster_subsystem_rules(), QueryRule(BuiltPackage, [DagsterLocationConfigFieldSet])]
    )
The signature of the goal I'm trying to test
Copy code
@rule
async def package_locations(
    field_set: DagsterLocationConfigFieldSet,
    dagster_subsystem: DagsterSubsystem,
    union_membership: UnionMembership,
    dist_dir: DistDir,
) -> BuiltPackage:
w
hm. you might need to explicitly include the rules from
pants.core.util_rules.distdir
, if
dagster_goal_rules
doesn’t already include them
r
Yep that worked! Thank you!
Is it normal for coverage not to be detected for integration tested rules?