Skip to content

Manifest

Manifest

CodeEngineManifest dataclass

CodeEngineManifest(
    functions: list[CodeEngineManifest_Function],
    configuration: dict[str, Any],
    raw: str = None,
)

from_python_file classmethod

from_python_file(
    file_path: str, accounts_mapping: list[Any]
) -> CodeEngineManifest

Analyze all functions in a Python script file and return a structured manifest.

This is the main public method that orchestrates the complete analysis process. It loads the specified file, parses its AST, and generates comprehensive metadata descriptions for every function found in the script, returning them as a Manifest object.

Parameters:

Name Type Description Default
file_path str

Path to the Python script file to analyze

required

Returns:

Name Type Description
Manifest CodeEngineManifest

A manifest object containing: - functions (list[FunctionMetadata]): list of function metadata objects - configuration (dict[str, Any]): Configuration dictionary with accountsMapping

Error Handling
  • Returns a Manifest with empty functions list if file loading fails
  • Prints error messages for individual function analysis failures but continues processing
  • Skips functions that cannot be analyzed due to errors
Example

analyzer = CodeEngineScriptAnalyzer() manifest = analyzer.analyze_all_functions('my_script.py') for func in manifest.functions: ... print(f"Function: {func.name} ({len(func.inputs)} parameters)")

Note

This method walks the entire AST and processes all function definitions found, including nested functions and methods within classes.

Source code in src/crew_dcs/classes/DomoCodeEngine/Manifest.py
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
@classmethod
def from_python_file(
    cls, file_path: str, accounts_mapping: list[Any]
) -> "CodeEngineManifest":
    """
    Analyze all functions in a Python script file and return a structured manifest.

    This is the main public method that orchestrates the complete analysis process.
    It loads the specified file, parses its AST, and generates comprehensive metadata
    descriptions for every function found in the script, returning them as a Manifest object.

    Args:
        file_path (str): Path to the Python script file to analyze

    Returns:
        Manifest: A manifest object containing:
            - functions (list[FunctionMetadata]): list of function metadata objects
            - configuration (dict[str, Any]): Configuration dictionary with accountsMapping

    Error Handling:
        - Returns a Manifest with empty functions list if file loading fails
        - Prints error messages for individual function analysis failures but continues processing
        - Skips functions that cannot be analyzed due to errors

    Example:
        >>> analyzer = CodeEngineScriptAnalyzer()
        >>> manifest = analyzer.analyze_all_functions('my_script.py')
        >>> for func in manifest.functions:
        ...     print(f"Function: {func.name} ({len(func.inputs)} parameters)")

    Note:
        This method walks the entire AST and processes all function definitions found,
        including nested functions and methods within classes.
    """
    content = dmcv.convert_python_to_ast_module(
        python_file_path=file_path, return_str=True
    )

    ast_module = dmcv.convert_python_to_ast(python_str=content, return_str=False)

    return cls(
        functions=[
            CodeEngineManifest_Function.from_ast_function(ast_fn, content=content)
            for ast_fn in dmcv.extract_ast_functions(ast_module)
        ],
        configuration={"accountsMapping": accounts_mapping or []},
    )

from_python_string classmethod

from_python_string(
    python_str: str,
    accounts_mapping: list[Any],
    validate: bool = True,
) -> CodeEngineManifest

Analyze all functions in a Python script string and return a structured manifest.

This is the main public method that orchestrates the complete analysis process. It loads the specified string, parses its AST, and generates comprehensive metadata descriptions for every function found in the script, returning them as a Manifest object.

Parameters:

Name Type Description Default
python_str str

Python script content to analyze

required

Returns:

Name Type Description
Manifest CodeEngineManifest

A manifest object containing: - functions (list[FunctionMetadata]): list of function metadata objects - configuration (dict[str, Any]): Configuration dictionary with accountsMapping

Error Handling
  • Returns a Manifest with empty functions list if string loading fails
  • Prints error messages for individual function analysis failures but continues processing
  • Skips functions that cannot be analyzed due to errors
Example

analyzer = CodeEngineScriptAnalyzer() manifest = analyzer.analyze_all_functions('def my_func(x): return x') for func in manifest.functions: ... print(f"Function: {func.name} ({len(func.inputs)} parameters)")

