https://pantsbuild.org/ logo
#general
Title
# general
r

ripe-gigabyte-88964

04/14/2023, 2:27 PM
Hey, I'm getting this error when trying to launch an interactive process from a goal rule I'm writing:
Copy code
IntrinsicError: Side-effects are not allowed in this context: SideEffecting types must be acquired via parameters to `@rule`s.
Has something changed since the guide here was written? Alternatively, is this another case of pants obfuscating the real error message?
run_in_workspace=True
if that matters
e

enough-analyst-54434

04/14/2023, 2:28 PM
The code matters most, any chance you could share it? Blind here.
r

ripe-gigabyte-88964

04/14/2023, 2:30 PM
Copy code
@goal_rule
async def run_dagster(targets: Targets) -> DagsterGoal:
    process_opts, exit_code = [], 0
    for target in targets:
        if DagsterLocationConfigFieldSet.is_applicable(target):
            code_source = target[DagsterLocationCodeSource].value
            if "python_file" in code_source:
                process_opts.append(f"-f {code_source['python_file']}")
            else:  # parameter already checks that key is one of either 'python_file' or 'package_name', so safe to assume here
                process_opts.append(f"-m {code_source['package_name']}")
    if process_opts:
        dagster_command = " ".join(("dagster", "dev", *process_opts))
        logger.debug(dagster_command)
        result = await Effect(
            InteractiveProcessResult,
            InteractiveProcess(
                argv=[dagster_command],
                env={"DAGSTER_ENVIRONMENT": "LOCAL_DEV", "DAGSTER_HOME": "/tmp/dagster_home"},
                run_in_workspace=True,
            ),
        )
        exit_code = result.exit_code
    return DagsterGoal(exit_code=exit_code)
Trying to spin up a local dagster server
Here's the
rules
function at the bottom of said file:
Copy code
def rules():
    return [
        *collect_rules(),
        UnionRule(PackageFieldSet, DagsterLocationConfigFieldSet),
        UnionRule(PackageFieldSet, CopyDestinationFieldSet),
    ]
c

curved-television-6568

04/14/2023, 2:34 PM
how are you invoking/wiring up your goal rule? i.e. do you have
await Get(DagsterGoal, …)
or something like that? (which I would not expect to work)
r

ripe-gigabyte-88964

04/14/2023, 2:36 PM
Just following the guide I linked, I have a goal subsystem like:
Copy code
class RunDagitSubsystem(GoalSubsystem):
    name = "run-dagit"
    help = "Run dagster locally"


class DagsterGoal(Goal):
    subsystem_cls = RunDagitSubsystem


def rules():
    return collect_rules()
c

curved-television-6568

04/14/2023, 2:36 PM
that seems legit
e

enough-analyst-54434

04/14/2023, 2:37 PM
@ripe-gigabyte-88964 try adding an (unused)
Workspace
parameter to your goal rule for kicks.
🙏 1
r

ripe-gigabyte-88964

04/14/2023, 2:39 PM
that worked!
Thank you!
c

curved-television-6568

04/14/2023, 2:39 PM
I’m also comparing to what’s been done to an existing pants goal, and this one uses await Effect ok: https://github.com/pantsbuild/pants/blob/main/src/python/pants/core/goals/publish.py and there’s some environment stuff going on there as well.,.
oh, nvm 😉
e

enough-analyst-54434

04/14/2023, 2:40 PM
Ok, @ripe-gigabyte-88964 that worked but its clearly buggy.
If you don't use it you shouldn't need it.
2
r

ripe-gigabyte-88964

04/14/2023, 2:40 PM
for reference I'm on
2.16.0rc0
e

enough-analyst-54434

04/14/2023, 2:41 PM
Yeah. This is likely ~ever-present. If you don't mind filing an issue, that would be great.
c

curved-television-6568

04/14/2023, 2:42 PM
@enough-analyst-54434 it is not for the code I linked to, so guess there’s some underlying requirement that is needed to be pulled in that can be done in any of several ways..
r

ripe-gigabyte-88964

04/14/2023, 2:47 PM
e

enough-analyst-54434

04/14/2023, 2:59 PM
@curved-television-6568 that's probably because:
Copy code
$ git grep "class Console("
src/python/pants/engine/console.py:class Console(SideEffecting):
If you grep the error message Nick was getting its internals are sneaky.
Probably an un-intended strangeness here:
Copy code
$ git grep "class " | grep "(SideEffecting)"
src/python/pants/engine/console.py:class Console(SideEffecting):
src/python/pants/engine/fs.py:class Workspace(SideEffecting):
src/python/pants/engine/process.py:class InteractiveProcess(SideEffecting):
c

curved-television-6568

04/14/2023, 3:22 PM
ah, so.. requires your rule to consume a side effecting type in order to use one, perhaps?
oh, yea that’s basically what the error said
e

enough-analyst-54434

04/14/2023, 3:25 PM
Patchy, probably
run_in_workspace: bool
->
run_in_workspace: Workspace
, but it seems like it deserves a step back and think.