ConditionStep#

class ConditionStep(config)#

Bases: BatchedStep

Step that executes other steps based on provided condition.

Parameters
  • step (str) – flow

  • type (str) – condition

  • condition (dict) – Condition based on which the step to be executed is selected. If declared condition passed, the step defined in the “true_step” key is executed, otherwise the step from the “false_step” key is chosen. Available conditions: healthy_service, healthy_nlp_service, truthy_server_config.

  • true_step (dict) – Step configuration that should be executed when condition is true.

  • false_step (dict) – Step configuration that should be executed when condition is false.

Example

{
    "step": "flow",
    "type": "condition",
    "condition": {
        "truthy_server_config": {
            "key": "topic.test-key"
        }
    },
    "true_step": {
        "step": "external",
        "type": "remote_spacy",
        "name": "remote_spacy",
        "field_mapping": {
            "user_terms_str": "nlp"
        },
        "disable_pipes__default": ["merge_noun_chunks"]
    },
    "false_step": {
        "step": "app",
        "type": "query_processing",
        "name": "custom_spacy_normalizer",
        "model_cache_expiration": 345600,
        "infix_split_hyphen": false,
        "infix_split_chars": ":<>=",
        "merge_noun_chunks": false,
        "merge_phrases": true,
        "merge_entities": true,
        "fallback_language": "en",
        "exclude_spacy_pipes": [],
        "spacy_model_mapping": {
            "en": "en_core_web_sm",
            "de": "de_core_news_sm"
        }
    }
}

Methods Summary

choose_step_config()

rtype

dict

is_condition_true(**kwargs)

process_batch(batch)

Process a batch of documents.

Methods Documentation

choose_step_config()#
Return type

dict

is_condition_true(**kwargs)#
process_batch(batch)#

Process a batch of documents. If not defined will default to using self.process_doc for each document in the batch.

Parameters

batch (list(Document)) – List of documents

Returns

List of processed documents

Return type

list(Document)