upload
upload ¶
upload_package_version
async
¶
upload_package_version(
auth: DomoAuth,
package_id: str,
code: str,
is_new_version: bool = False,
metadata: dict | None = None,
return_raw: bool = False,
*,
context: RouteContext | None = None,
**context_kwargs
) -> ResponseGetData
Upload Python code to a CodeEngine package.
This route function validates inputs, builds a manifest from the Python code, and deploys it to the specified CodeEngine package.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
auth
|
DomoAuth
|
Authentication object with valid Domo credentials |
required |
package_id
|
str
|
ID of the CodeEngine package to update |
required |
code
|
str
|
Python source code string to deploy |
required |
is_new_version
|
bool
|
If True, create a new version. If False (default), update the current version. |
False
|
metadata
|
dict | None
|
Optional metadata overrides including: - runtime: Runtime version (default: "PYTHON_3_13") - accountsMapping: List of account mapping dicts - name: Package name override - description: Package description - handler_name: Name of the handler function |
None
|
return_raw
|
bool
|
Return raw response without processing |
False
|
context
|
RouteContext | None
|
RouteContext for request configuration |
None
|
**context_kwargs
|
Additional context parameters (session, debug_api, etc.) |
{}
|
Returns:
| Type | Description |
|---|---|
ResponseGetData
|
ResponseGetData containing: - package_id: The package ID - version: The version that was created/updated - status: "created" or "updated" - manifest: The generated manifest |
Raises:
| Type | Description |
|---|---|
CodeEngine_CRUD_Error
|
If validation fails or deployment fails |
Example
from crew_dcs.auth import DomoTokenAuth auth = DomoTokenAuth( ... domo_instance="mycompany", ... domo_access_token="your-token" ... ) code = ''' ... def process_data(items: list, limit: int = 10) -> dict: ... """Process items and return summary.""" ... return {"count": len(items[:limit])} ... ''' result = await upload_package_version( ... auth=auth, ... package_id="517ca12c-3459-4e66-b0bb-40f000720a84", ... code=code, ... is_new_version=False ... )
Note
- Default runtime is Python 3.13 ("PYTHON_3_13")
- Multi-file packages are not supported; code must be a single string
- The first top-level function in the code is used as the handler unless handler_name is specified in metadata
Source code in src/crew_dcs/routes/codeengine/upload.py
39 40 41 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 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 106 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 160 161 162 163 164 | |