Note

This method walks the entire AST and processes all function definitions found, including nested functions and methods within classes.

Source code in src/crew_dcs/classes/DomoCodeEngine/Manifest.py
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
@classmethod
def from_python_string(
    cls, python_str: str, accounts_mapping: list[Any], validate: bool = True
) -> "CodeEngineManifest":
    """
    Analyze all functions in a Python script string and return a structured manifest.

    This is the main public method that orchestrates the complete analysis process.
    It loads the specified string, parses its AST, and generates comprehensive metadata
    descriptions for every function found in the script, returning them as a Manifest object.

    Args:
        python_str (str): Python script content to analyze

    Returns:
        Manifest: A manifest object containing:
            - functions (list[FunctionMetadata]): list of function metadata objects
            - configuration (dict[str, Any]): Configuration dictionary with accountsMapping

    Error Handling:
        - Returns a Manifest with empty functions list if string loading fails
        - Prints error messages for individual function analysis failures but continues processing
        - Skips functions that cannot be analyzed due to errors

    Example:
        >>> analyzer = CodeEngineScriptAnalyzer()
        >>> manifest = analyzer.analyze_all_functions('def my_func(x): return x')
        >>> for func in manifest.functions:
        ...     print(f"Function: {func.name} ({len(func.inputs)} parameters)")

    Note:
        This method walks the entire AST and processes all function definitions found,
        including nested functions and methods within classes.
    """
    ast_module = dmcv.convert_python_to_ast_module(
        python_str=python_str, return_str=False
    )

    manifest = cls(
        functions=[
            CodeEngineManifest_Function.from_ast_function_def(
                ast_fn, original_module_string=python_str
            )
            for ast_fn in dmcv.extract_ast_functions(ast_module)
        ],
        configuration={"accountsMapping": accounts_mapping or []},
    )
    # validate=False on the READ path: the description cap is a write-side
    # constraint, and refusing to parse a package that already exists in
    # Domo would break inspection of it for no benefit.
    if validate:
        manifest.validate_descriptions()
    return manifest

to_dict

to_dict() -> dict[str, Any]

Convert manifest to dictionary format for API submission.

Returns:

Type Description
dict[str, Any]

Dictionary with 'functions' and 'configuration' keys.

Source code in src/crew_dcs/classes/DomoCodeEngine/Manifest.py
180
181
182
183
184
185
186
187
188
189
def to_dict(self) -> dict[str, Any]:
    """Convert manifest to dictionary format for API submission.

    Returns:
        Dictionary with 'functions' and 'configuration' keys.
    """
    return {
        "functions": [fn.to_dict() for fn in self.functions],
        "configuration": self.configuration,
    }

validate_descriptions

validate_descriptions() -> None

Raise if any function docstring exceeds Domo's description cap.

Called before the manifest is sent so an over-long docstring fails here, naming the function and the overage, instead of as Domo's anonymous 400. See MAX_FUNCTION_DESCRIPTION_LEN for how the limit was established.

Source code in src/crew_dcs/classes/DomoCodeEngine/Manifest.py
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
def validate_descriptions(self) -> None:
    """Raise if any function docstring exceeds Domo's description cap.

    Called before the manifest is sent so an over-long docstring fails here,
    naming the function and the overage, instead of as Domo's anonymous 400.
    See MAX_FUNCTION_DESCRIPTION_LEN for how the limit was established.
    """
    too_long = [
        (fn.name, len(fn.description or ""))
        for fn in self.functions
        if len(fn.description or "") > MAX_FUNCTION_DESCRIPTION_LEN
    ]
    if not too_long:
        return

    detail = "; ".join(
        f"{name} is {size} chars ({size - MAX_FUNCTION_DESCRIPTION_LEN} over)"
        for name, size in too_long
    )
    raise CodeEngine_InvalidPackageError(
        message=(
            f"Function docstring exceeds Domo's {MAX_FUNCTION_DESCRIPTION_LEN}-character "
            f"description limit: {detail}. Domo rejects this with a 400 that names no "
            f"field. Move the extra prose into module-level comments, which are not capped."
        )
    )