-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ShellJob
: Add support for custom parsing
The `ShellJob` comes with the default `ShellParser` which will automatically attach the `stdout` and `stderr` files as `SinglefileData` nodes, as well as any additional files that have been specified by the user in the `outputs` argument. Although this makes for an easy interface to use since the user is not required to implement the parser, it is also rather restrictive. A strong side of AiiDA is exactly to allow storing data in JSON form in the relational database making it queryable. By storing data in `SinglefileData` nodes exclusively, this functionality is not available. In certain cases, it might be advantageous to parse the output produced by a shell command into other specific `Data` nodes. The input `parser` is added to the `ShellJob`. It takes a Python function with the signature: def parser(self, dirpath: pathlib.Path) -> dict[str, Data]: """Parse files in the working directory of the shell job.""" The `dirpath` will be the path to the folder with the output files generated by the shell command that have been retrieved by the engine. If specified, this function is called by the `ShellParser` allowing it to parse output files into any `Data` nodes which will be automatically attached as outputs of the `ShellJob`. To make sure that the specified parsing function can also be loaded by the daemon, in the case that the `ShellJob` is submitted instead of ran in the interpreter where the function is defined, it is stored in a `PickledData` instance. This data plugin will pickle the function, which allows the daemon worker to unpickle it and call the function.
- Loading branch information
Showing
3 changed files
with
91 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters