![]() FireWorks passes in the entire spec to the run_task method the run_task method can therefore modify its behavior based on any input data present in the spec, or by detecting previous or future tasks in the spec. Specifically, we execute the run_task method which must be implemented for every Firetask. In the third step, we execute the code of the Firetask we loaded. You will just need to define what Python packages to search for your custom Firetasks, or use a special format that allows for direct loading of classes. If you want to place your Firetasks in a package outside of FireWorks, please read the FireWorks configuration tutorial. You can write code for custom Firetasks anywhere in the user_packages directory of FireWorks, and it will automatically be discovered. The ScriptTask is just one type of Firetask that’s built into FireWorks to help you run scripts easily. When we set a _fw_name of ScriptTask in the previous examples, FireWorks was loading a Python object with a _fw_name class variable set to ScriptTask (and passing the script parameter to its constructor). It does this by searching a list of Python packages for Python objects that have a value of _fw_name that match your setting. In the second step, FireWorks dynamically loads Python objects based on your specified _tasks. ![]() ![]() So far, we haven’t seen an example of this the only information we gave in the spec in the previous examples was within the _tasks section. The spec also allows you to define arbitrary JSON data (labeled input in the diagram) to pass into your Firetasks as input. There is a section that contains your Firetasks (one or many), as we saw in the previous examples. The first step of the image just shows how the spec section of the Firework is structured. We’ll be creating a custom Firetask that adds one or more numbers using Python’s sum() function, and later building workflows using this (and similar) Firetasks.īefore diving into an example of custom Firetask, it is worth understanding how FireWorks is bootstrapping jobs based on your specification. A custom Firetask gives you more control over your jobs, clarifies the usage of your code, and guards against unintended behavior by restricting the commands that can be executed.Įven if you plan to only use the built-in tasks, we suggest that you still read through the next portion before continuing with the tutorial. However, if you are comfortable with some basic Python, you can define your own custom Firetasks for the codes you run. ScriptTask also has many additional features that are covered in the ScriptTask tutorial. In fact, they might be all you need! In particular, because the ScriptTask can run arbitrary shell scripts, it can in theory run any type of computation and is an ‘all-encompassing’ Firetask. The TemplateWriterTask, ScriptTask, FileTransferTask are built-into FireWorks and can be used to perform useful operations.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |