Package: pyTaskify
pyTaskifyA Task Runner written in Python.pyTaskifyis a pure Python task runner for automating repetitive tasks in projects.Getting startedInstallationpyTaskifyis available onPyPi. Install the package withpipinstallpytaskifyCheck that the installation was done correctly by checking the version with the--versionargumenttaskify--versionUsageTo usepyTaskify, execute thetaskifycommand with the appropriate arguments. For example, to run the build task:taskifybuildYou can also pass arguments to the task. For example, to run thetesttask with the--verboseargument:taskifytest--verboseConfigurationYou can configurepyTaskifyby creating ataskify.ymlfile in the root directory of your project. This file should contain a list of tasks with their respective configurations.Here's an exampletaskify.ymlfile:version:1tasks:build:cmds:-rm -rf build-mkdir build-cd build && cmake .. && makeenv:CFLAGS:-O3LDFLAGS:-lmcontinue_on_error:truecheck:truetest:cmd:./build/tests --verbose={verbose}args:verbose:is_flag:truealias:--v---verboseIn this example, we have defined two tasks:buildandtest.Thebuildtask has a list of commands that will be executed in order, and some environment variables that will be set before the commands are run. Thecontinue_on_errorflag is set totrue, which means that if one of the commands fails, the remaining commands will still be executed. Thecheckflag is set totrue, which means that if one of the commands fails, the program will exit with a non-zero status code.Thetesttask has a single command, which takes averboseargument. Theargsdictionary defines theverboseargument, which is a flag with the-vand--verbosealias. Thecontinue_on_errorflag is set tofalse, which means that if the command fails, the program will exit with a non-zero status code. Thecheckflag is set totrue, which means that if the command fails, the program will exit with a non-zero status code.Supported file namespyTaskifyrecognizes a variety of file names that can contain task configurations. These include:taskify.ymltaskify.yamlEnvironment variablesYou can define environment variables that will be available to all tasks by adding them to theenvsection of thetaskify.ymlfile.version:1env:FOO:bartasks:default:cmd:echo taskifyYou can also define environment variables for a specific task by adding them to theenvsection of the task configuration.version:1tasks:default:cmd:echo taskifyenv:FOO:barIf you use both forms simultaneously, task environment variables will overwrite those previously declared.version:1env:FOO:bartasks:default:cmd:echo taskifyenv:FOO:foobarModulespyTaskifylets you import modules and use their functions in your task commands. This can be helpful for organizing your tasks and avoiding code repetition.version:1modules:foo:./foobar:./barTasks ArgumentsThepyTaskifyconfiguration file allows defining tasks with arguments. Arguments can be used in task commands and can have default values or be marked as required.These arguments can be used in task commands by using the curly brace syntax{arg_name}to reference the argument in the command.PropertiesA task argument can have the following properties:is_flag(optional): If set to True, the argument is treated as a flag and does not require a value. Defaults to False.required(optional): If set to True, the argument is marked as required and must be provided when calling the task. Defaults to False.default(optional): The default value for the argument. If the argument is not provided, this value will be used instead. If the argument is a flag, the value should be True or False. Defaults to None.alias(required): A list of aliases for the argument. Aliases can be used in place of the argument name in the task command.placeholder(optional): The placeholder value for the argument in the task command. This field serves as a mask for the argument, using the{value}braces syntax, the argument entry is replaced by the Placeholder and then in the command. Defaults to a string{value}.Exampleversion:1tasks:foo:cmd:echo foo {verbose}args:verbose:is_flag:trueplaceholder:--verbosealias:--vbar:cmd:echo bar {color}args:color:placeholder:--color={value}default:redalias:--cfoobar:cmd:echo foobar {color} {size}args:color:placeholder:--color={value}required:truealias:--csize:placeholder:--size={value}alias:--spytaskifyfoobar-cblue
pytaskifyfoobar-cblue-slargeversion:1tasks:mytask:cmd:echo {myarg}args:myarg:required:truealias:--m---myargplaceholder:--myarg={value}default:'foo'pytaskifymytask--myargbarTasks DependenciesYou can define dependencies between your tasks withpyTaskify. When you run a task, its dependencies will be executed first, if any, the dependency entry is an array.version:1tasks:build:cmd:python build.pydeploy:deps:-buildcmd:python deploy.py ./distTasks Commands and Calling another taskpyTaskifylets you define commands for your tasks. These commands can be shell commands, Python scripts, or even other tasks.pyTaskifyonly accepts 1 type of command per task, you must define only 1 betweencmd,cmds,taskandtasks.version:1tasks:calling_command:cmd:echo "Foobar" {FOO}args:FOO:alias:-fcalling_commands:cmds:-echo "Step 1"-echo "Step 2"calling_task:task:name:calling_commandcalling_tasks:tasks:-name:calling_commandargs:FOO:barIgnore errorsSometimes it can be useful to ignore errors and continue executing tasks.pyTaskifysupports this with thecontinue_on_erroroption.version:1tasks:calling_commands:cmds:-echo "Step 1"-exit 1-echo "Step 3"continue_on_error:trueCheck errorsIf check is true, and the process exits with a non-zero exit code, a CalledProcessError exception will be raised. Attributes of that exception hold the arguments, the exit code, and stdout and stderr if they were captured.version:1tasks:calling_commands:cmds:-echo "Step 1"-echo "Step 2"check:trueBug ReportFeel free to post anissueabout any bugs you find, or to ask any questions!ContributionThis project uses the Pythonsubprocessto execute the commands, see the documentation if you need to clarify any doubts!InstallationInside the project folder you can run the command.gitclonehttps://github.com/AlisonVilela/pyTaskify.gitcdpyTaskify
pipinstall-rrequirements.txtRunningpython.\pytaskify\cli.py--versionCodingWe followGoogle Python Style Guideto maintain a good quality of code written, please read carefully to write correctly to keep the code organized and clean.LinterWe usePyLintto keep the code organized. Make sure your IDE is respecting the.editorconfigfile, you may need to install aplugin or extension.To check for programming errors, bugs, stylistic errors and suspicious constructions you can run the command:python.\pytaskify\cli.pylintUnit Testpython.\pytaskify\cli.pytestIDEFeel free to use any IDE, but we do recommendVS Code.Pull RequestIf you want to contribute topyTaskify, follow these steps:Fork this repositoryCreate a new branch (git checkout -b my-new-feature)Make your changes and commit (git commit -am 'I added a new feature')Push to the branch (git push origin my-new-feature)Open a Pull RequestTODOUnit TestsGithub workflowGithub issue templateDo not allow tasks with required arguments to be added as a dependency of another task, or allow passing the necessary argumentsDotenv file supportParallel execution of tasksTask timeoutDynamic variablesForwarding CLI arguments to commandsTask status to prevent unnecessary workPlatform specific tasks and commandsDry run modeWatch tasksChangelogSeeCHANGELOGfor a list of changes.LicenseThis project is licensed under the MIT License - see theLICENSEfile for details.AcknowledgmentThis project was inspired byTaskwritten in Go.CitationIf you rely on pytask to manage your research project, please cite it with the following
key to help others to discover the tool.@Unpublished{Vilela2023,Title={A Task Runner written in Python.},Author={Alison Vilela},Year={2023},Url={https://github.com/AlisonVilela/pyTaskify}}