David Yang
11/22/2021, 8:18 PMKevin Kho
shell
argument.David Yang
11/22/2021, 8:32 PMAkiva Wolberg
11/30/2021, 10:32 PMKevin Kho
Kevin Kho
David Yang
12/01/2021, 2:13 PMAkiva Wolberg
12/01/2021, 8:33 PMKevin Kho
Akiva Wolberg
12/01/2021, 9:02 PMprint("got to R")
r_shelltask.py:
from prefect import Flow
from prefect.tasks.shell import ShellTask
rshell = ShellTask(
shell = "cmd",
helper_script="echo 'got to cmd'",
stream_output=True,
)
with Flow("abc") as f:
r_result = rshell(
command = "Rscript test.r"
)
f.run()
output on running this:
PS C:\Users\lwolberg\Desktop\workingdata> py r_shelltask.py
[2021-12-01 16:01:48-0500] INFO - prefect.FlowRunner | Beginning Flow run for 'abc'
[2021-12-01 16:01:48-0500] INFO - prefect.TaskRunner | Task 'ShellTask': Starting task run...
[2021-12-01 16:01:48-0500] INFO - prefect.ShellTask | Microsoft Windows [Version 10.0.19043.1165]
[2021-12-01 16:01:48-0500] INFO - prefect.ShellTask | (c) Microsoft Corporation. All rights reserved.
[2021-12-01 16:01:48-0500] INFO - prefect.ShellTask |
And then it hangs indefinitely.Akiva Wolberg
12/01/2021, 9:05 PMfrom prefect import Flow
from prefect.tasks.shell import ShellTask
rshell = ShellTask(
shell = "Rscript",
helper_script="echo 'got to cmd'",
stream_output=True,
)
with Flow("abc") as f:
r_result = rshell(
command = "test.r"
)
f.run()
Akiva Wolberg
12/01/2021, 9:07 PMshell="powershell"
it appears to work (reports Task 'ShellTask' with final state 'Success'), but it doesn't print either the helper script or the R script, just offers to open a prefect temp file.Kevin Kho
rshell = ShellTask(
shell = "cmd",
helper_script="echo 'got to cmd'",
stream_output=True,
return_all=True
)
The return_all
specificallyAkiva Wolberg
12/01/2021, 9:25 PMKevin Kho
Akiva Wolberg
12/01/2021, 9:27 PMAkiva Wolberg
12/01/2021, 9:29 PMKevin Kho
Kevin Kho
Kevin Kho
Kevin Kho
Akiva Wolberg
12/01/2021, 10:21 PMKevin Kho
import subprocess
from typing import Sequence, Union
@task
def run_process(command: Union[str, Sequence[str]]):
if isinstance(command, str):
command = command.split()
return subprocess.run(command, check=True)
Kevin Kho
cmd
, but itβs honestly. a low priority ticket because there are so many gotchas with Windows and the recommendation is to use bashAkiva Wolberg
12/01/2021, 10:35 PMPS C:\Users\lwolberg\Desktop\workingdata> py r_shelltask.py
[2021-12-01 17:36:56-0500] INFO - prefect.FlowRunner | Beginning Flow run for 'abc'
[2021-12-01 17:36:56-0500] INFO - prefect.TaskRunner | Task 'ShellTask': Starting task run...
[2021-12-01 17:36:56-0500] INFO - prefect.ShellTask | Microsoft Windows [Version 10.0.19043.1165]
[2021-12-01 17:36:56-0500] INFO - prefect.ShellTask | (c) Microsoft Corporation. All rights reserved.
[2021-12-01 17:36:56-0500] INFO - prefect.ShellTask |
help
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | C:\Users\lwolberg\Desktop\workingdata>For more information on a specific command, type HELP command-name
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | ASSOC Displays or modifies file extension associations.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | ATTRIB Displays or changes file attributes.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | BREAK Sets or clears extended CTRL+C checking.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | BCDEDIT Sets properties in boot database to control boot loading.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | CACLS Displays or modifies access control lists (ACLs) of files.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | CALL Calls one batch program from another.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | CD Displays the name of or changes the current directory.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | CHCP Displays or sets the active code page number.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | CHDIR Displays the name of or changes the current directory.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | CHKDSK Checks a disk and displays a status report.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | CHKNTFS Displays or modifies the checking of disk at boot time.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | CLS Clears the screen.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | CMD Starts a new instance of the Windows command interpreter.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | COLOR Sets the default console foreground and background colors.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | COMP Compares the contents of two files or sets of files.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | COMPACT Displays or alters the compression of files on NTFS partitions.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | CONVERT Converts FAT volumes to NTFS. You cannot convert the
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | current drive.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | COPY Copies one or more files to another location.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | DATE Displays or sets the date.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | DEL Deletes one or more files.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | DIR Displays a list of files and subdirectories in a directory.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | DISKPART Displays or configures Disk Partition properties.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | DOSKEY Edits command lines, recalls Windows commands, and
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | creates macros.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | DRIVERQUERY Displays current device driver status and properties.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | ECHO Displays messages, or turns command echoing on or off.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | ENDLOCAL Ends localization of environment changes in a batch file.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | ERASE Deletes one or more files.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | EXIT Quits the CMD.EXE program (command interpreter).
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | FC Compares two files or sets of files, and displays the
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | differences between them.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | FIND Searches for a text string in a file or files.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | FINDSTR Searches for strings in files.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | FOR Runs a specified command for each file in a set of files.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | FORMAT Formats a disk for use with Windows.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | FSUTIL Displays or configures the file system properties.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | FTYPE Displays or modifies file types used in file extension
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | associations.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | GOTO Directs the Windows command interpreter to a labeled line in
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | a batch program.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | GPRESULT Displays Group Policy information for machine or user.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | GRAFTABL Enables Windows to display an extended character set in
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | graphics mode.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | HELP Provides Help information for Windows commands.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | ICACLS Display, modify, backup, or restore ACLs for files and
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | directories.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | IF Performs conditional processing in batch programs.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | LABEL Creates, changes, or deletes the volume label of a disk.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | MD Creates a directory.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | MKDIR Creates a directory.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | MKLINK Creates Symbolic Links and Hard Links
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | MODE Configures a system device.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | MORE Displays output one screen at a time.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | MOVE Moves one or more files from one directory to another
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | directory.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | OPENFILES Displays files opened by remote users for a file share.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | PATH Displays or sets a search path for executable files.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | PAUSE Suspends processing of a batch file and displays a message.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | POPD Restores the previous value of the current directory saved by
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | PUSHD.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | PRINT Prints a text file.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | PROMPT Changes the Windows command prompt.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | PUSHD Saves the current directory then changes it.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | RD Removes a directory.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | RECOVER Recovers readable information from a bad or defective disk.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | REM Records comments (remarks) in batch files or CONFIG.SYS.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | REN Renames a file or files.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | RENAME Renames a file or files.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | REPLACE Replaces files.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | RMDIR Removes a directory.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | ROBOCOPY Advanced utility to copy files and directory trees
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | SET Displays, sets, or removes Windows environment variables.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | SETLOCAL Begins localization of environment changes in a batch file.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | SC Displays or configures services (background processes).
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | SCHTASKS Schedules commands and programs to run on a computer.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | SHIFT Shifts the position of replaceable parameters in batch files.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | SHUTDOWN Allows proper local or remote shutdown of machine.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | SORT Sorts input.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | START Starts a separate window to run a specified program or command.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | SUBST Associates a path with a drive letter.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | SYSTEMINFO Displays machine specific properties and configuration.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | TASKLIST Displays all currently running tasks including services.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | TASKKILL Kill or stop a running process or application.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | TIME Displays or sets the system time.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | TITLE Sets the window title for a CMD.EXE session.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | TREE Graphically displays the directory structure of a drive or
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | path.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | TYPE Displays the contents of a text file.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | VER Displays the Windows version.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | VERIFY Tells Windows whether to verify that your files are written
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | correctly to a disk.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | VOL Displays a disk volume label and serial number.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | XCOPY Copies files and directory trees.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | WMIC Displays WMI information inside interactive command shell.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask |
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask | For more information on tools see the command-line reference in the online help.
[2021-12-01 17:37:04-0500] INFO - prefect.ShellTask |