Hi there. I've been trying to migrate all of the f...
# ask-community
c
Hi there. I've been trying to migrate all of the flows that use
shell_run_command
from
prefect-shell
into the new
ShellOperation
class, however, I'm always running into the following error when I try to run ANY command. This is using WINDOWS. Examples:
Copy code
ShellOperation(commands=["echo Hello"]).run()
โœ… 1
m
From my own experience, I suggest using python's built-in
subprocess
module, especially if you're on windows. You can run a shell task like
Copy code
import subprocess

subprocess.run(command, stdout=True, check=True)
Under the hood, the shell_run_command and shellOperation also use this module, but I think the problems that come with them aren't worth the trouble.
n
Hi @Carlos Cueto - thanks for raising this! this looks like a windows-specific issue with how we write commands to a temp dir before executing them, we'll explore this more! and just to clarify @Mansour Zayer, we do not use subprocess.run, we use anyio.open_process
๐Ÿ™Œ 1
m
Thanks for the clarification. I think subprocess was used in prefect1 shell tasks (or I might just be mistaken all together)
n
(or I might just be mistaken all together)
nope! you're totally right, we did use subprocess in v1 version of shell task
c
Thank you @Nate. I'm surprised that I'm the only one that has reported this. Maybe not a lot of people use Windows agents with local processes and
prefect-shell
@Nate BTW, I opened an issue under the
prefect-shell
GitHub as well: https://github.com/PrefectHQ/prefect-shell/issues/69
๐Ÿ™ 1
a
@Carlos Cueto I created a branch https://github.com/PrefectHQ/prefect-shell/pull/70 do you mind trying to install this and rerunning? also can you let us know which Python version youโ€™re using?
pip install git+<https://github.com/PrefectHQ/prefect-shell.git@flush_after_write>
c
@Andrew Huang Installed the branch version you gave me. Running on python 3.10.7, but error also occurs in another machine with 3.9.2. Getting following error now:
a
Thanks! let me see if I can find another solution. I think we found a misconfiguration in our Windows tests. We can now reproduce on GitHub
๐Ÿ‘ 1
I believe this https://github.com/PrefectHQ/prefect-shell/pull/70 should fix it. I just need to fix the Windows assertion tests If youโ€™d like to help confirm:
pip install -U git+<https://github.com/PrefectHQ/prefect-shell.git@flush_after_write>
c
It works good now! Appreciate you taking the time to fix this.
๐ŸŽ‰ 1
a
No problem! Thank you for raising it. Iโ€™ll try to get a release soon..
Released; should be up on pypi in a few minutes
๐Ÿ‘ 1
๐Ÿ™Œ 1
c
Thank you for the quick fix.
๐Ÿ™ 2
a
Thanks for reporting!
upvote 2