Module ploigos_step_runner.step_implementers.examples.hello_world
A simple StepImplementer that prints out a greeting. See the HelloShell example for an upgraded version that runs a shell command to print the greeting.
You can run this example from the command line by creating a file named psr.yaml with these contents:
step-runner-config:
examples:
- implementer: HelloWorld
config:
greeting-name: Folks
And then running the command psr -s examples -c psr.yaml
Step Configuration
Step configuration expected as input to this step. Could come from:
- static configuration
- runtime configuration
- previous step results
Configuration Key | Required? | Default | Description |
---|---|---|---|
greeting-name |
No | World |
Name to use in greeting message. |
Result Artifacts
Results artifacts output by this step.
Result Artifact Key | Description |
---|---|
greeting |
Message that was printed |
Classes
class HelloWorld (workflow_result, parent_work_dir_path, config, environment=None)
-
Example StepImplementer that prints a message and does nothing else.
Expand source code
class HelloWorld(StepImplementer): """ Example StepImplementer that prints a message and does nothing else. """ # Overridden to specify default values for this StepImplementer's configuration. @staticmethod def step_implementer_config_defaults(): return { 'greeting-name': 'World' } # Overridden to specify required configuration values. These can be specified in # the configuration file or calculated by previous steps in the workflow. @staticmethod def _required_config_or_result_keys(): return [] # No required values without defaults # Overridden to implement the behavior of this StepImplementer. def _run_step(self): """Runs the step implemented by this StepImplementer. Returns ------- StepResult Object containing the dictionary results of this step. """ # Read the configuration, usually from `psr.yaml`. step_result = StepResult.from_step_implementer(self) greeting = self.get_value('greeting-name') # Read from configuration # Do the actual work of the step. message = f"Hello {greeting}!" print(message) # Save the result. Future steps like the report step can access artifacts. step_result.add_artifact( name='greeting-output', value=message ) return step_result
Ancestors
- StepImplementer
- abc.ABC
Inherited members
StepImplementer
:config
create_working_dir_sub_dir
environment
get_config_value
get_copy_of_runtime_step_config
get_result_value
get_value
global_config_defaults
global_environment_config_defaults
has_config_value
run_step
step_config
step_config_overrides
step_environment_config
step_implementer_config_defaults
step_name
sub_step_implementer_name
sub_step_name
work_dir_path
workflow_result
write_working_file