Skip to content

cli_utils

get_input_for_existing_data_entities(existing_data_entity_list)

Prompts the user to choose input for a task from a list of existing data entities.

Parameters:

Name Type Description Default
existing_data_entity_list List[DataEntity]

A list of existing data entities.

required

Returns:

Type Description
List[DataEntity]

List[DataEntity]: A list of chosen data entities.

Source code in exe_kg_lib/utils/cli_utils.py
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
def get_input_for_existing_data_entities(
    existing_data_entity_list: List[DataEntity],
) -> List[DataEntity]:
    """
    Prompts the user to choose input for a task from a list of existing data entities.

    Args:
        existing_data_entity_list (List[DataEntity]): A list of existing data entities.

    Returns:
        List[DataEntity]: A list of chosen data entities.
    """
    if not existing_data_entity_list:
        return []

    chosen_data_entity_list = []
    print("Choose input for the task from existing data entities:")
    while True:
        for i, data_entity in enumerate(existing_data_entity_list):
            print(f"\t{str(i)}. {data_entity.name}")
        print(f"\t{str(-1)}. Continue")
        chosen_data_entity_i = int(input())
        if chosen_data_entity_i == -1:
            break

        chosen_data_entity_list.append(existing_data_entity_list[chosen_data_entity_i])

    return chosen_data_entity_list

get_input_for_new_data_entities(data_semantics_list, data_structure_list, namespace, data_entity)

Prompts the user to enter input columns and their corresponding data semantics and data structure.

Parameters:

Name Type Description Default
data_semantics_list List[Entity]

A list of available data semantics.

required
data_structure_list List[Entity]

A list of available data structures.

required
namespace Namespace

The namespace for the new data entities.

required
data_entity Entity

The data entity to which the new data entities belong.

required

Returns:

Type Description
List[DataEntity]

List[DataEntity]: A list of newly created data entities.

Source code in exe_kg_lib/utils/cli_utils.py
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
def get_input_for_new_data_entities(
    data_semantics_list: List[Entity], data_structure_list: List[Entity], namespace: Namespace, data_entity: Entity
) -> List[DataEntity]:
    """
    Prompts the user to enter input columns and their corresponding data semantics and data structure.

    Args:
        data_semantics_list (List[Entity]): A list of available data semantics.
        data_structure_list (List[Entity]): A list of available data structures.
        namespace (Namespace): The namespace for the new data entities.
        data_entity (Entity): The data entity to which the new data entities belong.

    Returns:
        List[DataEntity]: A list of newly created data entities.
    """
    data_entities = []

    prompt = "Enter input columns, then 'quit' when done: "
    source = input(prompt)
    while source != "quit":
        new_data_entity = DataEntity(namespace + source, data_entity, source)

        print(f"Choose data semantics for {source}:")
        for i, t in enumerate(data_semantics_list):
            print(f"\t{str(i)}. {t.name}")
        chosen_data_semantics_id = int(input())
        new_data_entity.data_semantics = data_semantics_list[chosen_data_semantics_id].iri

        print(f"Choose data structure for {source}:")
        for i, t in enumerate(data_structure_list):
            print(f"\t{str(i)}. {t.name}")
        chosen_data_structure_id = int(input())
        new_data_entity.data_structure = data_structure_list[chosen_data_structure_id].iri

        data_entities.append(new_data_entity)

        source = input(prompt)

    return data_entities

input_pipeline_info()

Prompts the user to enter information about the pipeline.

Returns:

Type Description
Tuple[str, str, str]

A tuple containing the pipeline name, input data path, and output directory for saving plots.

Source code in exe_kg_lib/utils/cli_utils.py
83
84
85
86
87
88
89
90
91
92
93
94
def input_pipeline_info() -> Tuple[str, str, str]:
    """
    Prompts the user to enter information about the pipeline.

    Returns:
        A tuple containing the pipeline name, input data path, and output directory for saving plots.
    """
    pipeline_name = input("Enter a name for the pipeline: ")
    input_data_path = input("Enter a path for the input data: ")
    input_plots_output_dir = input("Enter a path for saving the plots: ")

    return pipeline_name, input_data_path, input_plots_output_dir