Hey, I'm getting this error when trying to launch ...
# general
r
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
The code matters most, any chance you could share it? Blind here.
r
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
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
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
that seems legit
e
@ripe-gigabyte-88964 try adding an (unused)
Workspace
parameter to your goal rule for kicks.
🙏 1
r
that worked!
Thank you!
c
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
Ok, @ripe-gigabyte-88964 that worked but its clearly buggy.
If you don't use it you shouldn't need it.
2
r
for reference I'm on
2.16.0rc0
e
Yeah. This is likely ~ever-present. If you don't mind filing an issue, that would be great.
c
@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
e
@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
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
Patchy, probably
run_in_workspace: bool
->
run_in_workspace: Workspace
, but it seems like it deserves a step back and think.