From b49a3a8ad52196886a21f4b8a1f5a141babe1c0e Mon Sep 17 00:00:00 2001 From: Viren Baraiya Date: Thu, 5 Oct 2023 22:57:25 -0700 Subject: [PATCH 1/9] ai support --- src/conductor/client/ai/__init__.py | 0 src/conductor/client/ai/ai_orchestrator.py | 126 ++++ src/conductor/client/ai/llm_prompt_test.py | 60 ++ .../client/http/api/prompt_resource_api.py | 697 ++++++++++++++++++ .../client/http/models/workflow_def.py | 4 +- src/conductor/client/worker/worker.py | 3 + .../client/workflow/conductor_workflow.py | 36 +- .../task/llm_tasks/llm_generate_embeddings.py | 2 - .../task/llm_tasks/llm_text_complete.py | 4 +- .../workflow/task/llm_tasks/utils/prompt.py | 2 +- src/conductor/client/workflow/task/task.py | 5 +- src/test.ipynb | 124 ++++ 12 files changed, 1049 insertions(+), 14 deletions(-) create mode 100644 src/conductor/client/ai/__init__.py create mode 100644 src/conductor/client/ai/ai_orchestrator.py create mode 100644 src/conductor/client/ai/llm_prompt_test.py create mode 100644 src/conductor/client/http/api/prompt_resource_api.py create mode 100644 src/test.ipynb diff --git a/src/conductor/client/ai/__init__.py b/src/conductor/client/ai/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/conductor/client/ai/ai_orchestrator.py b/src/conductor/client/ai/ai_orchestrator.py new file mode 100644 index 00000000..c0c88700 --- /dev/null +++ b/src/conductor/client/ai/ai_orchestrator.py @@ -0,0 +1,126 @@ +import time +from typing import Optional, List +from uuid import uuid4 + +from typing_extensions import Self + +from conductor.client.configuration.configuration import Configuration +from conductor.client.http.api.prompt_resource_api import PromptResourceApi +from conductor.client.http.api.workflow_resource_api import WorkflowResourceApi +from conductor.client.http.api_client import ApiClient +from conductor.client.http.models import Task, TaskResult, StartWorkflowRequest, Workflow +from conductor.client.worker.worker import Worker +from conductor.client.workflow.conductor_workflow import ConductorWorkflow +from conductor.client.workflow.executor.workflow_executor import WorkflowExecutor +from conductor.client.workflow.task.llm_tasks.llm_text_complete import LlmTextComplete +from conductor.client.workflow.task.llm_tasks.utils.prompt import Prompt + + +class AIConfiguration: + def __init__(self, llm_provider: str, text_complete_model: str, embedding_model: str, vector_db: str) -> Self: + self.llm_provider = llm_provider + self.text_complete_model = text_complete_model + self.embedding_model = embedding_model + self.vector_db = vector_db + + +class AIOrchestrator: + def __init__(self, api_configuration: Configuration, ai_configuration: AIConfiguration, + prompt_test_workflow_name: str = '') -> Self: + self.ai_configuration = ai_configuration + api_client = ApiClient(api_configuration) + self.workflow_executor = WorkflowExecutor(api_configuration) + self.prompt_resource = PromptResourceApi(api_client) + self.workflow_resource = WorkflowResourceApi(api_client) + self.prompt_test_workflow_name = prompt_test_workflow_name + if self.prompt_test_workflow_name == '': + self.prompt_test_workflow_name = 'prompt_test_' + str(uuid4()) + + def add_prompt_template(self, name: str, template: str, description: str): + self.prompt_resource.save_message_template(template, description, name) + return self + + def test_prompt_template(self, name: str, variables: dict, + stop_words: Optional[List[str]] = [], max_tokens: Optional[int] = 100, + temperature: int = 0, + top_p: int = 1): + prompt = Prompt(name, variables) + llm_text_complete = LlmTextComplete( + 'prompt_test', 'prompt_test', + self.ai_configuration.llm_provider, self.ai_configuration.text_complete_model, + prompt, + stop_words, max_tokens, temperature, top_p + ) + name = self.prompt_test_workflow_name + prompt_test_workflow = ConductorWorkflow( + executor=self.workflow_executor, + name=name, + description='Prompt testing workflow from SDK' + ) + prompt_test_workflow.add(llm_text_complete) + output = prompt_test_workflow.execute({}) + if 'result' in output.keys(): + return output['result'] + else: + return '' + + def __get_pending_tasks(self, workflow: Workflow) -> List[Task]: + pending = [] + for wf_task in workflow.tasks: + if wf_task.status == 'SCHEDULED': + pending.append(wf_task) + return pending + + def execute_workflow(self, workflow: ConductorWorkflow, task_to_exec: dict[str, object] = None, + wait_for_seconds: int = 10) -> dict: + task_to_exec = task_to_exec or {} + workflow.executor = self.workflow_executor + request = StartWorkflowRequest() + request.workflow_def = workflow.to_workflow_def() + request.input = {} + request.name = request.workflow_def.name + request.version = 1 + + workflow_id = workflow.start_workflow(request) + execution = self.workflow_executor.get_workflow(workflow_id, True) + count = wait_for_seconds - 1 + + while len(task_to_exec) > 0 and count > 0: + pending = self.__get_pending_tasks(execution) + if len(pending) == 0: + break + for wf_task in pending: + ref_name = wf_task.reference_task_name + exec_fn = None + if ref_name in task_to_exec.keys(): + exec_fn = task_to_exec.pop(ref_name) + if exec_fn is not None: + worker = Worker(execute_function=exec_fn, task_definition_name=wf_task.task_definition.name) + exec_result = worker.execute(wf_task) + output = {} + + if isinstance(exec_result, TaskResult): + output = exec_result.output_data + else: + if isinstance(exec_result, dict): + output = exec_result + else: + output['result'] = exec_result + execution = self.workflow_executor.update_task_by_ref_name_sync(task_output=output, + task_reference_name=ref_name, + workflow_id=workflow_id, + status='COMPLETED') + + if execution.status != 'RUNNING': + break + else: + time.sleep(1) + count = count - 1 + + count = wait_for_seconds + while execution.status == 'RUNNING' and count > 0: + execution = self.workflow_executor.get_workflow(workflow_id, False) + time.sleep(1) + count = count - 1 + + return execution \ No newline at end of file diff --git a/src/conductor/client/ai/llm_prompt_test.py b/src/conductor/client/ai/llm_prompt_test.py new file mode 100644 index 00000000..32eb2c22 --- /dev/null +++ b/src/conductor/client/ai/llm_prompt_test.py @@ -0,0 +1,60 @@ +import sys +from typing import Dict + +from conductor.client.ai.ai_orchestrator import AIConfiguration, AIOrchestrator +from conductor.client.configuration.configuration import Configuration +from conductor.client.configuration.settings.authentication_settings import AuthenticationSettings +from conductor.client.http.models import Task, TaskResult +from conductor.client.workflow.conductor_workflow import ConductorWorkflow +from conductor.client.workflow.task.llm_tasks.llm_text_complete import LlmTextComplete +from conductor.client.workflow.task.llm_tasks.utils.prompt import Prompt +from conductor.client.workflow.task.simple_task import SimpleTask + + +def exec_fn(task: Task) -> TaskResult: + task_result = TaskResult( + task_id=task.task_id, + workflow_instance_id=task.workflow_instance_id, + worker_id='your_custom_id' + ) + task_result.add_output_data('worker_style', 'function') + task_result.add_output_data('name', 'this') + task_result.status = 'COMPLETED' + return task_result + + +def echo(input: Task) -> Dict: + return 'hello world' + + +def exec_fn2(task: Task) -> str: + return 'Hello world222' + + +def get_document(task: Task) -> str: + return 'Viren Baraiya' + + +def main(): + ai_config = AIConfiguration('azure_openai', 'text-davinci-003', 'text-embedding-ada-002', 'pineconedb') + api_config = Configuration( + authentication_settings=AuthenticationSettings(key_id='3bbcc893-66f4-4887-a419-12b8117fac62', + key_secret='t6BhLZUqaKRXLEjzEtnVNnjtO5Ll2C1205SSE1rXg3WrRZ7V')) + + prompt_client = AIOrchestrator(api_configuration=api_config, ai_configuration=ai_config) + + prompt = Prompt(name='say_hi_to_friend', variables={'friend_name': '${get_friend_name_ref.output.result}'}) + tasks = [ + SimpleTask('get_friend_name', 'get_friend_name_ref'), + LlmTextComplete('say_hi', 'say_hi_ref', ai_config.llm_provider, ai_config.text_complete_model, prompt=prompt) + ] + workflow = ConductorWorkflow(name='say_hi_to_the_friend') + workflow >> tasks + workflow.output_parameters = {'greetings': '${say_hi_ref.output.result}'} + task_executors = {'get_friend_name_ref': get_document} + wf_result = prompt_client.execute_workflow(workflow=workflow, wait_for_seconds=10, task_to_exec=task_executors) + print(wf_result.output) + + +if __name__ == '__main__': + sys.exit(main()) # next section explains the use of sys.exit diff --git a/src/conductor/client/http/api/prompt_resource_api.py b/src/conductor/client/http/api/prompt_resource_api.py new file mode 100644 index 00000000..9f0b6939 --- /dev/null +++ b/src/conductor/client/http/api/prompt_resource_api.py @@ -0,0 +1,697 @@ +from __future__ import absolute_import + +import re # noqa: F401 + +# python 2 and python 3 compatibility library +import six + +from conductor.client.http.api_client import ApiClient + + +class PromptResourceApi(object): + """NOTE: This class is auto generated by the swagger code generator program. + + Do not edit the class manually. + Ref: https://github.com/swagger-api/swagger-codegen + """ + + def __init__(self, api_client=None): + if api_client is None: + api_client = ApiClient() + self.api_client = api_client + + def delete_message_template(self, name, **kwargs): # noqa: E501 + """Delete Template # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.delete_message_template(name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param str name: (required) + :return: None + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('async_req'): + return self.delete_message_template_with_http_info(name, **kwargs) # noqa: E501 + else: + (data) = self.delete_message_template_with_http_info(name, **kwargs) # noqa: E501 + return data + + def delete_message_template_with_http_info(self, name, **kwargs): # noqa: E501 + """Delete Template # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.delete_message_template_with_http_info(name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param str name: (required) + :return: None + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['name'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + + params = locals() + for key, val in six.iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method delete_message_template" % key + ) + params[key] = val + del params['kwargs'] + # verify the required parameter 'name' is set + if ('name' not in params or + params['name'] is None): + raise ValueError("Missing the required parameter `name` when calling `delete_message_template`") # noqa: E501 + + collection_formats = {} + + path_params = {} + if 'name' in params: + path_params['name'] = params['name'] # noqa: E501 + + query_params = [] + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + # Authentication setting + auth_settings = ['api_key'] # noqa: E501 + + return self.api_client.call_api( + '/prompts/{name}', 'DELETE', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type=None, # noqa: E501 + auth_settings=auth_settings, + async_req=params.get('async_req'), + _return_http_data_only=params.get('_return_http_data_only'), + _preload_content=params.get('_preload_content', True), + _request_timeout=params.get('_request_timeout'), + collection_formats=collection_formats) + + def delete_tag_for_prompt_template(self, body, name, **kwargs): # noqa: E501 + """Delete a tag for Prompt Template # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.delete_tag_for_prompt_template(body, name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param list[TagObject] body: (required) + :param str name: (required) + :return: None + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('async_req'): + return self.delete_tag_for_prompt_template_with_http_info(body, name, **kwargs) # noqa: E501 + else: + (data) = self.delete_tag_for_prompt_template_with_http_info(body, name, **kwargs) # noqa: E501 + return data + + def delete_tag_for_prompt_template_with_http_info(self, body, name, **kwargs): # noqa: E501 + """Delete a tag for Prompt Template # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.delete_tag_for_prompt_template_with_http_info(body, name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param list[TagObject] body: (required) + :param str name: (required) + :return: None + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['body', 'name'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + + params = locals() + for key, val in six.iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method delete_tag_for_prompt_template" % key + ) + params[key] = val + del params['kwargs'] + # verify the required parameter 'body' is set + if ('body' not in params or + params['body'] is None): + raise ValueError("Missing the required parameter `body` when calling `delete_tag_for_prompt_template`") # noqa: E501 + # verify the required parameter 'name' is set + if ('name' not in params or + params['name'] is None): + raise ValueError("Missing the required parameter `name` when calling `delete_tag_for_prompt_template`") # noqa: E501 + + collection_formats = {} + + path_params = {} + if 'name' in params: + path_params['name'] = params['name'] # noqa: E501 + + query_params = [] + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + if 'body' in params: + body_params = params['body'] + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 + ['application/json']) # noqa: E501 + + # Authentication setting + auth_settings = ['api_key'] # noqa: E501 + + return self.api_client.call_api( + '/prompts/{name}/tags', 'DELETE', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type=None, # noqa: E501 + auth_settings=auth_settings, + async_req=params.get('async_req'), + _return_http_data_only=params.get('_return_http_data_only'), + _preload_content=params.get('_preload_content', True), + _request_timeout=params.get('_request_timeout'), + collection_formats=collection_formats) + + def get_message_template(self, name, **kwargs): # noqa: E501 + """Get Template # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.get_message_template(name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param str name: (required) + :return: MessageTemplate + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('async_req'): + return self.get_message_template_with_http_info(name, **kwargs) # noqa: E501 + else: + (data) = self.get_message_template_with_http_info(name, **kwargs) # noqa: E501 + return data + + def get_message_template_with_http_info(self, name, **kwargs): # noqa: E501 + """Get Template # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.get_message_template_with_http_info(name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param str name: (required) + :return: MessageTemplate + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['name'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + + params = locals() + for key, val in six.iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method get_message_template" % key + ) + params[key] = val + del params['kwargs'] + # verify the required parameter 'name' is set + if ('name' not in params or + params['name'] is None): + raise ValueError("Missing the required parameter `name` when calling `get_message_template`") # noqa: E501 + + collection_formats = {} + + path_params = {} + if 'name' in params: + path_params['name'] = params['name'] # noqa: E501 + + query_params = [] + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + # HTTP header `Accept` + header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # Authentication setting + auth_settings = ['api_key'] # noqa: E501 + + return self.api_client.call_api( + '/prompts/{name}', 'GET', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type='MessageTemplate', # noqa: E501 + auth_settings=auth_settings, + async_req=params.get('async_req'), + _return_http_data_only=params.get('_return_http_data_only'), + _preload_content=params.get('_preload_content', True), + _request_timeout=params.get('_request_timeout'), + collection_formats=collection_formats) + + def get_message_templates(self, **kwargs): # noqa: E501 + """Get Templates # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.get_message_templates(async_req=True) + >>> result = thread.get() + + :param async_req bool + :return: list[MessageTemplate] + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('async_req'): + return self.get_message_templates_with_http_info(**kwargs) # noqa: E501 + else: + (data) = self.get_message_templates_with_http_info(**kwargs) # noqa: E501 + return data + + def get_message_templates_with_http_info(self, **kwargs): # noqa: E501 + """Get Templates # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.get_message_templates_with_http_info(async_req=True) + >>> result = thread.get() + + :param async_req bool + :return: list[MessageTemplate] + If the method is called asynchronously, + returns the request thread. + """ + + all_params = [] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + + params = locals() + for key, val in six.iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method get_message_templates" % key + ) + params[key] = val + del params['kwargs'] + + collection_formats = {} + + path_params = {} + + query_params = [] + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + # HTTP header `Accept` + header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # Authentication setting + auth_settings = ['api_key'] # noqa: E501 + + return self.api_client.call_api( + '/prompts', 'GET', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type='list[MessageTemplate]', # noqa: E501 + auth_settings=auth_settings, + async_req=params.get('async_req'), + _return_http_data_only=params.get('_return_http_data_only'), + _preload_content=params.get('_preload_content', True), + _request_timeout=params.get('_request_timeout'), + collection_formats=collection_formats) + + def get_tags_for_prompt_template(self, name, **kwargs): # noqa: E501 + """Get tags by Prompt Template # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.get_tags_for_prompt_template(name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param str name: (required) + :return: list[TagObject] + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('async_req'): + return self.get_tags_for_prompt_template_with_http_info(name, **kwargs) # noqa: E501 + else: + (data) = self.get_tags_for_prompt_template_with_http_info(name, **kwargs) # noqa: E501 + return data + + def get_tags_for_prompt_template_with_http_info(self, name, **kwargs): # noqa: E501 + """Get tags by Prompt Template # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.get_tags_for_prompt_template_with_http_info(name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param str name: (required) + :return: list[TagObject] + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['name'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + + params = locals() + for key, val in six.iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method get_tags_for_prompt_template" % key + ) + params[key] = val + del params['kwargs'] + # verify the required parameter 'name' is set + if ('name' not in params or + params['name'] is None): + raise ValueError("Missing the required parameter `name` when calling `get_tags_for_prompt_template`") # noqa: E501 + + collection_formats = {} + + path_params = {} + if 'name' in params: + path_params['name'] = params['name'] # noqa: E501 + + query_params = [] + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + # HTTP header `Accept` + header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # Authentication setting + auth_settings = ['api_key'] # noqa: E501 + + return self.api_client.call_api( + '/prompts/{name}/tags', 'GET', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type='list[TagObject]', # noqa: E501 + auth_settings=auth_settings, + async_req=params.get('async_req'), + _return_http_data_only=params.get('_return_http_data_only'), + _preload_content=params.get('_preload_content', True), + _request_timeout=params.get('_request_timeout'), + collection_formats=collection_formats) + + def put_tag_for_prompt_template(self, body, name, **kwargs): # noqa: E501 + """Put a tag to Prompt Template # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.put_tag_for_prompt_template(body, name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param list[TagObject] body: (required) + :param str name: (required) + :return: None + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('async_req'): + return self.put_tag_for_prompt_template_with_http_info(body, name, **kwargs) # noqa: E501 + else: + (data) = self.put_tag_for_prompt_template_with_http_info(body, name, **kwargs) # noqa: E501 + return data + + def put_tag_for_prompt_template_with_http_info(self, body, name, **kwargs): # noqa: E501 + """Put a tag to Prompt Template # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.put_tag_for_prompt_template_with_http_info(body, name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param list[TagObject] body: (required) + :param str name: (required) + :return: None + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['body', 'name'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + + params = locals() + for key, val in six.iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method put_tag_for_prompt_template" % key + ) + params[key] = val + del params['kwargs'] + # verify the required parameter 'body' is set + if ('body' not in params or + params['body'] is None): + raise ValueError("Missing the required parameter `body` when calling `put_tag_for_prompt_template`") # noqa: E501 + # verify the required parameter 'name' is set + if ('name' not in params or + params['name'] is None): + raise ValueError("Missing the required parameter `name` when calling `put_tag_for_prompt_template`") # noqa: E501 + + collection_formats = {} + + path_params = {} + if 'name' in params: + path_params['name'] = params['name'] # noqa: E501 + + query_params = [] + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + if 'body' in params: + body_params = params['body'] + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 + ['application/json']) # noqa: E501 + + # Authentication setting + auth_settings = ['api_key'] # noqa: E501 + + return self.api_client.call_api( + '/prompts/{name}/tags', 'PUT', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type=None, # noqa: E501 + auth_settings=auth_settings, + async_req=params.get('async_req'), + _return_http_data_only=params.get('_return_http_data_only'), + _preload_content=params.get('_preload_content', True), + _request_timeout=params.get('_request_timeout'), + collection_formats=collection_formats) + + def save_message_template(self, body, description, name, **kwargs): # noqa: E501 + """Create or Update Template # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.save_message_template(body, description, name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param str body: (required) + :param str description: (required) + :param str name: (required) + :param list[str] models: + :return: None + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('async_req'): + return self.save_message_template_with_http_info(body, description, name, **kwargs) # noqa: E501 + else: + (data) = self.save_message_template_with_http_info(body, description, name, **kwargs) # noqa: E501 + return data + + def save_message_template_with_http_info(self, body, description, name, **kwargs): # noqa: E501 + """Create or Update Template # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.save_message_template_with_http_info(body, description, name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param str body: (required) + :param str description: (required) + :param str name: (required) + :param list[str] models: + :return: None + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['body', 'description', 'name', 'models'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + + params = locals() + for key, val in six.iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method save_message_template" % key + ) + params[key] = val + del params['kwargs'] + # verify the required parameter 'body' is set + if ('body' not in params or + params['body'] is None): + raise ValueError("Missing the required parameter `body` when calling `save_message_template`") # noqa: E501 + # verify the required parameter 'description' is set + if ('description' not in params or + params['description'] is None): + raise ValueError("Missing the required parameter `description` when calling `save_message_template`") # noqa: E501 + # verify the required parameter 'name' is set + if ('name' not in params or + params['name'] is None): + raise ValueError("Missing the required parameter `name` when calling `save_message_template`") # noqa: E501 + + collection_formats = {} + + path_params = {} + if 'name' in params: + path_params['name'] = params['name'] # noqa: E501 + + query_params = [] + if 'description' in params: + query_params.append(('description', params['description'])) # noqa: E501 + if 'models' in params: + query_params.append(('models', params['models'])) # noqa: E501 + collection_formats['models'] = 'multi' # noqa: E501 + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + if 'body' in params: + body_params = params['body'] + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 + ['application/json']) # noqa: E501 + + # Authentication setting + auth_settings = ['api_key'] # noqa: E501 + + return self.api_client.call_api( + '/prompts/{name}', 'POST', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type=None, # noqa: E501 + auth_settings=auth_settings, + async_req=params.get('async_req'), + _return_http_data_only=params.get('_return_http_data_only'), + _preload_content=params.get('_preload_content', True), + _request_timeout=params.get('_request_timeout'), + collection_formats=collection_formats) diff --git a/src/conductor/client/http/models/workflow_def.py b/src/conductor/client/http/models/workflow_def.py index 0eaa72cf..d394116e 100644 --- a/src/conductor/client/http/models/workflow_def.py +++ b/src/conductor/client/http/models/workflow_def.py @@ -61,7 +61,7 @@ class WorkflowDef(object): 'input_template': 'inputTemplate' } - def __init__(self, owner_app=None, create_time=None, update_time=None, created_by=None, updated_by=None, name=None, description=None, version=None, tasks=None, input_parameters=None, output_parameters=None, failure_workflow=None, schema_version=None, restartable=None, workflow_status_listener_enabled=None, owner_email=None, timeout_policy=None, timeout_seconds=None, variables=None, input_template=None): # noqa: E501 + def __init__(self, owner_app=None, create_time=None, update_time=None, created_by=None, updated_by=None, name=None, description=None, version=None, tasks=None, input_parameters=None, output_parameters: dict = {}, failure_workflow=None, schema_version=None, restartable=None, workflow_status_listener_enabled=None, owner_email=None, timeout_policy=None, timeout_seconds=None, variables=None, input_template=None): # noqa: E501 """WorkflowDef - a model defined in Swagger""" # noqa: E501 self._owner_app = None self._create_time = None @@ -73,7 +73,7 @@ def __init__(self, owner_app=None, create_time=None, update_time=None, created_b self._version = None self._tasks = None self._input_parameters = None - self._output_parameters = None + # self._output_parameters = None self._failure_workflow = None self._schema_version = None self._restartable = None diff --git a/src/conductor/client/worker/worker.py b/src/conductor/client/worker/worker.py index c159eed7..2b1ed548 100644 --- a/src/conductor/client/worker/worker.py +++ b/src/conductor/client/worker/worker.py @@ -65,6 +65,9 @@ def execute(self, task: Task) -> TaskResult: task_result = self.get_task_result_from_task(task) task_result.status = TaskResultStatus.COMPLETED task_result.output_data = self.execute_function(task) + if not isinstance(task_result.output_data, dict): + output = task_result.output_data + task_result.output_data = {'result': output} return task_result def get_identity(self) -> str: diff --git a/src/conductor/client/workflow/conductor_workflow.py b/src/conductor/client/workflow/conductor_workflow.py index dd55e65e..358b208e 100644 --- a/src/conductor/client/workflow/conductor_workflow.py +++ b/src/conductor/client/workflow/conductor_workflow.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from conductor.client.http.models.workflow_def import WorkflowDef from conductor.client.http.models.workflow_task import WorkflowTask from conductor.client.workflow.task.fork_task import ForkTask @@ -9,15 +11,15 @@ from copy import deepcopy from typing import Any, Dict, List from typing_extensions import Self -from shortuuid import uuid +from uuid import uuid4 class ConductorWorkflow: SCHEMA_VERSION = 2 def __init__(self, - executor: WorkflowExecutor, - name: str, + executor: WorkflowExecutor = None, + name: str = '', version: int = None, description: str = None) -> Self: self._executor = executor @@ -49,6 +51,15 @@ def name(self, name: str) -> None: def version(self) -> int: return self._version + @property + def executor(self) -> WorkflowExecutor: + return self._executor + + @executor.setter + def executor(self, executor: WorkflowExecutor) -> Self: + self._executor = executor + return self + @version.setter def version(self, version: int) -> None: if version != None and not isinstance(version, int): @@ -165,9 +176,18 @@ def start_workflow(self, start_workflow_request: StartWorkflowRequest): start_workflow_request.workflow_def = self.to_workflow_def() return self._executor.start_workflow(start_workflow_request) + def execute(self, workflow_input: dict) -> dict: + request = StartWorkflowRequest() + request.workflow_def = self.to_workflow_def() + request.input = workflow_input + request.name = request.workflow_def.name + request.version = 1 + run = self._executor.execute_workflow(request, wait_until_task_ref='') + return run.output + # Converts the workflow to the JSON serializable format def to_workflow_def(self) -> WorkflowDef: - return WorkflowDef( + workflow_def = WorkflowDef( name=self._name, description=self._description, version=self._version, @@ -182,6 +202,8 @@ def to_workflow_def(self) -> WorkflowDef: variables=self._variables, input_template=self._input_template, ) + workflow_def.output_parameters = self._output_parameters + return workflow_def def __get_workflow_task_list(self) -> List[WorkflowTask]: workflow_task_list = [] @@ -222,18 +244,18 @@ def __add_fork_join_tasks(self, forked_tasks: List[List[TaskInterface]]) -> Self if not issubclass(type(task), TaskInterface): raise Exception('invalid type') - suffix = str(uuid()) + suffix = str(uuid4()) fork_task = ForkTask( task_ref_name='forked_' + suffix, forked_tasks=forked_tasks ) - + join_task = JoinTask( task_ref_name='join_' + suffix, join_on=fork_task.to_workflow_task().join_on ) - + self._tasks.append(fork_task) self._tasks.append(join_task) return self diff --git a/src/conductor/client/workflow/task/llm_tasks/llm_generate_embeddings.py b/src/conductor/client/workflow/task/llm_tasks/llm_generate_embeddings.py index 5e64e434..9f5d5b4e 100644 --- a/src/conductor/client/workflow/task/llm_tasks/llm_generate_embeddings.py +++ b/src/conductor/client/workflow/task/llm_tasks/llm_generate_embeddings.py @@ -1,7 +1,5 @@ from conductor.client.workflow.task.task import TaskInterface from conductor.client.workflow.task.task_type import TaskType -from conductor.client.workflow.task.embedding_model import EmbeddingModel -from typing import Any, Dict, List from typing_extensions import Self diff --git a/src/conductor/client/workflow/task/llm_tasks/llm_text_complete.py b/src/conductor/client/workflow/task/llm_tasks/llm_text_complete.py index 9b84bbdb..9df3cee4 100644 --- a/src/conductor/client/workflow/task/llm_tasks/llm_text_complete.py +++ b/src/conductor/client/workflow/task/llm_tasks/llm_text_complete.py @@ -6,7 +6,9 @@ class LlmTextComplete(TaskInterface): - def __init__(self, task_name: str, task_ref_name: str, llm_provider: str, model: str, prompt: Prompt, stop_words: Optional[List[str]], max_tokens: Optional[int], temperature: int = 0, top_p: int = 0) -> Self: + def __init__(self, task_name: str, task_ref_name: str, llm_provider: str, model: str, prompt: Prompt, + stop_words: Optional[List[str]] = [], max_tokens: Optional[int] = 100, + temperature: int = 0, top_p: int = 1) -> Self: optional_input_params = {} if stop_words: diff --git a/src/conductor/client/workflow/task/llm_tasks/utils/prompt.py b/src/conductor/client/workflow/task/llm_tasks/utils/prompt.py index b32b6004..65303369 100644 --- a/src/conductor/client/workflow/task/llm_tasks/utils/prompt.py +++ b/src/conductor/client/workflow/task/llm_tasks/utils/prompt.py @@ -9,7 +9,7 @@ class Prompt(object): 'variables': 'promptVariables' } - def __init__(self, name: str, variables: dict[str, str]): + def __init__(self, name: str, variables: dict[str, object]): self._name= name self._variables = variables diff --git a/src/conductor/client/workflow/task/task.py b/src/conductor/client/workflow/task/task.py index 7aa61c26..da2232c0 100644 --- a/src/conductor/client/workflow/task/task.py +++ b/src/conductor/client/workflow/task/task.py @@ -1,5 +1,6 @@ from abc import ABC, abstractmethod from conductor.client.http.models.workflow_task import WorkflowTask +from conductor.client.worker.worker_interface import WorkerInterface from conductor.client.workflow.task.task_type import TaskType from copy import deepcopy from typing import Any, Dict, List @@ -21,13 +22,15 @@ def __init__(self, task_name: str = None, description: str = None, optional: bool = None, - input_parameters: Dict[str, Any] = None) -> Self: + input_parameters: Dict[str, Any] = None, + executor: WorkerInterface = None) -> Self: self.task_reference_name = task_reference_name self.task_type = task_type self.name = task_name or task_reference_name self.description = description self.optional = optional self.input_parameters = input_parameters + self.executor = executor @property def task_reference_name(self) -> str: diff --git a/src/test.ipynb b/src/test.ipynb new file mode 100644 index 00000000..2c32f7a2 --- /dev/null +++ b/src/test.ipynb @@ -0,0 +1,124 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 2, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "\n", + "Good morning, Viren! It's nice to meet you.\n" + ] + } + ], + "source": [ + "from conductor.client.ai.ai_orchestrator import AIOrchestrator\n", + "from conductor.client.ai.ai_orchestrator import AIConfiguration\n", + "from conductor.client.configuration.configuration import Configuration\n", + "from conductor.client.configuration.settings.authentication_settings import AuthenticationSettings\n", + "from conductor.client.workflow.task.switch_task import SwitchTask\n", + "\n", + "ai_config = AIConfiguration('azure_openai', 'text-davinci-003', 'text-embedding-ada-002', 'pineconedb')\n", + "api_config = Configuration(\n", + " authentication_settings=AuthenticationSettings(key_id='3bbcc893-66f4-4887-a419-12b8117fac62', key_secret='t6BhLZUqaKRXLEjzEtnVNnjtO5Ll2C1205SSE1rXg3WrRZ7V'))\n", + "\n", + "prompt_client = AIOrchestrator(api_configuration=api_config, ai_configuration=ai_config)\n", + "prompt_client.add_prompt_template('say_hi_to_friend', 'Say hello to your new friend ${friend_name} based on the time of the day.', 'xxx template')\n", + "result = prompt_client.test_prompt_template('say_hi_to_friend', {'friend_name': 'viren'})\n", + "print(result)" + ], + "metadata": { + "collapsed": false, + "ExecuteTime": { + "end_time": "2023-09-25T19:19:39.402170Z", + "start_time": "2023-09-25T19:19:36.150700Z" + } + }, + "id": "866c99bc07c3d0cd" + }, + { + "cell_type": "markdown", + "source": [ + "# Let's try and run a workflow that uses the LLM Chaining" + ], + "metadata": { + "collapsed": false + }, + "id": "224067570fd81626" + }, + { + "cell_type": "code", + "execution_count": 4, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'get_friend_name_ref': {'result': 'Viren Baraiya'}, 'say_hi_ref': {'result': \"\\n\\nGood morning, ${friend_name}! It's nice to meet you.\"}}\n" + ] + } + ], + "source": [ + "from conductor.client.workflow.conductor_workflow import ConductorWorkflow\n", + "from conductor.client.workflow.task.llm_tasks.utils.prompt import Prompt\n", + "from conductor.client.workflow.task.llm_tasks.llm_text_complete import LlmTextComplete\n", + "from conductor.client.workflow.task.simple_task import SimpleTask\n", + "from conductor.client.automator.task_handler import TaskHandler\n", + "from conductor.client.worker.worker import Worker\n", + "from conductor.client.http.models import Task, TaskResult\n", + "from conductor.client.http.models.task_result_status import TaskResultStatus\n", + "from conductor.client.worker.worker_interface import WorkerInterface\n", + "\n", + "def get_document(task: Task) -> str:\n", + " return 'Viren Baraiya'\n", + "\n", + "prompt = Prompt(name='say_hi_to_friend', variables={'friend_name': '${get_friend_name_ref.output.result}'})\n", + "tasks = [\n", + " SimpleTask('get_friend_name', 'get_friend_name_ref'),\n", + " LlmTextComplete('say_hi', 'say_hi_ref', ai_config.llm_provider, ai_config.text_complete_model, prompt=prompt)\n", + " ]\n", + "workflow = ConductorWorkflow(name='say_hi_to_the_friend')\n", + "workflow >> tasks\n", + "workflow.output_parameters = {'greetings': '${say_hi_ref.output.result}'}\n", + "\n", + "# When running from the notebook\n", + "task_executors = {'get_friend_name_ref': get_document}\n", + "\n", + "wf_result = prompt_client.execute_workflow(workflow=workflow, wait_for_seconds=5, task_to_exec=task_executors)\n", + "print(wf_result.output)" + ], + "metadata": { + "collapsed": false, + "ExecuteTime": { + "end_time": "2023-09-25T19:19:54.952025Z", + "start_time": "2023-09-25T19:19:51.736977Z" + } + }, + "id": "5d6999207803bd5f" + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.6" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} From 27038af69a348ca54bf198445ea60f261e8917ae Mon Sep 17 00:00:00 2001 From: Viren Baraiya Date: Tue, 28 Nov 2023 21:35:29 -0800 Subject: [PATCH 2/9] changes --- src/conductor/client/ai/ai_orchestrator.py | 3 + src/conductor/client/worker/worker_task.py | 4 +- .../client/workflow/conductor_workflow.py | 4 + .../client/workflow/task/simple_task.py | 3 +- src/conductor/hello.py | 55 +++++++++++++ src/conductor/hello2.py | 44 +++++++++++ src/conductor/hello3.py | 78 +++++++++++++++++++ src/test.ipynb | 51 ++++++------ 8 files changed, 216 insertions(+), 26 deletions(-) create mode 100644 src/conductor/hello.py create mode 100644 src/conductor/hello2.py create mode 100644 src/conductor/hello3.py diff --git a/src/conductor/client/ai/ai_orchestrator.py b/src/conductor/client/ai/ai_orchestrator.py index c0c88700..7ef66b06 100644 --- a/src/conductor/client/ai/ai_orchestrator.py +++ b/src/conductor/client/ai/ai_orchestrator.py @@ -74,6 +74,9 @@ def __get_pending_tasks(self, workflow: Workflow) -> List[Task]: def execute_workflow(self, workflow: ConductorWorkflow, task_to_exec: dict[str, object] = None, wait_for_seconds: int = 10) -> dict: task_to_exec = task_to_exec or {} + for task in workflow.tasks: + task_to_exec[task.task_reference_name] = task.executor + workflow.executor = self.workflow_executor request = StartWorkflowRequest() request.workflow_def = workflow.to_workflow_def() diff --git a/src/conductor/client/worker/worker_task.py b/src/conductor/client/worker/worker_task.py index dcdb9c9e..edc1fcb0 100644 --- a/src/conductor/client/worker/worker_task.py +++ b/src/conductor/client/worker/worker_task.py @@ -1,9 +1,9 @@ -from typing import Callable, TypeVar from conductor.client.worker.worker import ExecuteTaskFunction class WorkerTask(ExecuteTaskFunction): - def __init__(self, task_definition_name: str, domain: str = None, poll_interval_seconds: float = None, worker_id: str = None): + def __init__(self, task_definition_name: str, domain: str = None, poll_interval_seconds: float = None, + worker_id: str = None): self.task_definition_name = task_definition_name self.domain = domain self.poll_interval = poll_interval_seconds diff --git a/src/conductor/client/workflow/conductor_workflow.py b/src/conductor/client/workflow/conductor_workflow.py index 358b208e..779f705e 100644 --- a/src/conductor/client/workflow/conductor_workflow.py +++ b/src/conductor/client/workflow/conductor_workflow.py @@ -51,6 +51,10 @@ def name(self, name: str) -> None: def version(self) -> int: return self._version + @property + def tasks(self) -> List[TaskInterface]: + return self._tasks + @property def executor(self) -> WorkflowExecutor: return self._executor diff --git a/src/conductor/client/workflow/task/simple_task.py b/src/conductor/client/workflow/task/simple_task.py index aa787081..f7bc2bce 100644 --- a/src/conductor/client/workflow/task/simple_task.py +++ b/src/conductor/client/workflow/task/simple_task.py @@ -4,9 +4,10 @@ class SimpleTask(TaskInterface): - def __init__(self, task_def_name: str, task_reference_name: str) -> Self: + def __init__(self, task_def_name: str, task_reference_name: str, execute_fn: TaskInterface = None) -> Self: super().__init__( task_reference_name=task_reference_name, task_type=TaskType.SIMPLE, task_name=task_def_name, + executor=execute_fn ) diff --git a/src/conductor/hello.py b/src/conductor/hello.py new file mode 100644 index 00000000..b5e72572 --- /dev/null +++ b/src/conductor/hello.py @@ -0,0 +1,55 @@ +import functools +from typing import List + +from conductor.client.workflow.conductor_workflow import ConductorWorkflow + + +def repeat(num_times): + def decorator_repeat(func): + @functools.wraps(func) + def wrapper_repeat(*args, **kwargs): + for _ in range(num_times): + value = func(*args, **kwargs) + return value + + return wrapper_repeat + + return decorator_repeat + + +def switch(ref: str, condition: str, cases: dict[str, object]): + print('eval ' + condition) + return + + +def worker(name: str, polling_interval: int = 0.1): + def do_twice(func): + @functools.wraps(func) + def wrapper_do_twice(*args, **kwargs): + # func() + func() + print('hello intercepted: ' + str(polling_interval)) + + return wrapper_do_twice + + return do_twice + + +@worker(name='viren', polling_interval=100) +def hello(): + print('Hello world') + + +def workflow() -> ConductorWorkflow: + wf = ConductorWorkflow() + wf >> hello() >> switch() >> hello() + pass + + +def main(): + workflow() + print('Done') + + +if __name__ == '__main__': + main() diff --git a/src/conductor/hello2.py b/src/conductor/hello2.py new file mode 100644 index 00000000..e9a83d2e --- /dev/null +++ b/src/conductor/hello2.py @@ -0,0 +1,44 @@ +from conductor.client.worker.worker_task import WorkerTask +from conductor.client.workflow.conductor_workflow import ConductorWorkflow +from conductor.client.workflow.task.llm_tasks.utils.prompt import Prompt +from conductor.client.workflow.task.llm_tasks.llm_text_complete import LlmTextComplete +from conductor.client.workflow.task.simple_task import SimpleTask +from conductor.client.http.models import Task, TaskResult +from conductor.client.ai.ai_orchestrator import AIOrchestrator +from conductor.client.ai.ai_orchestrator import AIConfiguration +from conductor.client.configuration.configuration import Configuration +from conductor.client.configuration.settings.authentication_settings import AuthenticationSettings + + +@WorkerTask(task_definition_name="get_friend_name") +def getName(task: Task) -> str: + return 'Steve Jobs' + + +def main(): + ai_config = AIConfiguration('azure_openai', 'text-davinci-003', 'text-embedding-ada-002', 'pineconedb') + api_config = Configuration(authentication_settings=AuthenticationSettings(key_id='3bbcc893-66f4-4887-a419-12b8117fac62',key_secret='t6BhLZUqaKRXLEjzEtnVNnjtO5Ll2C1205SSE1rXg3WrRZ7V')) + + prompt_client = AIOrchestrator(api_configuration=api_config, ai_configuration=ai_config) + prompt_client.add_prompt_template('say_hi_to_friend', + 'Say hello to your new friend ${friend_name} based on the time of the day.', + 'xxx template') + + #result = prompt_client.test_prompt_template('say_hi_to_friend', {'friend_name': 'viren'}) + #print(result) + + prompt = Prompt(name='say_hi_to_friend', variables={'friend_name': '${get_friend_name_ref.output.result}'}) + workflow = ConductorWorkflow(name='say_hi_to_the_friend') + + workflow >> SimpleTask(task_def_name='get_friend_name', task_reference_name='get_friend_name_ref',execute_fn=getName) + workflow >> LlmTextComplete('say_hi', 'say_hi_ref', ai_config.llm_provider,ai_config.text_complete_model, prompt=prompt) + + workflow.output_parameters = {'greetings': '${say_hi_ref.output.result}'} + + wf_result = prompt_client.execute_workflow(workflow=workflow, wait_for_seconds=5) + print(wf_result.output) + print('Done') + + +if __name__ == '__main__': + main() diff --git a/src/conductor/hello3.py b/src/conductor/hello3.py new file mode 100644 index 00000000..56378386 --- /dev/null +++ b/src/conductor/hello3.py @@ -0,0 +1,78 @@ +import functools +from typing import List + +from conductor.client.configuration.configuration import Configuration +from conductor.client.configuration.settings.authentication_settings import AuthenticationSettings +from conductor.client.worker.worker_task import WorkerTask +from conductor.client.workflow.conductor_workflow import ConductorWorkflow +from conductor.client.workflow.executor.workflow_executor import WorkflowExecutor +from conductor.client.workflow.task.switch_task import SwitchTask +from conductor.client.workflow.task.task import TaskInterface +from conductor.hello import workflow + + +@WorkerTask(task_definition_name="get_user_info") +def get_user_info(): + pass + + +@WorkerTask(task_definition_name="send_email") +def send_email(): + pass + + +@WorkerTask(task_definition_name="send_sms") +def send_sms(): + pass + + +def RunsOn(cpu, memory): + pass + + +@WorkerTask(task_definition_name="record_notification") +@RunsOn(cpu=2, memory='1Mi') +def record_notification(): + pass + + +@WorkerTask(task_definition_name="capture_audit") +def capture_audit(): + pass + + +@workflow(name='user_notification', schedule='0 0 * ? * *') +def user_notification_workflow() -> List[TaskInterface]: + switch = SwitchTask('email_or_sms_ref', '${get_user_info.output.preference}') + switch = switch.switch_case('email', send_email) + switch = switch.switch_case('sms', send_sms) + return get_user_info >> switch >> record_notification + + +def assistant(func): + pass + + +@assistant +def get_movie_recommendation(prompt: str): + pass + + +def main(): + executor = WorkflowExecutor( + configuration=Configuration(authentication_settings=AuthenticationSettings(key_id='', key_secret=''))) + workflow = ConductorWorkflow(name='user_notification', executor=executor) + email_or_sms = SwitchTask('email_or_sms_ref', '${get_user_info.output.preference}') + email_or_sms = email_or_sms.switch_case('email', send_email) + email_or_sms = email_or_sms.switch_case('sms', send_sms) + workflow >> get_user_info >> email_or_sms >> [record_notification, capture_audit] + + output = workflow.execute({'username': 'user1@ores.io'}) + print(output) + + workflow.schedule('0 0 * ? * *', {'username': 'user1@ores.io'}) + pass + + +if __name__ == '__main__': + main() diff --git a/src/test.ipynb b/src/test.ipynb index 2c32f7a2..03f995d3 100644 --- a/src/test.ipynb +++ b/src/test.ipynb @@ -2,8 +2,16 @@ "cells": [ { "cell_type": "code", - "execution_count": 2, + "execution_count": 1, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/viren/workspace/github/orkes/sdk/conductor-python/venv/lib/python3.9/site-packages/urllib3/__init__.py:34: NotOpenSSLWarning: urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'LibreSSL 2.8.3'. See: https://github.com/urllib3/urllib3/issues/3020\n", + " warnings.warn(\n" + ] + }, { "name": "stdout", "output_type": "stream", @@ -33,8 +41,8 @@ "metadata": { "collapsed": false, "ExecuteTime": { - "end_time": "2023-09-25T19:19:39.402170Z", - "start_time": "2023-09-25T19:19:36.150700Z" + "end_time": "2023-11-20T19:17:05.140695Z", + "start_time": "2023-11-20T19:17:04.482083Z" } }, "id": "866c99bc07c3d0cd" @@ -51,13 +59,18 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 6, "outputs": [ { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'get_friend_name_ref': {'result': 'Viren Baraiya'}, 'say_hi_ref': {'result': \"\\n\\nGood morning, ${friend_name}! It's nice to meet you.\"}}\n" + "ename": "TypeError", + "evalue": "can only concatenate str (not \"list\") to str", + "output_type": "error", + "traceback": [ + "\u001B[0;31m---------------------------------------------------------------------------\u001B[0m", + "\u001B[0;31mTypeError\u001B[0m Traceback (most recent call last)", + "Cell \u001B[0;32mIn[6], line 18\u001B[0m\n\u001B[1;32m 13\u001B[0m workflow\u001B[38;5;241m.\u001B[39moutput_parameters \u001B[38;5;241m=\u001B[39m {\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mgreetings\u001B[39m\u001B[38;5;124m'\u001B[39m: \u001B[38;5;124m'\u001B[39m\u001B[38;5;124m$\u001B[39m\u001B[38;5;132;01m{say_hi_ref.output.result}\u001B[39;00m\u001B[38;5;124m'\u001B[39m}\n\u001B[1;32m 15\u001B[0m \u001B[38;5;66;03m# When running from the notebook\u001B[39;00m\n\u001B[1;32m 16\u001B[0m \u001B[38;5;66;03m# task_executors = {'get_friend_name_ref': getName}\u001B[39;00m\n\u001B[0;32m---> 18\u001B[0m wf_result \u001B[38;5;241m=\u001B[39m \u001B[43mprompt_client\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mexecute_workflow\u001B[49m\u001B[43m(\u001B[49m\u001B[43mworkflow\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mworkflow\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mwait_for_seconds\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[38;5;241;43m5\u001B[39;49m\u001B[43m)\u001B[49m\n\u001B[1;32m 19\u001B[0m \u001B[38;5;28mprint\u001B[39m(wf_result\u001B[38;5;241m.\u001B[39moutput)\n", + "File \u001B[0;32m~/workspace/github/orkes/sdk/conductor-python/src/conductor/client/ai/ai_orchestrator.py:78\u001B[0m, in \u001B[0;36mAIOrchestrator.execute_workflow\u001B[0;34m(self, workflow, task_to_exec, wait_for_seconds)\u001B[0m\n\u001B[1;32m 76\u001B[0m task_to_exec \u001B[38;5;241m=\u001B[39m task_to_exec \u001B[38;5;129;01mor\u001B[39;00m {}\n\u001B[1;32m 77\u001B[0m task_to_exec \u001B[38;5;241m=\u001B[39m workflow\u001B[38;5;241m.\u001B[39mtasks\n\u001B[0;32m---> 78\u001B[0m \u001B[38;5;28mprint\u001B[39m(\u001B[38;5;124;43m'\u001B[39;49m\u001B[38;5;124;43mHello\u001B[39;49m\u001B[38;5;124;43m'\u001B[39;49m\u001B[43m \u001B[49m\u001B[38;5;241;43m+\u001B[39;49m\u001B[43m \u001B[49m\u001B[43mtask_to_exec\u001B[49m)\n\u001B[1;32m 79\u001B[0m workflow\u001B[38;5;241m.\u001B[39mexecutor \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mworkflow_executor\n\u001B[1;32m 80\u001B[0m request \u001B[38;5;241m=\u001B[39m StartWorkflowRequest()\n", + "\u001B[0;31mTypeError\u001B[0m: can only concatenate str (not \"list\") to str" ] } ], @@ -66,35 +79,27 @@ "from conductor.client.workflow.task.llm_tasks.utils.prompt import Prompt\n", "from conductor.client.workflow.task.llm_tasks.llm_text_complete import LlmTextComplete\n", "from conductor.client.workflow.task.simple_task import SimpleTask\n", - "from conductor.client.automator.task_handler import TaskHandler\n", - "from conductor.client.worker.worker import Worker\n", "from conductor.client.http.models import Task, TaskResult\n", - "from conductor.client.http.models.task_result_status import TaskResultStatus\n", - "from conductor.client.worker.worker_interface import WorkerInterface\n", "\n", - "def get_document(task: Task) -> str:\n", - " return 'Viren Baraiya'\n", + "def getName(task: Task) -> str:\n", + " return 'Steve Jobs'\n", "\n", "prompt = Prompt(name='say_hi_to_friend', variables={'friend_name': '${get_friend_name_ref.output.result}'})\n", - "tasks = [\n", - " SimpleTask('get_friend_name', 'get_friend_name_ref'),\n", - " LlmTextComplete('say_hi', 'say_hi_ref', ai_config.llm_provider, ai_config.text_complete_model, prompt=prompt)\n", - " ]\n", "workflow = ConductorWorkflow(name='say_hi_to_the_friend')\n", - "workflow >> tasks\n", + "workflow >> SimpleTask(task_def_name='get_friend_name', task_reference_name='get_friend_name_ref', execute_fn=getName) >> LlmTextComplete('say_hi', 'say_hi_ref', ai_config.llm_provider, ai_config.text_complete_model, prompt=prompt) \n", "workflow.output_parameters = {'greetings': '${say_hi_ref.output.result}'}\n", "\n", "# When running from the notebook\n", - "task_executors = {'get_friend_name_ref': get_document}\n", + "# task_executors = {'get_friend_name_ref': getName}\n", "\n", - "wf_result = prompt_client.execute_workflow(workflow=workflow, wait_for_seconds=5, task_to_exec=task_executors)\n", + "wf_result = prompt_client.execute_workflow(workflow=workflow, wait_for_seconds=5)\n", "print(wf_result.output)" ], "metadata": { "collapsed": false, "ExecuteTime": { - "end_time": "2023-09-25T19:19:54.952025Z", - "start_time": "2023-09-25T19:19:51.736977Z" + "end_time": "2023-11-20T19:17:20.277641Z", + "start_time": "2023-11-20T19:17:20.261670Z" } }, "id": "5d6999207803bd5f" From cbb8983e0738455a10d44554c2286b997f4f099b Mon Sep 17 00:00:00 2001 From: Viren Baraiya Date: Fri, 1 Dec 2023 23:22:23 -0800 Subject: [PATCH 3/9] changes --- src/conductor/client/ai/ai_orchestrator.py | 129 - src/conductor/client/ai/configuration.py | 15 + src/conductor/client/ai/integrations.py | 48 + src/conductor/client/ai/llm_prompt_test.py | 2 +- src/conductor/client/ai/orchestrator.py | 68 + .../api/integration_resource_ap_interfacei.py | 72 + .../http/api/integration_resource_api.py | 2235 +++++++++++++++++ src/conductor/client/http/api_client.py | 19 - .../client/http/models/integration.py | 393 +++ .../client/http/models/integration_api.py | 330 +++ .../client/http/models/integration_def.py | 310 +++ .../client/http/models/integration_update.py | 209 ++ src/conductor/hello2.py | 4 +- 13 files changed, 3683 insertions(+), 151 deletions(-) delete mode 100644 src/conductor/client/ai/ai_orchestrator.py create mode 100644 src/conductor/client/ai/configuration.py create mode 100644 src/conductor/client/ai/integrations.py create mode 100644 src/conductor/client/ai/orchestrator.py create mode 100644 src/conductor/client/http/api/integration_resource_ap_interfacei.py create mode 100644 src/conductor/client/http/api/integration_resource_api.py create mode 100644 src/conductor/client/http/models/integration.py create mode 100644 src/conductor/client/http/models/integration_api.py create mode 100644 src/conductor/client/http/models/integration_def.py create mode 100644 src/conductor/client/http/models/integration_update.py diff --git a/src/conductor/client/ai/ai_orchestrator.py b/src/conductor/client/ai/ai_orchestrator.py deleted file mode 100644 index 7ef66b06..00000000 --- a/src/conductor/client/ai/ai_orchestrator.py +++ /dev/null @@ -1,129 +0,0 @@ -import time -from typing import Optional, List -from uuid import uuid4 - -from typing_extensions import Self - -from conductor.client.configuration.configuration import Configuration -from conductor.client.http.api.prompt_resource_api import PromptResourceApi -from conductor.client.http.api.workflow_resource_api import WorkflowResourceApi -from conductor.client.http.api_client import ApiClient -from conductor.client.http.models import Task, TaskResult, StartWorkflowRequest, Workflow -from conductor.client.worker.worker import Worker -from conductor.client.workflow.conductor_workflow import ConductorWorkflow -from conductor.client.workflow.executor.workflow_executor import WorkflowExecutor -from conductor.client.workflow.task.llm_tasks.llm_text_complete import LlmTextComplete -from conductor.client.workflow.task.llm_tasks.utils.prompt import Prompt - - -class AIConfiguration: - def __init__(self, llm_provider: str, text_complete_model: str, embedding_model: str, vector_db: str) -> Self: - self.llm_provider = llm_provider - self.text_complete_model = text_complete_model - self.embedding_model = embedding_model - self.vector_db = vector_db - - -class AIOrchestrator: - def __init__(self, api_configuration: Configuration, ai_configuration: AIConfiguration, - prompt_test_workflow_name: str = '') -> Self: - self.ai_configuration = ai_configuration - api_client = ApiClient(api_configuration) - self.workflow_executor = WorkflowExecutor(api_configuration) - self.prompt_resource = PromptResourceApi(api_client) - self.workflow_resource = WorkflowResourceApi(api_client) - self.prompt_test_workflow_name = prompt_test_workflow_name - if self.prompt_test_workflow_name == '': - self.prompt_test_workflow_name = 'prompt_test_' + str(uuid4()) - - def add_prompt_template(self, name: str, template: str, description: str): - self.prompt_resource.save_message_template(template, description, name) - return self - - def test_prompt_template(self, name: str, variables: dict, - stop_words: Optional[List[str]] = [], max_tokens: Optional[int] = 100, - temperature: int = 0, - top_p: int = 1): - prompt = Prompt(name, variables) - llm_text_complete = LlmTextComplete( - 'prompt_test', 'prompt_test', - self.ai_configuration.llm_provider, self.ai_configuration.text_complete_model, - prompt, - stop_words, max_tokens, temperature, top_p - ) - name = self.prompt_test_workflow_name - prompt_test_workflow = ConductorWorkflow( - executor=self.workflow_executor, - name=name, - description='Prompt testing workflow from SDK' - ) - prompt_test_workflow.add(llm_text_complete) - output = prompt_test_workflow.execute({}) - if 'result' in output.keys(): - return output['result'] - else: - return '' - - def __get_pending_tasks(self, workflow: Workflow) -> List[Task]: - pending = [] - for wf_task in workflow.tasks: - if wf_task.status == 'SCHEDULED': - pending.append(wf_task) - return pending - - def execute_workflow(self, workflow: ConductorWorkflow, task_to_exec: dict[str, object] = None, - wait_for_seconds: int = 10) -> dict: - task_to_exec = task_to_exec or {} - for task in workflow.tasks: - task_to_exec[task.task_reference_name] = task.executor - - workflow.executor = self.workflow_executor - request = StartWorkflowRequest() - request.workflow_def = workflow.to_workflow_def() - request.input = {} - request.name = request.workflow_def.name - request.version = 1 - - workflow_id = workflow.start_workflow(request) - execution = self.workflow_executor.get_workflow(workflow_id, True) - count = wait_for_seconds - 1 - - while len(task_to_exec) > 0 and count > 0: - pending = self.__get_pending_tasks(execution) - if len(pending) == 0: - break - for wf_task in pending: - ref_name = wf_task.reference_task_name - exec_fn = None - if ref_name in task_to_exec.keys(): - exec_fn = task_to_exec.pop(ref_name) - if exec_fn is not None: - worker = Worker(execute_function=exec_fn, task_definition_name=wf_task.task_definition.name) - exec_result = worker.execute(wf_task) - output = {} - - if isinstance(exec_result, TaskResult): - output = exec_result.output_data - else: - if isinstance(exec_result, dict): - output = exec_result - else: - output['result'] = exec_result - execution = self.workflow_executor.update_task_by_ref_name_sync(task_output=output, - task_reference_name=ref_name, - workflow_id=workflow_id, - status='COMPLETED') - - if execution.status != 'RUNNING': - break - else: - time.sleep(1) - count = count - 1 - - count = wait_for_seconds - while execution.status == 'RUNNING' and count > 0: - execution = self.workflow_executor.get_workflow(workflow_id, False) - time.sleep(1) - count = count - 1 - - return execution \ No newline at end of file diff --git a/src/conductor/client/ai/configuration.py b/src/conductor/client/ai/configuration.py new file mode 100644 index 00000000..9a0fa1ee --- /dev/null +++ b/src/conductor/client/ai/configuration.py @@ -0,0 +1,15 @@ +from typing import List + +from typing_extensions import Self + + +class AIConfiguration: + def __init__(self, llm_provider: str, text_complete_model: str, chat_complete_model: str, embedding_model: str, + vector_db: str) -> Self: + self.llm_provider = llm_provider + self.text_complete_model = text_complete_model + self.chat_complete_model = chat_complete_model + self.embedding_model = embedding_model + self.vector_db = vector_db + + diff --git a/src/conductor/client/ai/integrations.py b/src/conductor/client/ai/integrations.py new file mode 100644 index 00000000..94029d54 --- /dev/null +++ b/src/conductor/client/ai/integrations.py @@ -0,0 +1,48 @@ +from __future__ import annotations + + +class IntegrationConfig: + def __init__(self): + pass + + def to_dict(self) -> dict: + pass + + +class WeviateConfig(IntegrationConfig): + + def __init__(self, api_key: str, endpoint: str, classname: str) -> None: + self.api_key = api_key + self.endpoint = endpoint + self.classname = classname + + def to_dict(self) -> dict: + return { + 'api_key': self.api_key, + 'endpoint': self.endpoint + } + + +class OpenAIConfig(IntegrationConfig): + + def __init__(self, api_key: str) -> None: + self.api_key = api_key + + def to_dict(self) -> dict: + return { + 'api_key': self.api_key + } + + +class PineconeConfig(IntegrationConfig): + + def __init__(self, api_key: str, endpoint: str, classname: str) -> None: + self.api_key = api_key + self.endpoint = endpoint + self.classname = classname + + def to_dict(self) -> dict: + return { + 'api_key': self.api_key, + 'endpoint': self.endpoint + } diff --git a/src/conductor/client/ai/llm_prompt_test.py b/src/conductor/client/ai/llm_prompt_test.py index 32eb2c22..a17c6f62 100644 --- a/src/conductor/client/ai/llm_prompt_test.py +++ b/src/conductor/client/ai/llm_prompt_test.py @@ -1,7 +1,7 @@ import sys from typing import Dict -from conductor.client.ai.ai_orchestrator import AIConfiguration, AIOrchestrator +from conductor.client.ai.orchestrator import AIConfiguration, AIOrchestrator from conductor.client.configuration.configuration import Configuration from conductor.client.configuration.settings.authentication_settings import AuthenticationSettings from conductor.client.http.models import Task, TaskResult diff --git a/src/conductor/client/ai/orchestrator.py b/src/conductor/client/ai/orchestrator.py new file mode 100644 index 00000000..1c4a9d6d --- /dev/null +++ b/src/conductor/client/ai/orchestrator.py @@ -0,0 +1,68 @@ +from __future__ import annotations + +import time +from typing import Optional, List +from uuid import uuid4 + +from typing_extensions import Self + +from conductor.client.ai.integrations import IntegrationConfig +from conductor.client.configuration.configuration import Configuration +from conductor.client.http.api.prompt_resource_api import PromptResourceApi +from conductor.client.http.api.workflow_resource_api import WorkflowResourceApi +from conductor.client.http.api_client import ApiClient +from conductor.client.workflow.conductor_workflow import ConductorWorkflow +from conductor.client.workflow.executor.workflow_executor import WorkflowExecutor +from conductor.client.workflow.task.llm_tasks.llm_text_complete import LlmTextComplete +from conductor.client.workflow.task.llm_tasks.utils.prompt import Prompt +from conductor.client.ai.configuration import AIConfiguration + + +class AIOrchestrator: + def __init__(self, api_configuration: Configuration, ai_configuration: AIConfiguration, + prompt_test_workflow_name: str = '') -> Self: + self.ai_configuration = ai_configuration + api_client = ApiClient(api_configuration) + self.workflow_executor = WorkflowExecutor(api_configuration) + self.prompt_resource = PromptResourceApi(api_client) + self.workflow_resource = WorkflowResourceApi(api_client) + self.prompt_test_workflow_name = prompt_test_workflow_name + if self.prompt_test_workflow_name == '': + self.prompt_test_workflow_name = 'prompt_test_' + str(uuid4()) + + def add_prompt_template(self, name: str, template: str, description: str): + self.prompt_resource.save_message_template(template, description, name) + return self + + def test_prompt_template(self, name: str, variables: dict, + stop_words: Optional[List[str]] = [], max_tokens: Optional[int] = 100, + temperature: int = 0, + top_p: int = 1): + prompt = Prompt(name, variables) + llm_text_complete = LlmTextComplete( + 'prompt_test', 'prompt_test', + self.ai_configuration.llm_provider, self.ai_configuration.text_complete_model, + prompt, + stop_words, max_tokens, temperature, top_p + ) + name = self.prompt_test_workflow_name + prompt_test_workflow = ConductorWorkflow( + executor=self.workflow_executor, + name=name, + description='Prompt testing workflow from SDK' + ) + prompt_test_workflow.add(llm_text_complete) + output = prompt_test_workflow.execute({}) + if 'result' in output.keys(): + return output['result'] + else: + return '' + + def add_ai_integration(self, name: str, provider: str, models: List[str], description: str, api_key: str, + config: IntegrationConfig): + pass + + def add_vector_store(self, name: str, provider: str, indices: List[str], description: str, api_key: str, + config: IntegrationConfig): + pass + diff --git a/src/conductor/client/http/api/integration_resource_ap_interfacei.py b/src/conductor/client/http/api/integration_resource_ap_interfacei.py new file mode 100644 index 00000000..17ed427a --- /dev/null +++ b/src/conductor/client/http/api/integration_resource_ap_interfacei.py @@ -0,0 +1,72 @@ +from __future__ import absolute_import + +import re # noqa: F401 + + +class IntegrationResourceApi(object): + def associate_prompt_with_integration(self, integration_provider, integration_name, prompt_name, + **kwargs): # noqa: E501 + pass + + def delete_integration_api(self, name, integration_name, **kwargs): # noqa: E501 + pass + + def delete_integration_provider(self, name, **kwargs): # noqa: E501 + pass + + def delete_tag_for_integration(self, body, name, integration_name, **kwargs): # noqa: E501 + pass + + def delete_tag_for_integration_provider(self, body, name, **kwargs): # noqa: E501 + pass + + def get_integration_api(self, name, integration_name, **kwargs): # noqa: E501 + pass + + def get_integration_apis(self, name, **kwargs): # noqa: E501 + pass + + def get_integration_available_apis(self, name, **kwargs): # noqa: E501 + pass + + def get_integration_provider(self, name, **kwargs): # noqa: E501 + pass + + def get_integration_provider_defs(self, **kwargs): # noqa: E501 + pass + + def get_integration_providers(self, **kwargs): # noqa: E501 + pass + + def get_prompts_with_integration(self, integration_provider, integration_name, **kwargs): # noqa: E501 + pass + + def get_providers_and_integrations(self, **kwargs): # noqa: E501 + pass + + def get_tags_for_integration(self, name, integration_name, **kwargs): # noqa: E501 + pass + + def get_tags_for_integration_provider(self, name, **kwargs): # noqa: E501 + pass + + def get_token_usage_for_integration(self, name, integration_name, **kwargs): # noqa: E501 + pass + + def get_token_usage_for_integration_provider(self, name, **kwargs): # noqa: E501 + pass + + def put_tag_for_integration(self, body, name, integration_name, **kwargs): # noqa: E501 + pass + + def put_tag_for_integration_provider(self, body, name, **kwargs): # noqa: E501 + pass + + def register_token_usage(self, body, name, integration_name, **kwargs): # noqa: E501 + pass + + def save_integration_api(self, body, name, integration_name, **kwargs): # noqa: E501 + pass + + def save_integration_provider(self, body, name, **kwargs): # noqa: E501 + pass diff --git a/src/conductor/client/http/api/integration_resource_api.py b/src/conductor/client/http/api/integration_resource_api.py new file mode 100644 index 00000000..321886e2 --- /dev/null +++ b/src/conductor/client/http/api/integration_resource_api.py @@ -0,0 +1,2235 @@ +from __future__ import absolute_import + +import re # noqa: F401 + +# python 2 and python 3 compatibility library +import six + +from conductor.client.http.api_client import ApiClient + + +class IntegrationResourceApi(object): + """NOTE: This class is auto generated by the swagger code generator program. + + Do not edit the class manually. + Ref: https://github.com/swagger-api/swagger-codegen + """ + + def __init__(self, api_client=None): + if api_client is None: + api_client = ApiClient() + self.api_client = api_client + + def associate_prompt_with_integration(self, integration_provider, integration_name, prompt_name, + **kwargs): # noqa: E501 + """Associate a Prompt Template with an Integration # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.associate_prompt_with_integration(integration_provider, integration_name, prompt_name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param str integration_provider: (required) + :param str integration_name: (required) + :param str prompt_name: (required) + :return: None + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('async_req'): + return self.associate_prompt_with_integration_with_http_info(integration_provider, integration_name, + prompt_name, **kwargs) # noqa: E501 + else: + (data) = self.associate_prompt_with_integration_with_http_info(integration_provider, integration_name, + prompt_name, **kwargs) # noqa: E501 + return data + + def associate_prompt_with_integration_with_http_info(self, integration_provider, integration_name, prompt_name, + **kwargs): # noqa: E501 + """Associate a Prompt Template with an Integration # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.associate_prompt_with_integration_with_http_info(integration_provider, integration_name, prompt_name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param str integration_provider: (required) + :param str integration_name: (required) + :param str prompt_name: (required) + :return: None + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['integration_provider', 'integration_name', 'prompt_name'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + + params = locals() + for key, val in six.iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method associate_prompt_with_integration" % key + ) + params[key] = val + del params['kwargs'] + # verify the required parameter 'integration_provider' is set + if ('integration_provider' not in params or + params['integration_provider'] is None): + raise ValueError( + "Missing the required parameter `integration_provider` when calling `associate_prompt_with_integration`") # noqa: E501 + # verify the required parameter 'integration_name' is set + if ('integration_name' not in params or + params['integration_name'] is None): + raise ValueError( + "Missing the required parameter `integration_name` when calling `associate_prompt_with_integration`") # noqa: E501 + # verify the required parameter 'prompt_name' is set + if ('prompt_name' not in params or + params['prompt_name'] is None): + raise ValueError( + "Missing the required parameter `prompt_name` when calling `associate_prompt_with_integration`") # noqa: E501 + + collection_formats = {} + + path_params = {} + if 'integration_provider' in params: + path_params['integration_provider'] = params['integration_provider'] # noqa: E501 + if 'integration_name' in params: + path_params['integration_name'] = params['integration_name'] # noqa: E501 + if 'prompt_name' in params: + path_params['prompt_name'] = params['prompt_name'] # noqa: E501 + + query_params = [] + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + # Authentication setting + auth_settings = ['api_key'] # noqa: E501 + + return self.api_client.call_api( + '/integrations/provider/{integration_provider}/integration/{integration_name}/prompt/{prompt_name}', + 'POST', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type=None, # noqa: E501 + auth_settings=auth_settings, + async_req=params.get('async_req'), + _return_http_data_only=params.get('_return_http_data_only'), + _preload_content=params.get('_preload_content', True), + _request_timeout=params.get('_request_timeout'), + collection_formats=collection_formats) + + def delete_integration_api(self, name, integration_name, **kwargs): # noqa: E501 + """Delete an Integration # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.delete_integration_api(name, integration_name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param str name: (required) + :param str integration_name: (required) + :return: None + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('async_req'): + return self.delete_integration_api_with_http_info(name, integration_name, **kwargs) # noqa: E501 + else: + (data) = self.delete_integration_api_with_http_info(name, integration_name, **kwargs) # noqa: E501 + return data + + def delete_integration_api_with_http_info(self, name, integration_name, **kwargs): # noqa: E501 + """Delete an Integration # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.delete_integration_api_with_http_info(name, integration_name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param str name: (required) + :param str integration_name: (required) + :return: None + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['name', 'integration_name'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + + params = locals() + for key, val in six.iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method delete_integration_api" % key + ) + params[key] = val + del params['kwargs'] + # verify the required parameter 'name' is set + if ('name' not in params or + params['name'] is None): + raise ValueError( + "Missing the required parameter `name` when calling `delete_integration_api`") # noqa: E501 + # verify the required parameter 'integration_name' is set + if ('integration_name' not in params or + params['integration_name'] is None): + raise ValueError( + "Missing the required parameter `integration_name` when calling `delete_integration_api`") # noqa: E501 + + collection_formats = {} + + path_params = {} + if 'name' in params: + path_params['name'] = params['name'] # noqa: E501 + if 'integration_name' in params: + path_params['integration_name'] = params['integration_name'] # noqa: E501 + + query_params = [] + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + # Authentication setting + auth_settings = ['api_key'] # noqa: E501 + + return self.api_client.call_api( + '/integrations/provider/{name}/integration/{integration_name}', 'DELETE', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type=None, # noqa: E501 + auth_settings=auth_settings, + async_req=params.get('async_req'), + _return_http_data_only=params.get('_return_http_data_only'), + _preload_content=params.get('_preload_content', True), + _request_timeout=params.get('_request_timeout'), + collection_formats=collection_formats) + + def delete_integration_provider(self, name, **kwargs): # noqa: E501 + """Delete an Integration Provider # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.delete_integration_provider(name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param str name: (required) + :return: None + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('async_req'): + return self.delete_integration_provider_with_http_info(name, **kwargs) # noqa: E501 + else: + (data) = self.delete_integration_provider_with_http_info(name, **kwargs) # noqa: E501 + return data + + def delete_integration_provider_with_http_info(self, name, **kwargs): # noqa: E501 + """Delete an Integration Provider # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.delete_integration_provider_with_http_info(name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param str name: (required) + :return: None + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['name'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + + params = locals() + for key, val in six.iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method delete_integration_provider" % key + ) + params[key] = val + del params['kwargs'] + # verify the required parameter 'name' is set + if ('name' not in params or + params['name'] is None): + raise ValueError( + "Missing the required parameter `name` when calling `delete_integration_provider`") # noqa: E501 + + collection_formats = {} + + path_params = {} + if 'name' in params: + path_params['name'] = params['name'] # noqa: E501 + + query_params = [] + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + # Authentication setting + auth_settings = ['api_key'] # noqa: E501 + + return self.api_client.call_api( + '/integrations/provider/{name}', 'DELETE', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type=None, # noqa: E501 + auth_settings=auth_settings, + async_req=params.get('async_req'), + _return_http_data_only=params.get('_return_http_data_only'), + _preload_content=params.get('_preload_content', True), + _request_timeout=params.get('_request_timeout'), + collection_formats=collection_formats) + + def delete_tag_for_integration(self, body, name, integration_name, **kwargs): # noqa: E501 + """Delete a tag for Integration # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.delete_tag_for_integration(body, name, integration_name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param list[TagObject] body: (required) + :param str name: (required) + :param str integration_name: (required) + :return: None + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('async_req'): + return self.delete_tag_for_integration_with_http_info(body, name, integration_name, **kwargs) # noqa: E501 + else: + (data) = self.delete_tag_for_integration_with_http_info(body, name, integration_name, + **kwargs) # noqa: E501 + return data + + def delete_tag_for_integration_with_http_info(self, body, name, integration_name, **kwargs): # noqa: E501 + """Delete a tag for Integration # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.delete_tag_for_integration_with_http_info(body, name, integration_name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param list[TagObject] body: (required) + :param str name: (required) + :param str integration_name: (required) + :return: None + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['body', 'name', 'integration_name'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + + params = locals() + for key, val in six.iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method delete_tag_for_integration" % key + ) + params[key] = val + del params['kwargs'] + # verify the required parameter 'body' is set + if ('body' not in params or + params['body'] is None): + raise ValueError( + "Missing the required parameter `body` when calling `delete_tag_for_integration`") # noqa: E501 + # verify the required parameter 'name' is set + if ('name' not in params or + params['name'] is None): + raise ValueError( + "Missing the required parameter `name` when calling `delete_tag_for_integration`") # noqa: E501 + # verify the required parameter 'integration_name' is set + if ('integration_name' not in params or + params['integration_name'] is None): + raise ValueError( + "Missing the required parameter `integration_name` when calling `delete_tag_for_integration`") # noqa: E501 + + collection_formats = {} + + path_params = {} + if 'name' in params: + path_params['name'] = params['name'] # noqa: E501 + if 'integration_name' in params: + path_params['integration_name'] = params['integration_name'] # noqa: E501 + + query_params = [] + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + if 'body' in params: + body_params = params['body'] + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 + ['application/json']) # noqa: E501 + + # Authentication setting + auth_settings = ['api_key'] # noqa: E501 + + return self.api_client.call_api( + '/integrations/provider/{name}/integration/{integration_name}/tags', 'DELETE', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type=None, # noqa: E501 + auth_settings=auth_settings, + async_req=params.get('async_req'), + _return_http_data_only=params.get('_return_http_data_only'), + _preload_content=params.get('_preload_content', True), + _request_timeout=params.get('_request_timeout'), + collection_formats=collection_formats) + + def delete_tag_for_integration_provider(self, body, name, **kwargs): # noqa: E501 + """Delete a tag for Integration Provider # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.delete_tag_for_integration_provider(body, name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param list[TagObject] body: (required) + :param str name: (required) + :return: None + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('async_req'): + return self.delete_tag_for_integration_provider_with_http_info(body, name, **kwargs) # noqa: E501 + else: + (data) = self.delete_tag_for_integration_provider_with_http_info(body, name, **kwargs) # noqa: E501 + return data + + def delete_tag_for_integration_provider_with_http_info(self, body, name, **kwargs): # noqa: E501 + """Delete a tag for Integration Provider # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.delete_tag_for_integration_provider_with_http_info(body, name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param list[TagObject] body: (required) + :param str name: (required) + :return: None + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['body', 'name'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + + params = locals() + for key, val in six.iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method delete_tag_for_integration_provider" % key + ) + params[key] = val + del params['kwargs'] + # verify the required parameter 'body' is set + if ('body' not in params or + params['body'] is None): + raise ValueError( + "Missing the required parameter `body` when calling `delete_tag_for_integration_provider`") # noqa: E501 + # verify the required parameter 'name' is set + if ('name' not in params or + params['name'] is None): + raise ValueError( + "Missing the required parameter `name` when calling `delete_tag_for_integration_provider`") # noqa: E501 + + collection_formats = {} + + path_params = {} + if 'name' in params: + path_params['name'] = params['name'] # noqa: E501 + + query_params = [] + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + if 'body' in params: + body_params = params['body'] + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 + ['application/json']) # noqa: E501 + + # Authentication setting + auth_settings = ['api_key'] # noqa: E501 + + return self.api_client.call_api( + '/integrations/provider/{name}/tags', 'DELETE', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type=None, # noqa: E501 + auth_settings=auth_settings, + async_req=params.get('async_req'), + _return_http_data_only=params.get('_return_http_data_only'), + _preload_content=params.get('_preload_content', True), + _request_timeout=params.get('_request_timeout'), + collection_formats=collection_formats) + + def get_integration_api(self, name, integration_name, **kwargs): # noqa: E501 + """Get Integration details # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.get_integration_api(name, integration_name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param str name: (required) + :param str integration_name: (required) + :return: IntegrationApi + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('async_req'): + return self.get_integration_api_with_http_info(name, integration_name, **kwargs) # noqa: E501 + else: + (data) = self.get_integration_api_with_http_info(name, integration_name, **kwargs) # noqa: E501 + return data + + def get_integration_api_with_http_info(self, name, integration_name, **kwargs): # noqa: E501 + """Get Integration details # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.get_integration_api_with_http_info(name, integration_name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param str name: (required) + :param str integration_name: (required) + :return: IntegrationApi + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['name', 'integration_name'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + + params = locals() + for key, val in six.iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method get_integration_api" % key + ) + params[key] = val + del params['kwargs'] + # verify the required parameter 'name' is set + if ('name' not in params or + params['name'] is None): + raise ValueError("Missing the required parameter `name` when calling `get_integration_api`") # noqa: E501 + # verify the required parameter 'integration_name' is set + if ('integration_name' not in params or + params['integration_name'] is None): + raise ValueError( + "Missing the required parameter `integration_name` when calling `get_integration_api`") # noqa: E501 + + collection_formats = {} + + path_params = {} + if 'name' in params: + path_params['name'] = params['name'] # noqa: E501 + if 'integration_name' in params: + path_params['integration_name'] = params['integration_name'] # noqa: E501 + + query_params = [] + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + # HTTP header `Accept` + header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # Authentication setting + auth_settings = ['api_key'] # noqa: E501 + + return self.api_client.call_api( + '/integrations/provider/{name}/integration/{integration_name}', 'GET', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type='IntegrationApi', # noqa: E501 + auth_settings=auth_settings, + async_req=params.get('async_req'), + _return_http_data_only=params.get('_return_http_data_only'), + _preload_content=params.get('_preload_content', True), + _request_timeout=params.get('_request_timeout'), + collection_formats=collection_formats) + + def get_integration_apis(self, name, **kwargs): # noqa: E501 + """Get Integrations of an Integration Provider # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.get_integration_apis(name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param str name: (required) + :param bool active_only: + :return: list[IntegrationApi] + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('async_req'): + return self.get_integration_apis_with_http_info(name, **kwargs) # noqa: E501 + else: + (data) = self.get_integration_apis_with_http_info(name, **kwargs) # noqa: E501 + return data + + def get_integration_apis_with_http_info(self, name, **kwargs): # noqa: E501 + """Get Integrations of an Integration Provider # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.get_integration_apis_with_http_info(name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param str name: (required) + :param bool active_only: + :return: list[IntegrationApi] + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['name', 'active_only'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + + params = locals() + for key, val in six.iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method get_integration_apis" % key + ) + params[key] = val + del params['kwargs'] + # verify the required parameter 'name' is set + if ('name' not in params or + params['name'] is None): + raise ValueError("Missing the required parameter `name` when calling `get_integration_apis`") # noqa: E501 + + collection_formats = {} + + path_params = {} + if 'name' in params: + path_params['name'] = params['name'] # noqa: E501 + + query_params = [] + if 'active_only' in params: + query_params.append(('activeOnly', params['active_only'])) # noqa: E501 + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + # HTTP header `Accept` + header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # Authentication setting + auth_settings = ['api_key'] # noqa: E501 + + return self.api_client.call_api( + '/integrations/provider/{name}/integration', 'GET', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type='list[IntegrationApi]', # noqa: E501 + auth_settings=auth_settings, + async_req=params.get('async_req'), + _return_http_data_only=params.get('_return_http_data_only'), + _preload_content=params.get('_preload_content', True), + _request_timeout=params.get('_request_timeout'), + collection_formats=collection_formats) + + def get_integration_available_apis(self, name, **kwargs): # noqa: E501 + """Get Integrations Available for an Integration Provider # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.get_integration_available_apis(name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param str name: (required) + :return: list[str] + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('async_req'): + return self.get_integration_available_apis_with_http_info(name, **kwargs) # noqa: E501 + else: + (data) = self.get_integration_available_apis_with_http_info(name, **kwargs) # noqa: E501 + return data + + def get_integration_available_apis_with_http_info(self, name, **kwargs): # noqa: E501 + """Get Integrations Available for an Integration Provider # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.get_integration_available_apis_with_http_info(name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param str name: (required) + :return: list[str] + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['name'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + + params = locals() + for key, val in six.iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method get_integration_available_apis" % key + ) + params[key] = val + del params['kwargs'] + # verify the required parameter 'name' is set + if ('name' not in params or + params['name'] is None): + raise ValueError( + "Missing the required parameter `name` when calling `get_integration_available_apis`") # noqa: E501 + + collection_formats = {} + + path_params = {} + if 'name' in params: + path_params['name'] = params['name'] # noqa: E501 + + query_params = [] + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + # HTTP header `Accept` + header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # Authentication setting + auth_settings = ['api_key'] # noqa: E501 + + return self.api_client.call_api( + '/integrations/provider/{name}/integration/all', 'GET', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type='list[str]', # noqa: E501 + auth_settings=auth_settings, + async_req=params.get('async_req'), + _return_http_data_only=params.get('_return_http_data_only'), + _preload_content=params.get('_preload_content', True), + _request_timeout=params.get('_request_timeout'), + collection_formats=collection_formats) + + def get_integration_provider(self, name, **kwargs): # noqa: E501 + """Get Integration provider # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.get_integration_provider(name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param str name: (required) + :return: Integration + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('async_req'): + return self.get_integration_provider_with_http_info(name, **kwargs) # noqa: E501 + else: + (data) = self.get_integration_provider_with_http_info(name, **kwargs) # noqa: E501 + return data + + def get_integration_provider_with_http_info(self, name, **kwargs): # noqa: E501 + """Get Integration provider # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.get_integration_provider_with_http_info(name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param str name: (required) + :return: Integration + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['name'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + + params = locals() + for key, val in six.iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method get_integration_provider" % key + ) + params[key] = val + del params['kwargs'] + # verify the required parameter 'name' is set + if ('name' not in params or + params['name'] is None): + raise ValueError( + "Missing the required parameter `name` when calling `get_integration_provider`") # noqa: E501 + + collection_formats = {} + + path_params = {} + if 'name' in params: + path_params['name'] = params['name'] # noqa: E501 + + query_params = [] + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + # HTTP header `Accept` + header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # Authentication setting + auth_settings = ['api_key'] # noqa: E501 + + return self.api_client.call_api( + '/integrations/provider/{name}', 'GET', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type='Integration', # noqa: E501 + auth_settings=auth_settings, + async_req=params.get('async_req'), + _return_http_data_only=params.get('_return_http_data_only'), + _preload_content=params.get('_preload_content', True), + _request_timeout=params.get('_request_timeout'), + collection_formats=collection_formats) + + def get_integration_provider_defs(self, **kwargs): # noqa: E501 + """Get Integration provider definitions # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.get_integration_provider_defs(async_req=True) + >>> result = thread.get() + + :param async_req bool + :return: list[IntegrationDef] + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('async_req'): + return self.get_integration_provider_defs_with_http_info(**kwargs) # noqa: E501 + else: + (data) = self.get_integration_provider_defs_with_http_info(**kwargs) # noqa: E501 + return data + + def get_integration_provider_defs_with_http_info(self, **kwargs): # noqa: E501 + """Get Integration provider definitions # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.get_integration_provider_defs_with_http_info(async_req=True) + >>> result = thread.get() + + :param async_req bool + :return: list[IntegrationDef] + If the method is called asynchronously, + returns the request thread. + """ + + all_params = [] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + + params = locals() + for key, val in six.iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method get_integration_provider_defs" % key + ) + params[key] = val + del params['kwargs'] + + collection_formats = {} + + path_params = {} + + query_params = [] + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + # HTTP header `Accept` + header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # Authentication setting + auth_settings = ['api_key'] # noqa: E501 + + return self.api_client.call_api( + '/integrations/def', 'GET', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type='list[IntegrationDef]', # noqa: E501 + auth_settings=auth_settings, + async_req=params.get('async_req'), + _return_http_data_only=params.get('_return_http_data_only'), + _preload_content=params.get('_preload_content', True), + _request_timeout=params.get('_request_timeout'), + collection_formats=collection_formats) + + def get_integration_providers(self, **kwargs): # noqa: E501 + """Get all Integrations Providers # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.get_integration_providers(async_req=True) + >>> result = thread.get() + + :param async_req bool + :param str type: + :param bool active_only: + :return: list[Integration] + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('async_req'): + return self.get_integration_providers_with_http_info(**kwargs) # noqa: E501 + else: + (data) = self.get_integration_providers_with_http_info(**kwargs) # noqa: E501 + return data + + def get_integration_providers_with_http_info(self, **kwargs): # noqa: E501 + """Get all Integrations Providers # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.get_integration_providers_with_http_info(async_req=True) + >>> result = thread.get() + + :param async_req bool + :param str type: + :param bool active_only: + :return: list[Integration] + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['type', 'active_only'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + + params = locals() + for key, val in six.iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method get_integration_providers" % key + ) + params[key] = val + del params['kwargs'] + + collection_formats = {} + + path_params = {} + + query_params = [] + if 'type' in params: + query_params.append(('type', params['type'])) # noqa: E501 + if 'active_only' in params: + query_params.append(('activeOnly', params['active_only'])) # noqa: E501 + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + # HTTP header `Accept` + header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # Authentication setting + auth_settings = ['api_key'] # noqa: E501 + + return self.api_client.call_api( + '/integrations/provider', 'GET', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type='list[Integration]', # noqa: E501 + auth_settings=auth_settings, + async_req=params.get('async_req'), + _return_http_data_only=params.get('_return_http_data_only'), + _preload_content=params.get('_preload_content', True), + _request_timeout=params.get('_request_timeout'), + collection_formats=collection_formats) + + def get_prompts_with_integration(self, integration_provider, integration_name, **kwargs): # noqa: E501 + """Get the list of prompt templates associated with an integration # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.get_prompts_with_integration(integration_provider, integration_name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param str integration_provider: (required) + :param str integration_name: (required) + :return: list[MessageTemplate] + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('async_req'): + return self.get_prompts_with_integration_with_http_info(integration_provider, integration_name, + **kwargs) # noqa: E501 + else: + (data) = self.get_prompts_with_integration_with_http_info(integration_provider, integration_name, + **kwargs) # noqa: E501 + return data + + def get_prompts_with_integration_with_http_info(self, integration_provider, integration_name, + **kwargs): # noqa: E501 + """Get the list of prompt templates associated with an integration # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.get_prompts_with_integration_with_http_info(integration_provider, integration_name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param str integration_provider: (required) + :param str integration_name: (required) + :return: list[MessageTemplate] + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['integration_provider', 'integration_name'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + + params = locals() + for key, val in six.iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method get_prompts_with_integration" % key + ) + params[key] = val + del params['kwargs'] + # verify the required parameter 'integration_provider' is set + if ('integration_provider' not in params or + params['integration_provider'] is None): + raise ValueError( + "Missing the required parameter `integration_provider` when calling `get_prompts_with_integration`") # noqa: E501 + # verify the required parameter 'integration_name' is set + if ('integration_name' not in params or + params['integration_name'] is None): + raise ValueError( + "Missing the required parameter `integration_name` when calling `get_prompts_with_integration`") # noqa: E501 + + collection_formats = {} + + path_params = {} + if 'integration_provider' in params: + path_params['integration_provider'] = params['integration_provider'] # noqa: E501 + if 'integration_name' in params: + path_params['integration_name'] = params['integration_name'] # noqa: E501 + + query_params = [] + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + # HTTP header `Accept` + header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # Authentication setting + auth_settings = ['api_key'] # noqa: E501 + + return self.api_client.call_api( + '/integrations/provider/{integration_provider}/integration/{integration_name}/prompt', 'GET', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type='list[MessageTemplate]', # noqa: E501 + auth_settings=auth_settings, + async_req=params.get('async_req'), + _return_http_data_only=params.get('_return_http_data_only'), + _preload_content=params.get('_preload_content', True), + _request_timeout=params.get('_request_timeout'), + collection_formats=collection_formats) + + def get_providers_and_integrations(self, **kwargs): # noqa: E501 + """Get Integrations Providers and Integrations combo # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.get_providers_and_integrations(async_req=True) + >>> result = thread.get() + + :param async_req bool + :param str type: + :param bool active_only: + :return: list[str] + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('async_req'): + return self.get_providers_and_integrations_with_http_info(**kwargs) # noqa: E501 + else: + (data) = self.get_providers_and_integrations_with_http_info(**kwargs) # noqa: E501 + return data + + def get_providers_and_integrations_with_http_info(self, **kwargs): # noqa: E501 + """Get Integrations Providers and Integrations combo # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.get_providers_and_integrations_with_http_info(async_req=True) + >>> result = thread.get() + + :param async_req bool + :param str type: + :param bool active_only: + :return: list[str] + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['type', 'active_only'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + + params = locals() + for key, val in six.iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method get_providers_and_integrations" % key + ) + params[key] = val + del params['kwargs'] + + collection_formats = {} + + path_params = {} + + query_params = [] + if 'type' in params: + query_params.append(('type', params['type'])) # noqa: E501 + if 'active_only' in params: + query_params.append(('activeOnly', params['active_only'])) # noqa: E501 + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + # HTTP header `Accept` + header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # Authentication setting + auth_settings = ['api_key'] # noqa: E501 + + return self.api_client.call_api( + '/integrations/all', 'GET', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type='list[str]', # noqa: E501 + auth_settings=auth_settings, + async_req=params.get('async_req'), + _return_http_data_only=params.get('_return_http_data_only'), + _preload_content=params.get('_preload_content', True), + _request_timeout=params.get('_request_timeout'), + collection_formats=collection_formats) + + def get_tags_for_integration(self, name, integration_name, **kwargs): # noqa: E501 + """Get tags by Integration # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.get_tags_for_integration(name, integration_name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param str name: (required) + :param str integration_name: (required) + :return: list[TagObject] + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('async_req'): + return self.get_tags_for_integration_with_http_info(name, integration_name, **kwargs) # noqa: E501 + else: + (data) = self.get_tags_for_integration_with_http_info(name, integration_name, **kwargs) # noqa: E501 + return data + + def get_tags_for_integration_with_http_info(self, name, integration_name, **kwargs): # noqa: E501 + """Get tags by Integration # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.get_tags_for_integration_with_http_info(name, integration_name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param str name: (required) + :param str integration_name: (required) + :return: list[TagObject] + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['name', 'integration_name'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + + params = locals() + for key, val in six.iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method get_tags_for_integration" % key + ) + params[key] = val + del params['kwargs'] + # verify the required parameter 'name' is set + if ('name' not in params or + params['name'] is None): + raise ValueError( + "Missing the required parameter `name` when calling `get_tags_for_integration`") # noqa: E501 + # verify the required parameter 'integration_name' is set + if ('integration_name' not in params or + params['integration_name'] is None): + raise ValueError( + "Missing the required parameter `integration_name` when calling `get_tags_for_integration`") # noqa: E501 + + collection_formats = {} + + path_params = {} + if 'name' in params: + path_params['name'] = params['name'] # noqa: E501 + if 'integration_name' in params: + path_params['integration_name'] = params['integration_name'] # noqa: E501 + + query_params = [] + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + # HTTP header `Accept` + header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # Authentication setting + auth_settings = ['api_key'] # noqa: E501 + + return self.api_client.call_api( + '/integrations/provider/{name}/integration/{integration_name}/tags', 'GET', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type='list[TagObject]', # noqa: E501 + auth_settings=auth_settings, + async_req=params.get('async_req'), + _return_http_data_only=params.get('_return_http_data_only'), + _preload_content=params.get('_preload_content', True), + _request_timeout=params.get('_request_timeout'), + collection_formats=collection_formats) + + def get_tags_for_integration_provider(self, name, **kwargs): # noqa: E501 + """Get tags by Integration Provider # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.get_tags_for_integration_provider(name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param str name: (required) + :return: list[TagObject] + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('async_req'): + return self.get_tags_for_integration_provider_with_http_info(name, **kwargs) # noqa: E501 + else: + (data) = self.get_tags_for_integration_provider_with_http_info(name, **kwargs) # noqa: E501 + return data + + def get_tags_for_integration_provider_with_http_info(self, name, **kwargs): # noqa: E501 + """Get tags by Integration Provider # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.get_tags_for_integration_provider_with_http_info(name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param str name: (required) + :return: list[TagObject] + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['name'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + + params = locals() + for key, val in six.iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method get_tags_for_integration_provider" % key + ) + params[key] = val + del params['kwargs'] + # verify the required parameter 'name' is set + if ('name' not in params or + params['name'] is None): + raise ValueError( + "Missing the required parameter `name` when calling `get_tags_for_integration_provider`") # noqa: E501 + + collection_formats = {} + + path_params = {} + if 'name' in params: + path_params['name'] = params['name'] # noqa: E501 + + query_params = [] + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + # HTTP header `Accept` + header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # Authentication setting + auth_settings = ['api_key'] # noqa: E501 + + return self.api_client.call_api( + '/integrations/provider/{name}/tags', 'GET', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type='list[TagObject]', # noqa: E501 + auth_settings=auth_settings, + async_req=params.get('async_req'), + _return_http_data_only=params.get('_return_http_data_only'), + _preload_content=params.get('_preload_content', True), + _request_timeout=params.get('_request_timeout'), + collection_formats=collection_formats) + + def get_token_usage_for_integration(self, name, integration_name, **kwargs): # noqa: E501 + """Get Token Usage by Integration # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.get_token_usage_for_integration(name, integration_name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param str name: (required) + :param str integration_name: (required) + :return: int + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('async_req'): + return self.get_token_usage_for_integration_with_http_info(name, integration_name, **kwargs) # noqa: E501 + else: + (data) = self.get_token_usage_for_integration_with_http_info(name, integration_name, **kwargs) # noqa: E501 + return data + + def get_token_usage_for_integration_with_http_info(self, name, integration_name, **kwargs): # noqa: E501 + """Get Token Usage by Integration # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.get_token_usage_for_integration_with_http_info(name, integration_name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param str name: (required) + :param str integration_name: (required) + :return: int + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['name', 'integration_name'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + + params = locals() + for key, val in six.iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method get_token_usage_for_integration" % key + ) + params[key] = val + del params['kwargs'] + # verify the required parameter 'name' is set + if ('name' not in params or + params['name'] is None): + raise ValueError( + "Missing the required parameter `name` when calling `get_token_usage_for_integration`") # noqa: E501 + # verify the required parameter 'integration_name' is set + if ('integration_name' not in params or + params['integration_name'] is None): + raise ValueError( + "Missing the required parameter `integration_name` when calling `get_token_usage_for_integration`") # noqa: E501 + + collection_formats = {} + + path_params = {} + if 'name' in params: + path_params['name'] = params['name'] # noqa: E501 + if 'integration_name' in params: + path_params['integration_name'] = params['integration_name'] # noqa: E501 + + query_params = [] + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + # HTTP header `Accept` + header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # Authentication setting + auth_settings = ['api_key'] # noqa: E501 + + return self.api_client.call_api( + '/integrations/provider/{name}/integration/{integration_name}/metrics', 'GET', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type='int', # noqa: E501 + auth_settings=auth_settings, + async_req=params.get('async_req'), + _return_http_data_only=params.get('_return_http_data_only'), + _preload_content=params.get('_preload_content', True), + _request_timeout=params.get('_request_timeout'), + collection_formats=collection_formats) + + def get_token_usage_for_integration_provider(self, name, **kwargs): # noqa: E501 + """Get Token Usage by Integration Provider # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.get_token_usage_for_integration_provider(name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param str name: (required) + :return: dict(str, str) + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('async_req'): + return self.get_token_usage_for_integration_provider_with_http_info(name, **kwargs) # noqa: E501 + else: + (data) = self.get_token_usage_for_integration_provider_with_http_info(name, **kwargs) # noqa: E501 + return data + + def get_token_usage_for_integration_provider_with_http_info(self, name, **kwargs): # noqa: E501 + """Get Token Usage by Integration Provider # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.get_token_usage_for_integration_provider_with_http_info(name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param str name: (required) + :return: dict(str, str) + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['name'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + + params = locals() + for key, val in six.iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method get_token_usage_for_integration_provider" % key + ) + params[key] = val + del params['kwargs'] + # verify the required parameter 'name' is set + if ('name' not in params or + params['name'] is None): + raise ValueError( + "Missing the required parameter `name` when calling `get_token_usage_for_integration_provider`") # noqa: E501 + + collection_formats = {} + + path_params = {} + if 'name' in params: + path_params['name'] = params['name'] # noqa: E501 + + query_params = [] + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + # HTTP header `Accept` + header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # Authentication setting + auth_settings = ['api_key'] # noqa: E501 + + return self.api_client.call_api( + '/integrations/provider/{name}/metrics', 'GET', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type='dict(str, str)', # noqa: E501 + auth_settings=auth_settings, + async_req=params.get('async_req'), + _return_http_data_only=params.get('_return_http_data_only'), + _preload_content=params.get('_preload_content', True), + _request_timeout=params.get('_request_timeout'), + collection_formats=collection_formats) + + def put_tag_for_integration(self, body, name, integration_name, **kwargs): # noqa: E501 + """Put a tag to Integration # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.put_tag_for_integration(body, name, integration_name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param list[TagObject] body: (required) + :param str name: (required) + :param str integration_name: (required) + :return: None + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('async_req'): + return self.put_tag_for_integration_with_http_info(body, name, integration_name, **kwargs) # noqa: E501 + else: + (data) = self.put_tag_for_integration_with_http_info(body, name, integration_name, **kwargs) # noqa: E501 + return data + + def put_tag_for_integration_with_http_info(self, body, name, integration_name, **kwargs): # noqa: E501 + """Put a tag to Integration # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.put_tag_for_integration_with_http_info(body, name, integration_name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param list[TagObject] body: (required) + :param str name: (required) + :param str integration_name: (required) + :return: None + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['body', 'name', 'integration_name'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + + params = locals() + for key, val in six.iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method put_tag_for_integration" % key + ) + params[key] = val + del params['kwargs'] + # verify the required parameter 'body' is set + if ('body' not in params or + params['body'] is None): + raise ValueError( + "Missing the required parameter `body` when calling `put_tag_for_integration`") # noqa: E501 + # verify the required parameter 'name' is set + if ('name' not in params or + params['name'] is None): + raise ValueError( + "Missing the required parameter `name` when calling `put_tag_for_integration`") # noqa: E501 + # verify the required parameter 'integration_name' is set + if ('integration_name' not in params or + params['integration_name'] is None): + raise ValueError( + "Missing the required parameter `integration_name` when calling `put_tag_for_integration`") # noqa: E501 + + collection_formats = {} + + path_params = {} + if 'name' in params: + path_params['name'] = params['name'] # noqa: E501 + if 'integration_name' in params: + path_params['integration_name'] = params['integration_name'] # noqa: E501 + + query_params = [] + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + if 'body' in params: + body_params = params['body'] + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 + ['application/json']) # noqa: E501 + + # Authentication setting + auth_settings = ['api_key'] # noqa: E501 + + return self.api_client.call_api( + '/integrations/provider/{name}/integration/{integration_name}/tags', 'PUT', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type=None, # noqa: E501 + auth_settings=auth_settings, + async_req=params.get('async_req'), + _return_http_data_only=params.get('_return_http_data_only'), + _preload_content=params.get('_preload_content', True), + _request_timeout=params.get('_request_timeout'), + collection_formats=collection_formats) + + def put_tag_for_integration_provider(self, body, name, **kwargs): # noqa: E501 + """Put a tag to Integration Provider # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.put_tag_for_integration_provider(body, name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param list[TagObject] body: (required) + :param str name: (required) + :return: None + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('async_req'): + return self.put_tag_for_integration_provider_with_http_info(body, name, **kwargs) # noqa: E501 + else: + (data) = self.put_tag_for_integration_provider_with_http_info(body, name, **kwargs) # noqa: E501 + return data + + def put_tag_for_integration_provider_with_http_info(self, body, name, **kwargs): # noqa: E501 + """Put a tag to Integration Provider # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.put_tag_for_integration_provider_with_http_info(body, name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param list[TagObject] body: (required) + :param str name: (required) + :return: None + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['body', 'name'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + + params = locals() + for key, val in six.iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method put_tag_for_integration_provider" % key + ) + params[key] = val + del params['kwargs'] + # verify the required parameter 'body' is set + if ('body' not in params or + params['body'] is None): + raise ValueError( + "Missing the required parameter `body` when calling `put_tag_for_integration_provider`") # noqa: E501 + # verify the required parameter 'name' is set + if ('name' not in params or + params['name'] is None): + raise ValueError( + "Missing the required parameter `name` when calling `put_tag_for_integration_provider`") # noqa: E501 + + collection_formats = {} + + path_params = {} + if 'name' in params: + path_params['name'] = params['name'] # noqa: E501 + + query_params = [] + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + if 'body' in params: + body_params = params['body'] + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 + ['application/json']) # noqa: E501 + + # Authentication setting + auth_settings = ['api_key'] # noqa: E501 + + return self.api_client.call_api( + '/integrations/provider/{name}/tags', 'PUT', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type=None, # noqa: E501 + auth_settings=auth_settings, + async_req=params.get('async_req'), + _return_http_data_only=params.get('_return_http_data_only'), + _preload_content=params.get('_preload_content', True), + _request_timeout=params.get('_request_timeout'), + collection_formats=collection_formats) + + def register_token_usage(self, body, name, integration_name, **kwargs): # noqa: E501 + """Register Token usage # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.register_token_usage(body, name, integration_name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param int body: (required) + :param str name: (required) + :param str integration_name: (required) + :return: None + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('async_req'): + return self.register_token_usage_with_http_info(body, name, integration_name, **kwargs) # noqa: E501 + else: + (data) = self.register_token_usage_with_http_info(body, name, integration_name, **kwargs) # noqa: E501 + return data + + def register_token_usage_with_http_info(self, body, name, integration_name, **kwargs): # noqa: E501 + """Register Token usage # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.register_token_usage_with_http_info(body, name, integration_name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param int body: (required) + :param str name: (required) + :param str integration_name: (required) + :return: None + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['body', 'name', 'integration_name'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + + params = locals() + for key, val in six.iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method register_token_usage" % key + ) + params[key] = val + del params['kwargs'] + # verify the required parameter 'body' is set + if ('body' not in params or + params['body'] is None): + raise ValueError("Missing the required parameter `body` when calling `register_token_usage`") # noqa: E501 + # verify the required parameter 'name' is set + if ('name' not in params or + params['name'] is None): + raise ValueError("Missing the required parameter `name` when calling `register_token_usage`") # noqa: E501 + # verify the required parameter 'integration_name' is set + if ('integration_name' not in params or + params['integration_name'] is None): + raise ValueError( + "Missing the required parameter `integration_name` when calling `register_token_usage`") # noqa: E501 + + collection_formats = {} + + path_params = {} + if 'name' in params: + path_params['name'] = params['name'] # noqa: E501 + if 'integration_name' in params: + path_params['integration_name'] = params['integration_name'] # noqa: E501 + + query_params = [] + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + if 'body' in params: + body_params = params['body'] + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 + ['application/json']) # noqa: E501 + + # Authentication setting + auth_settings = ['api_key'] # noqa: E501 + + return self.api_client.call_api( + '/integrations/provider/{name}/integration/{integration_name}/metrics', 'POST', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type=None, # noqa: E501 + auth_settings=auth_settings, + async_req=params.get('async_req'), + _return_http_data_only=params.get('_return_http_data_only'), + _preload_content=params.get('_preload_content', True), + _request_timeout=params.get('_request_timeout'), + collection_formats=collection_formats) + + def save_integration_api(self, body, name, integration_name, **kwargs): # noqa: E501 + """Create or Update Integration # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.save_integration_api(body, name, integration_name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param IntegrationApiUpdate body: (required) + :param str name: (required) + :param str integration_name: (required) + :return: None + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('async_req'): + return self.save_integration_api_with_http_info(body, name, integration_name, **kwargs) # noqa: E501 + else: + (data) = self.save_integration_api_with_http_info(body, name, integration_name, **kwargs) # noqa: E501 + return data + + def save_integration_api_with_http_info(self, body, name, integration_name, **kwargs): # noqa: E501 + """Create or Update Integration # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.save_integration_api_with_http_info(body, name, integration_name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param IntegrationApiUpdate body: (required) + :param str name: (required) + :param str integration_name: (required) + :return: None + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['body', 'name', 'integration_name'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + + params = locals() + for key, val in six.iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method save_integration_api" % key + ) + params[key] = val + del params['kwargs'] + # verify the required parameter 'body' is set + if ('body' not in params or + params['body'] is None): + raise ValueError("Missing the required parameter `body` when calling `save_integration_api`") # noqa: E501 + # verify the required parameter 'name' is set + if ('name' not in params or + params['name'] is None): + raise ValueError("Missing the required parameter `name` when calling `save_integration_api`") # noqa: E501 + # verify the required parameter 'integration_name' is set + if ('integration_name' not in params or + params['integration_name'] is None): + raise ValueError( + "Missing the required parameter `integration_name` when calling `save_integration_api`") # noqa: E501 + + collection_formats = {} + + path_params = {} + if 'name' in params: + path_params['name'] = params['name'] # noqa: E501 + if 'integration_name' in params: + path_params['integration_name'] = params['integration_name'] # noqa: E501 + + query_params = [] + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + if 'body' in params: + body_params = params['body'] + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 + ['application/json']) # noqa: E501 + + # Authentication setting + auth_settings = ['api_key'] # noqa: E501 + + return self.api_client.call_api( + '/integrations/provider/{name}/integration/{integration_name}', 'POST', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type=None, # noqa: E501 + auth_settings=auth_settings, + async_req=params.get('async_req'), + _return_http_data_only=params.get('_return_http_data_only'), + _preload_content=params.get('_preload_content', True), + _request_timeout=params.get('_request_timeout'), + collection_formats=collection_formats) + + def save_integration_provider(self, body, name, **kwargs): # noqa: E501 + """Create or Update Integration provider # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.save_integration_provider(body, name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param IntegrationUpdate body: (required) + :param str name: (required) + :return: None + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('async_req'): + return self.save_integration_provider_with_http_info(body, name, **kwargs) # noqa: E501 + else: + (data) = self.save_integration_provider_with_http_info(body, name, **kwargs) # noqa: E501 + return data + + def save_integration_provider_with_http_info(self, body, name, **kwargs): # noqa: E501 + """Create or Update Integration provider # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.save_integration_provider_with_http_info(body, name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param IntegrationUpdate body: (required) + :param str name: (required) + :return: None + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['body', 'name'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + + params = locals() + for key, val in six.iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method save_integration_provider" % key + ) + params[key] = val + del params['kwargs'] + # verify the required parameter 'body' is set + if ('body' not in params or + params['body'] is None): + raise ValueError( + "Missing the required parameter `body` when calling `save_integration_provider`") # noqa: E501 + # verify the required parameter 'name' is set + if ('name' not in params or + params['name'] is None): + raise ValueError( + "Missing the required parameter `name` when calling `save_integration_provider`") # noqa: E501 + + collection_formats = {} + + path_params = {} + if 'name' in params: + path_params['name'] = params['name'] # noqa: E501 + + query_params = [] + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + if 'body' in params: + body_params = params['body'] + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 + ['application/json']) # noqa: E501 + + # Authentication setting + auth_settings = ['api_key'] # noqa: E501 + + return self.api_client.call_api( + '/integrations/provider/{name}', 'POST', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type=None, # noqa: E501 + auth_settings=auth_settings, + async_req=params.get('async_req'), + _return_http_data_only=params.get('_return_http_data_only'), + _preload_content=params.get('_preload_content', True), + _request_timeout=params.get('_request_timeout'), + collection_formats=collection_formats) diff --git a/src/conductor/client/http/api_client.py b/src/conductor/client/http/api_client.py index 3f1baa43..30af9ed2 100644 --- a/src/conductor/client/http/api_client.py +++ b/src/conductor/client/http/api_client.py @@ -24,25 +24,6 @@ class ApiClient(object): - """Generic API client for Swagger client library builds. - - Swagger generic API client. This client handles the client- - server communication, and is invariant across implementations. Specifics of - the methods and models for each application are generated from the Swagger - templates. - - NOTE: This class is auto generated by the swagger code generator program. - Ref: https://github.com/swagger-api/swagger-codegen - Do not edit the class manually. - - :param configuration: .Configuration object for this client - :param header_name: a header to pass when making calls to the API. - :param header_value: a header value to pass when making calls to - the API. - :param cookie: a cookie to include in the header when making calls - to the API - """ - PRIMITIVE_TYPES = (float, bool, bytes, six.text_type) + six.integer_types NATIVE_TYPES_MAPPING = { 'int': int, diff --git a/src/conductor/client/http/models/integration.py b/src/conductor/client/http/models/integration.py new file mode 100644 index 00000000..a7794155 --- /dev/null +++ b/src/conductor/client/http/models/integration.py @@ -0,0 +1,393 @@ +import pprint +import re # noqa: F401 + +import six + + +class Integration(object): + """NOTE: This class is auto generated by the swagger code generator program. + + Do not edit the class manually. + """ + """ + Attributes: + swagger_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + swagger_types = { + 'category': 'str', + 'configuration': 'dict(str, object)', + 'created_by': 'str', + 'created_on': 'int', + 'description': 'str', + 'enabled': 'bool', + 'models_count': 'int', + 'name': 'str', + 'tags': 'list[TagObject]', + 'type': 'str', + 'updated_by': 'str', + 'updated_on': 'int' + } + + attribute_map = { + 'category': 'category', + 'configuration': 'configuration', + 'created_by': 'createdBy', + 'created_on': 'createdOn', + 'description': 'description', + 'enabled': 'enabled', + 'models_count': 'modelsCount', + 'name': 'name', + 'tags': 'tags', + 'type': 'type', + 'updated_by': 'updatedBy', + 'updated_on': 'updatedOn' + } + + def __init__(self, category=None, configuration=None, created_by=None, created_on=None, description=None, + enabled=None, models_count=None, name=None, tags=None, type=None, updated_by=None, + updated_on=None): # noqa: E501 + """Integration - a model defined in Swagger""" # noqa: E501 + self._category = None + self._configuration = None + self._created_by = None + self._created_on = None + self._description = None + self._enabled = None + self._models_count = None + self._name = None + self._tags = None + self._type = None + self._updated_by = None + self._updated_on = None + self.discriminator = None + if category is not None: + self.category = category + if configuration is not None: + self.configuration = configuration + if created_by is not None: + self.created_by = created_by + if created_on is not None: + self.created_on = created_on + if description is not None: + self.description = description + if enabled is not None: + self.enabled = enabled + if models_count is not None: + self.models_count = models_count + if name is not None: + self.name = name + if tags is not None: + self.tags = tags + if type is not None: + self.type = type + if updated_by is not None: + self.updated_by = updated_by + if updated_on is not None: + self.updated_on = updated_on + + @property + def category(self): + """Gets the category of this Integration. # noqa: E501 + + + :return: The category of this Integration. # noqa: E501 + :rtype: str + """ + return self._category + + @category.setter + def category(self, category): + """Sets the category of this Integration. + + + :param category: The category of this Integration. # noqa: E501 + :type: str + """ + allowed_values = ["API", "AI_MODEL", "VECTOR_DB", "RELATIONAL_DB"] # noqa: E501 + if category not in allowed_values: + raise ValueError( + "Invalid value for `category` ({0}), must be one of {1}" # noqa: E501 + .format(category, allowed_values) + ) + + self._category = category + + @property + def configuration(self): + """Gets the configuration of this Integration. # noqa: E501 + + + :return: The configuration of this Integration. # noqa: E501 + :rtype: dict(str, object) + """ + return self._configuration + + @configuration.setter + def configuration(self, configuration): + """Sets the configuration of this Integration. + + + :param configuration: The configuration of this Integration. # noqa: E501 + :type: dict(str, object) + """ + + self._configuration = configuration + + @property + def created_by(self): + """Gets the created_by of this Integration. # noqa: E501 + + + :return: The created_by of this Integration. # noqa: E501 + :rtype: str + """ + return self._created_by + + @created_by.setter + def created_by(self, created_by): + """Sets the created_by of this Integration. + + + :param created_by: The created_by of this Integration. # noqa: E501 + :type: str + """ + + self._created_by = created_by + + @property + def created_on(self): + """Gets the created_on of this Integration. # noqa: E501 + + + :return: The created_on of this Integration. # noqa: E501 + :rtype: int + """ + return self._created_on + + @created_on.setter + def created_on(self, created_on): + """Sets the created_on of this Integration. + + + :param created_on: The created_on of this Integration. # noqa: E501 + :type: int + """ + + self._created_on = created_on + + @property + def description(self): + """Gets the description of this Integration. # noqa: E501 + + + :return: The description of this Integration. # noqa: E501 + :rtype: str + """ + return self._description + + @description.setter + def description(self, description): + """Sets the description of this Integration. + + + :param description: The description of this Integration. # noqa: E501 + :type: str + """ + + self._description = description + + @property + def enabled(self): + """Gets the enabled of this Integration. # noqa: E501 + + + :return: The enabled of this Integration. # noqa: E501 + :rtype: bool + """ + return self._enabled + + @enabled.setter + def enabled(self, enabled): + """Sets the enabled of this Integration. + + + :param enabled: The enabled of this Integration. # noqa: E501 + :type: bool + """ + + self._enabled = enabled + + @property + def models_count(self): + """Gets the models_count of this Integration. # noqa: E501 + + + :return: The models_count of this Integration. # noqa: E501 + :rtype: int + """ + return self._models_count + + @models_count.setter + def models_count(self, models_count): + """Sets the models_count of this Integration. + + + :param models_count: The models_count of this Integration. # noqa: E501 + :type: int + """ + + self._models_count = models_count + + @property + def name(self): + """Gets the name of this Integration. # noqa: E501 + + + :return: The name of this Integration. # noqa: E501 + :rtype: str + """ + return self._name + + @name.setter + def name(self, name): + """Sets the name of this Integration. + + + :param name: The name of this Integration. # noqa: E501 + :type: str + """ + + self._name = name + + @property + def tags(self): + """Gets the tags of this Integration. # noqa: E501 + + + :return: The tags of this Integration. # noqa: E501 + :rtype: list[TagObject] + """ + return self._tags + + @tags.setter + def tags(self, tags): + """Sets the tags of this Integration. + + + :param tags: The tags of this Integration. # noqa: E501 + :type: list[TagObject] + """ + + self._tags = tags + + @property + def type(self): + """Gets the type of this Integration. # noqa: E501 + + + :return: The type of this Integration. # noqa: E501 + :rtype: str + """ + return self._type + + @type.setter + def type(self, type): + """Sets the type of this Integration. + + + :param type: The type of this Integration. # noqa: E501 + :type: str + """ + + self._type = type + + @property + def updated_by(self): + """Gets the updated_by of this Integration. # noqa: E501 + + + :return: The updated_by of this Integration. # noqa: E501 + :rtype: str + """ + return self._updated_by + + @updated_by.setter + def updated_by(self, updated_by): + """Sets the updated_by of this Integration. + + + :param updated_by: The updated_by of this Integration. # noqa: E501 + :type: str + """ + + self._updated_by = updated_by + + @property + def updated_on(self): + """Gets the updated_on of this Integration. # noqa: E501 + + + :return: The updated_on of this Integration. # noqa: E501 + :rtype: int + """ + return self._updated_on + + @updated_on.setter + def updated_on(self, updated_on): + """Sets the updated_on of this Integration. + + + :param updated_on: The updated_on of this Integration. # noqa: E501 + :type: int + """ + + self._updated_on = updated_on + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.swagger_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + if issubclass(Integration, dict): + for key, value in self.items(): + result[key] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, Integration): + return False + + return self.__dict__ == other.__dict__ + + def __ne__(self, other): + """Returns true if both objects are not equal""" + return not self == other diff --git a/src/conductor/client/http/models/integration_api.py b/src/conductor/client/http/models/integration_api.py new file mode 100644 index 00000000..065c3437 --- /dev/null +++ b/src/conductor/client/http/models/integration_api.py @@ -0,0 +1,330 @@ +import pprint +import re # noqa: F401 + +import six + + +class IntegrationApi(object): + """ + Attributes: + swagger_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + swagger_types = { + 'api': 'str', + 'configuration': 'dict(str, object)', + 'created_by': 'str', + 'created_on': 'int', + 'description': 'str', + 'enabled': 'bool', + 'integration_name': 'str', + 'tags': 'list[TagObject]', + 'updated_by': 'str', + 'updated_on': 'int' + } + + attribute_map = { + 'api': 'api', + 'configuration': 'configuration', + 'created_by': 'createdBy', + 'created_on': 'createdOn', + 'description': 'description', + 'enabled': 'enabled', + 'integration_name': 'integrationName', + 'tags': 'tags', + 'updated_by': 'updatedBy', + 'updated_on': 'updatedOn' + } + + def __init__(self, api=None, configuration=None, created_by=None, created_on=None, description=None, enabled=None, + integration_name=None, tags=None, updated_by=None, updated_on=None): # noqa: E501 + """IntegrationApi - a model defined in Swagger""" # noqa: E501 + self._api = None + self._configuration = None + self._created_by = None + self._created_on = None + self._description = None + self._enabled = None + self._integration_name = None + self._tags = None + self._updated_by = None + self._updated_on = None + self.discriminator = None + if api is not None: + self.api = api + if configuration is not None: + self.configuration = configuration + if created_by is not None: + self.created_by = created_by + if created_on is not None: + self.created_on = created_on + if description is not None: + self.description = description + if enabled is not None: + self.enabled = enabled + if integration_name is not None: + self.integration_name = integration_name + if tags is not None: + self.tags = tags + if updated_by is not None: + self.updated_by = updated_by + if updated_on is not None: + self.updated_on = updated_on + + @property + def api(self): + """Gets the api of this IntegrationApi. # noqa: E501 + + + :return: The api of this IntegrationApi. # noqa: E501 + :rtype: str + """ + return self._api + + @api.setter + def api(self, api): + """Sets the api of this IntegrationApi. + + + :param api: The api of this IntegrationApi. # noqa: E501 + :type: str + """ + + self._api = api + + @property + def configuration(self): + """Gets the configuration of this IntegrationApi. # noqa: E501 + + + :return: The configuration of this IntegrationApi. # noqa: E501 + :rtype: dict(str, object) + """ + return self._configuration + + @configuration.setter + def configuration(self, configuration): + """Sets the configuration of this IntegrationApi. + + + :param configuration: The configuration of this IntegrationApi. # noqa: E501 + :type: dict(str, object) + """ + + self._configuration = configuration + + @property + def created_by(self): + """Gets the created_by of this IntegrationApi. # noqa: E501 + + + :return: The created_by of this IntegrationApi. # noqa: E501 + :rtype: str + """ + return self._created_by + + @created_by.setter + def created_by(self, created_by): + """Sets the created_by of this IntegrationApi. + + + :param created_by: The created_by of this IntegrationApi. # noqa: E501 + :type: str + """ + + self._created_by = created_by + + @property + def created_on(self): + """Gets the created_on of this IntegrationApi. # noqa: E501 + + + :return: The created_on of this IntegrationApi. # noqa: E501 + :rtype: int + """ + return self._created_on + + @created_on.setter + def created_on(self, created_on): + """Sets the created_on of this IntegrationApi. + + + :param created_on: The created_on of this IntegrationApi. # noqa: E501 + :type: int + """ + + self._created_on = created_on + + @property + def description(self): + """Gets the description of this IntegrationApi. # noqa: E501 + + + :return: The description of this IntegrationApi. # noqa: E501 + :rtype: str + """ + return self._description + + @description.setter + def description(self, description): + """Sets the description of this IntegrationApi. + + + :param description: The description of this IntegrationApi. # noqa: E501 + :type: str + """ + + self._description = description + + @property + def enabled(self): + """Gets the enabled of this IntegrationApi. # noqa: E501 + + + :return: The enabled of this IntegrationApi. # noqa: E501 + :rtype: bool + """ + return self._enabled + + @enabled.setter + def enabled(self, enabled): + """Sets the enabled of this IntegrationApi. + + + :param enabled: The enabled of this IntegrationApi. # noqa: E501 + :type: bool + """ + + self._enabled = enabled + + @property + def integration_name(self): + """Gets the integration_name of this IntegrationApi. # noqa: E501 + + + :return: The integration_name of this IntegrationApi. # noqa: E501 + :rtype: str + """ + return self._integration_name + + @integration_name.setter + def integration_name(self, integration_name): + """Sets the integration_name of this IntegrationApi. + + + :param integration_name: The integration_name of this IntegrationApi. # noqa: E501 + :type: str + """ + + self._integration_name = integration_name + + @property + def tags(self): + """Gets the tags of this IntegrationApi. # noqa: E501 + + + :return: The tags of this IntegrationApi. # noqa: E501 + :rtype: list[TagObject] + """ + return self._tags + + @tags.setter + def tags(self, tags): + """Sets the tags of this IntegrationApi. + + + :param tags: The tags of this IntegrationApi. # noqa: E501 + :type: list[TagObject] + """ + + self._tags = tags + + @property + def updated_by(self): + """Gets the updated_by of this IntegrationApi. # noqa: E501 + + + :return: The updated_by of this IntegrationApi. # noqa: E501 + :rtype: str + """ + return self._updated_by + + @updated_by.setter + def updated_by(self, updated_by): + """Sets the updated_by of this IntegrationApi. + + + :param updated_by: The updated_by of this IntegrationApi. # noqa: E501 + :type: str + """ + + self._updated_by = updated_by + + @property + def updated_on(self): + """Gets the updated_on of this IntegrationApi. # noqa: E501 + + + :return: The updated_on of this IntegrationApi. # noqa: E501 + :rtype: int + """ + return self._updated_on + + @updated_on.setter + def updated_on(self, updated_on): + """Sets the updated_on of this IntegrationApi. + + + :param updated_on: The updated_on of this IntegrationApi. # noqa: E501 + :type: int + """ + + self._updated_on = updated_on + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.swagger_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + if issubclass(IntegrationApi, dict): + for key, value in self.items(): + result[key] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, IntegrationApi): + return False + + return self.__dict__ == other.__dict__ + + def __ne__(self, other): + """Returns true if both objects are not equal""" + return not self == other diff --git a/src/conductor/client/http/models/integration_def.py b/src/conductor/client/http/models/integration_def.py new file mode 100644 index 00000000..04d72a81 --- /dev/null +++ b/src/conductor/client/http/models/integration_def.py @@ -0,0 +1,310 @@ +import pprint +import re # noqa: F401 + +import six + + +class IntegrationDef(object): + """ + Attributes: + swagger_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + swagger_types = { + 'category': 'str', + 'category_label': 'str', + 'configuration': 'dict(str, object)', + 'description': 'str', + 'enabled': 'bool', + 'icon_name': 'str', + 'name': 'str', + 'tags': 'list[str]', + 'type': 'str' + } + + attribute_map = { + 'category': 'category', + 'category_label': 'categoryLabel', + 'configuration': 'configuration', + 'description': 'description', + 'enabled': 'enabled', + 'icon_name': 'iconName', + 'name': 'name', + 'tags': 'tags', + 'type': 'type' + } + + def __init__(self, category=None, category_label=None, configuration=None, description=None, enabled=None, + icon_name=None, name=None, tags=None, type=None): # noqa: E501 + """IntegrationDef - a model defined in Swagger""" # noqa: E501 + self._category = None + self._category_label = None + self._configuration = None + self._description = None + self._enabled = None + self._icon_name = None + self._name = None + self._tags = None + self._type = None + self.discriminator = None + if category is not None: + self.category = category + if category_label is not None: + self.category_label = category_label + if configuration is not None: + self.configuration = configuration + if description is not None: + self.description = description + if enabled is not None: + self.enabled = enabled + if icon_name is not None: + self.icon_name = icon_name + if name is not None: + self.name = name + if tags is not None: + self.tags = tags + if type is not None: + self.type = type + + @property + def category(self): + """Gets the category of this IntegrationDef. # noqa: E501 + + + :return: The category of this IntegrationDef. # noqa: E501 + :rtype: str + """ + return self._category + + @category.setter + def category(self, category): + """Sets the category of this IntegrationDef. + + + :param category: The category of this IntegrationDef. # noqa: E501 + :type: str + """ + allowed_values = ["API", "AI_MODEL", "VECTOR_DB", "RELATIONAL_DB"] # noqa: E501 + if category not in allowed_values: + raise ValueError( + "Invalid value for `category` ({0}), must be one of {1}" # noqa: E501 + .format(category, allowed_values) + ) + + self._category = category + + @property + def category_label(self): + """Gets the category_label of this IntegrationDef. # noqa: E501 + + + :return: The category_label of this IntegrationDef. # noqa: E501 + :rtype: str + """ + return self._category_label + + @category_label.setter + def category_label(self, category_label): + """Sets the category_label of this IntegrationDef. + + + :param category_label: The category_label of this IntegrationDef. # noqa: E501 + :type: str + """ + + self._category_label = category_label + + @property + def configuration(self): + """Gets the configuration of this IntegrationDef. # noqa: E501 + + + :return: The configuration of this IntegrationDef. # noqa: E501 + :rtype: dict(str, object) + """ + return self._configuration + + @configuration.setter + def configuration(self, configuration): + """Sets the configuration of this IntegrationDef. + + + :param configuration: The configuration of this IntegrationDef. # noqa: E501 + :type: dict(str, object) + """ + + self._configuration = configuration + + @property + def description(self): + """Gets the description of this IntegrationDef. # noqa: E501 + + + :return: The description of this IntegrationDef. # noqa: E501 + :rtype: str + """ + return self._description + + @description.setter + def description(self, description): + """Sets the description of this IntegrationDef. + + + :param description: The description of this IntegrationDef. # noqa: E501 + :type: str + """ + + self._description = description + + @property + def enabled(self): + """Gets the enabled of this IntegrationDef. # noqa: E501 + + + :return: The enabled of this IntegrationDef. # noqa: E501 + :rtype: bool + """ + return self._enabled + + @enabled.setter + def enabled(self, enabled): + """Sets the enabled of this IntegrationDef. + + + :param enabled: The enabled of this IntegrationDef. # noqa: E501 + :type: bool + """ + + self._enabled = enabled + + @property + def icon_name(self): + """Gets the icon_name of this IntegrationDef. # noqa: E501 + + + :return: The icon_name of this IntegrationDef. # noqa: E501 + :rtype: str + """ + return self._icon_name + + @icon_name.setter + def icon_name(self, icon_name): + """Sets the icon_name of this IntegrationDef. + + + :param icon_name: The icon_name of this IntegrationDef. # noqa: E501 + :type: str + """ + + self._icon_name = icon_name + + @property + def name(self): + """Gets the name of this IntegrationDef. # noqa: E501 + + + :return: The name of this IntegrationDef. # noqa: E501 + :rtype: str + """ + return self._name + + @name.setter + def name(self, name): + """Sets the name of this IntegrationDef. + + + :param name: The name of this IntegrationDef. # noqa: E501 + :type: str + """ + + self._name = name + + @property + def tags(self): + """Gets the tags of this IntegrationDef. # noqa: E501 + + + :return: The tags of this IntegrationDef. # noqa: E501 + :rtype: list[str] + """ + return self._tags + + @tags.setter + def tags(self, tags): + """Sets the tags of this IntegrationDef. + + + :param tags: The tags of this IntegrationDef. # noqa: E501 + :type: list[str] + """ + + self._tags = tags + + @property + def type(self): + """Gets the type of this IntegrationDef. # noqa: E501 + + + :return: The type of this IntegrationDef. # noqa: E501 + :rtype: str + """ + return self._type + + @type.setter + def type(self, type): + """Sets the type of this IntegrationDef. + + + :param type: The type of this IntegrationDef. # noqa: E501 + :type: str + """ + + self._type = type + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.swagger_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + if issubclass(IntegrationDef, dict): + for key, value in self.items(): + result[key] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, IntegrationDef): + return False + + return self.__dict__ == other.__dict__ + + def __ne__(self, other): + """Returns true if both objects are not equal""" + return not self == other diff --git a/src/conductor/client/http/models/integration_update.py b/src/conductor/client/http/models/integration_update.py new file mode 100644 index 00000000..1dc0841b --- /dev/null +++ b/src/conductor/client/http/models/integration_update.py @@ -0,0 +1,209 @@ +import pprint +import re # noqa: F401 + +import six + + +class IntegrationUpdate(object): + """NOTE: This class is auto generated by the swagger code generator program. + + Do not edit the class manually. + """ + """ + Attributes: + swagger_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + swagger_types = { + 'category': 'str', + 'configuration': 'dict(str, object)', + 'description': 'str', + 'enabled': 'bool', + 'type': 'str' + } + + attribute_map = { + 'category': 'category', + 'configuration': 'configuration', + 'description': 'description', + 'enabled': 'enabled', + 'type': 'type' + } + + def __init__(self, category=None, configuration=None, description=None, enabled=None, type=None): # noqa: E501 + """IntegrationUpdate - a model defined in Swagger""" # noqa: E501 + self._category = None + self._configuration = None + self._description = None + self._enabled = None + self._type = None + self.discriminator = None + if category is not None: + self.category = category + if configuration is not None: + self.configuration = configuration + if description is not None: + self.description = description + if enabled is not None: + self.enabled = enabled + if type is not None: + self.type = type + + @property + def category(self): + """Gets the category of this IntegrationUpdate. # noqa: E501 + + + :return: The category of this IntegrationUpdate. # noqa: E501 + :rtype: str + """ + return self._category + + @category.setter + def category(self, category): + """Sets the category of this IntegrationUpdate. + + + :param category: The category of this IntegrationUpdate. # noqa: E501 + :type: str + """ + allowed_values = ["API", "AI_MODEL", "VECTOR_DB", "RELATIONAL_DB"] # noqa: E501 + if category not in allowed_values: + raise ValueError( + "Invalid value for `category` ({0}), must be one of {1}" # noqa: E501 + .format(category, allowed_values) + ) + + self._category = category + + @property + def configuration(self): + """Gets the configuration of this IntegrationUpdate. # noqa: E501 + + + :return: The configuration of this IntegrationUpdate. # noqa: E501 + :rtype: dict(str, object) + """ + return self._configuration + + @configuration.setter + def configuration(self, configuration): + """Sets the configuration of this IntegrationUpdate. + + + :param configuration: The configuration of this IntegrationUpdate. # noqa: E501 + :type: dict(str, object) + """ + + self._configuration = configuration + + @property + def description(self): + """Gets the description of this IntegrationUpdate. # noqa: E501 + + + :return: The description of this IntegrationUpdate. # noqa: E501 + :rtype: str + """ + return self._description + + @description.setter + def description(self, description): + """Sets the description of this IntegrationUpdate. + + + :param description: The description of this IntegrationUpdate. # noqa: E501 + :type: str + """ + + self._description = description + + @property + def enabled(self): + """Gets the enabled of this IntegrationUpdate. # noqa: E501 + + + :return: The enabled of this IntegrationUpdate. # noqa: E501 + :rtype: bool + """ + return self._enabled + + @enabled.setter + def enabled(self, enabled): + """Sets the enabled of this IntegrationUpdate. + + + :param enabled: The enabled of this IntegrationUpdate. # noqa: E501 + :type: bool + """ + + self._enabled = enabled + + @property + def type(self): + """Gets the type of this IntegrationUpdate. # noqa: E501 + + + :return: The type of this IntegrationUpdate. # noqa: E501 + :rtype: str + """ + return self._type + + @type.setter + def type(self, type): + """Sets the type of this IntegrationUpdate. + + + :param type: The type of this IntegrationUpdate. # noqa: E501 + :type: str + """ + + self._type = type + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.swagger_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + if issubclass(IntegrationUpdate, dict): + for key, value in self.items(): + result[key] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, IntegrationUpdate): + return False + + return self.__dict__ == other.__dict__ + + def __ne__(self, other): + """Returns true if both objects are not equal""" + return not self == other diff --git a/src/conductor/hello2.py b/src/conductor/hello2.py index e9a83d2e..ef36ddd8 100644 --- a/src/conductor/hello2.py +++ b/src/conductor/hello2.py @@ -4,8 +4,8 @@ from conductor.client.workflow.task.llm_tasks.llm_text_complete import LlmTextComplete from conductor.client.workflow.task.simple_task import SimpleTask from conductor.client.http.models import Task, TaskResult -from conductor.client.ai.ai_orchestrator import AIOrchestrator -from conductor.client.ai.ai_orchestrator import AIConfiguration +from conductor.client.ai.orchestrator import AIOrchestrator +from conductor.client.ai.orchestrator import AIConfiguration from conductor.client.configuration.configuration import Configuration from conductor.client.configuration.settings.authentication_settings import AuthenticationSettings From ec89e766254f7bf44ba27b3085b7e97ae35cd1b4 Mon Sep 17 00:00:00 2001 From: Viren Baraiya Date: Sat, 2 Dec 2023 09:32:36 -0800 Subject: [PATCH 4/9] more changes --- docs/workflow/README.md | 2 +- .../api/integration_resource_ap_interfacei.py | 72 ------------- src/conductor/client/integration_client.py | 100 ++++++++++++++++++ .../client/orkes/orkes_base_client.py | 2 +- .../client/orkes/orkes_integration_client.py | 88 +++++++++++++++ .../client/orkes/orkes_metadata_client.py | 7 +- .../client/orkes/orkes_workflow_client.py | 43 ++++---- src/conductor/client/workflow_client.py | 13 ++- 8 files changed, 226 insertions(+), 101 deletions(-) delete mode 100644 src/conductor/client/http/api/integration_resource_ap_interfacei.py create mode 100644 src/conductor/client/integration_client.py create mode 100644 src/conductor/client/orkes/orkes_integration_client.py diff --git a/docs/workflow/README.md b/docs/workflow/README.md index 4e4983a2..cb30a8b7 100644 --- a/docs/workflow/README.md +++ b/docs/workflow/README.md @@ -105,7 +105,7 @@ workflow_client.restart_workflow(workflow_id, use_latest_def=True) When called, the task in the failed state is scheduled again, and the workflow moves to RUNNING status. If resumeSubworkflowTasks is set and the last failed task was a sub-workflow, the server restarts the sub-workflow from the failed task. If set to false, the sub-workflow is re-executed. ```python -workflow_client.retry_workflow(workflow_id, resumeSubworkflowTasks=True) +workflow_client.retry_workflow(workflow_id, resume_subworkflow_tasks=True) ``` ### Skip task from workflow diff --git a/src/conductor/client/http/api/integration_resource_ap_interfacei.py b/src/conductor/client/http/api/integration_resource_ap_interfacei.py deleted file mode 100644 index 17ed427a..00000000 --- a/src/conductor/client/http/api/integration_resource_ap_interfacei.py +++ /dev/null @@ -1,72 +0,0 @@ -from __future__ import absolute_import - -import re # noqa: F401 - - -class IntegrationResourceApi(object): - def associate_prompt_with_integration(self, integration_provider, integration_name, prompt_name, - **kwargs): # noqa: E501 - pass - - def delete_integration_api(self, name, integration_name, **kwargs): # noqa: E501 - pass - - def delete_integration_provider(self, name, **kwargs): # noqa: E501 - pass - - def delete_tag_for_integration(self, body, name, integration_name, **kwargs): # noqa: E501 - pass - - def delete_tag_for_integration_provider(self, body, name, **kwargs): # noqa: E501 - pass - - def get_integration_api(self, name, integration_name, **kwargs): # noqa: E501 - pass - - def get_integration_apis(self, name, **kwargs): # noqa: E501 - pass - - def get_integration_available_apis(self, name, **kwargs): # noqa: E501 - pass - - def get_integration_provider(self, name, **kwargs): # noqa: E501 - pass - - def get_integration_provider_defs(self, **kwargs): # noqa: E501 - pass - - def get_integration_providers(self, **kwargs): # noqa: E501 - pass - - def get_prompts_with_integration(self, integration_provider, integration_name, **kwargs): # noqa: E501 - pass - - def get_providers_and_integrations(self, **kwargs): # noqa: E501 - pass - - def get_tags_for_integration(self, name, integration_name, **kwargs): # noqa: E501 - pass - - def get_tags_for_integration_provider(self, name, **kwargs): # noqa: E501 - pass - - def get_token_usage_for_integration(self, name, integration_name, **kwargs): # noqa: E501 - pass - - def get_token_usage_for_integration_provider(self, name, **kwargs): # noqa: E501 - pass - - def put_tag_for_integration(self, body, name, integration_name, **kwargs): # noqa: E501 - pass - - def put_tag_for_integration_provider(self, body, name, **kwargs): # noqa: E501 - pass - - def register_token_usage(self, body, name, integration_name, **kwargs): # noqa: E501 - pass - - def save_integration_api(self, body, name, integration_name, **kwargs): # noqa: E501 - pass - - def save_integration_provider(self, body, name, **kwargs): # noqa: E501 - pass diff --git a/src/conductor/client/integration_client.py b/src/conductor/client/integration_client.py new file mode 100644 index 00000000..9dd98baf --- /dev/null +++ b/src/conductor/client/integration_client.py @@ -0,0 +1,100 @@ +from __future__ import absolute_import +from abc import ABC, abstractmethod + + +class IntegrationClient(ABC): + """Client for managing integrations with external systems. Some examples of integrations are: + 1. AI/LLM providers (e.g. OpenAI, HuggingFace) + 2. Vector DBs (Pinecone, Weaviate etc.) + 3. Kafka + 4. Relational databases + + Integrations are configured as integration -> api with 1->N cardinality. + APIs are the underlying resources for an integration and depending on the type of integration they represent underlying resources. + Examples: + LLM integrations + The integration specifies the name of the integration unique to your environment, api keys and endpoint used. + APIs are the models (e.g. text-davinci-003, or text-embedding-ada-002) + + Vector DB integrations, + The integration represents the cluster, specifies the name of the integration unique to your environment, api keys and endpoint used. + APIs are the indexes (e.g. pinecone) or class (e.g. for weaviate) + + Kafka + The integration represents the cluster, specifies the name of the integration unique to your environment, api keys and endpoint used. + APIs are the topics that are configured for use within this kafka cluster + """ + + @abstractmethod + def associate_prompt_with_integration(self, ai_integration, model_name, prompt_name): + """Associate a prompt with an AI integration and model""" + pass + + @abstractmethod + def delete_integration_api(self, api_name, integration_name): + """Delete a specific integration api for a given integration""" + pass + + def delete_integration(self, integration_name): + """Delete an integration""" + pass + + def get_integration_api(self, name, integration_name): + pass + + def get_integration_apis(self, name): + pass + + def get_integration_available_apis(self, name): + pass + + def get_integration_provider(self, name): + pass + + def get_integration_provider_defs(self): + pass + + def get_integration_providers(self): + pass + + def get_prompts_with_integration(self, integration_provider, integration_name): + pass + + def get_providers_and_integrations(self): + pass + + def get_token_usage_for_integration(self, name, integration_name): + pass + + def get_token_usage_for_integration_provider(self, name): + pass + + def register_token_usage(self, body, name, integration_name): + pass + + def save_integration_api(self, body, name, integration_name): + pass + + def save_integration_provider(self, body, name): + pass + + # Tags + + def delete_tag_for_integration(self, body, tag_name, integration_name): + """Delete an integration""" + pass + + def delete_tag_for_integration_provider(self, body, name): + pass + + def put_tag_for_integration(self, body, name, integration_name): + pass + + def put_tag_for_integration_provider(self, body, name): + pass + + def get_tags_for_integration(self, name, integration_name): + pass + + def get_tags_for_integration_provider(self, name): + pass diff --git a/src/conductor/client/orkes/orkes_base_client.py b/src/conductor/client/orkes/orkes_base_client.py index 6e8c20b5..0b6e6676 100644 --- a/src/conductor/client/orkes/orkes_base_client.py +++ b/src/conductor/client/orkes/orkes_base_client.py @@ -13,6 +13,7 @@ import logging + class OrkesBaseClient(object): def __init__(self, configuration: Configuration): self.api_client = ApiClient(configuration) @@ -29,4 +30,3 @@ def __init__(self, configuration: Configuration): self.authorizationResourceApi = AuthorizationResourceApi(self.api_client) self.schedulerResourceApi = SchedulerResourceApi(self.api_client) self.tagsApi = TagsApi(self.api_client) - \ No newline at end of file diff --git a/src/conductor/client/orkes/orkes_integration_client.py b/src/conductor/client/orkes/orkes_integration_client.py new file mode 100644 index 00000000..e56dbe54 --- /dev/null +++ b/src/conductor/client/orkes/orkes_integration_client.py @@ -0,0 +1,88 @@ +from __future__ import absolute_import +from abc import ABC, abstractmethod + +from conductor.client.configuration.configuration import Configuration +from conductor.client.integration_client import IntegrationClient +from conductor.client.orkes.orkes_base_client import OrkesBaseClient +from conductor.client.exceptions.api_exception_handler import api_exception_handler, for_all_methods + + +@for_all_methods(api_exception_handler, ["__init__"]) +class OrkesIntegrationClient(OrkesBaseClient, IntegrationClient): + + def __init__(self, configuration: Configuration): + super(OrkesIntegrationClient, self).__init__(configuration) + + @abstractmethod + def associate_prompt_with_integration(self, ai_integration, model_name, prompt_name): + """Associate a prompt with an AI integration and model""" + pass + + @abstractmethod + def delete_integration_api(self, api_name, integration_name): + """Delete a specific integration api for a given integration""" + pass + + def delete_integration(self, integration_name): + """Delete an integration""" + pass + + def get_integration_api(self, name, integration_name): + pass + + def get_integration_apis(self, name): + pass + + def get_integration_available_apis(self, name): + pass + + def get_integration_provider(self, name): + pass + + def get_integration_provider_defs(self): + pass + + def get_integration_providers(self): + pass + + def get_prompts_with_integration(self, integration_provider, integration_name): + pass + + def get_providers_and_integrations(self): + pass + + def get_token_usage_for_integration(self, name, integration_name): + pass + + def get_token_usage_for_integration_provider(self, name): + pass + + def register_token_usage(self, body, name, integration_name): + pass + + def save_integration_api(self, body, name, integration_name): + pass + + def save_integration_provider(self, body, name): + pass + + # Tags + + def delete_tag_for_integration(self, body, tag_name, integration_name): + """Delete an integration""" + pass + + def delete_tag_for_integration_provider(self, body, name): + pass + + def put_tag_for_integration(self, body, name, integration_name): + pass + + def put_tag_for_integration_provider(self, body, name): + pass + + def get_tags_for_integration(self, name, integration_name): + pass + + def get_tags_for_integration_provider(self, name): + pass diff --git a/src/conductor/client/orkes/orkes_metadata_client.py b/src/conductor/client/orkes/orkes_metadata_client.py index cf0f17db..89a9cbfa 100644 --- a/src/conductor/client/orkes/orkes_metadata_client.py +++ b/src/conductor/client/orkes/orkes_metadata_client.py @@ -90,8 +90,7 @@ def getWorkflowRateLimit(self, workflowName: str) -> Optional[int]: return None def removeWorkflowRateLimit(self, workflowName: str): - currentRateLimit = self.getWorkflowRateLimit(workflowName) - - if currentRateLimit: - rateLimitTag = RateLimitTag(workflowName, currentRateLimit) + current_rate_limit = self.getWorkflowRateLimit(workflowName) + if current_rate_limit: + rateLimitTag = RateLimitTag(workflowName, current_rate_limit) self.tagsApi.delete_workflow_tag(rateLimitTag, workflowName) diff --git a/src/conductor/client/orkes/orkes_workflow_client.py b/src/conductor/client/orkes/orkes_workflow_client.py index eb8d1675..7ea93065 100644 --- a/src/conductor/client/orkes/orkes_workflow_client.py +++ b/src/conductor/client/orkes/orkes_workflow_client.py @@ -9,21 +9,22 @@ from conductor.client.orkes.orkes_base_client import OrkesBaseClient from conductor.client.exceptions.api_exception_handler import api_exception_handler, for_all_methods + @for_all_methods(api_exception_handler, ["__init__"]) class OrkesWorkflowClient(OrkesBaseClient, WorkflowClient): def __init__( - self, - configuration: Configuration - ): + self, + configuration: Configuration + ): super(OrkesWorkflowClient, self).__init__(configuration) def startWorkflowByName( - self, - name: str, - input: dict[str, object], - version: Optional[int] = None, - correlationId: Optional[str] = None, - priority: Optional[int] = None, + self, + name: str, + input: dict[str, object], + version: Optional[int] = None, + correlationId: Optional[str] = None, + priority: Optional[int] = None, ) -> str: kwargs = {} if version: @@ -39,15 +40,15 @@ def start_workflow(self, start_workflow_request: StartWorkflowRequest) -> str: return self.workflowResourceApi.start_workflow(start_workflow_request) def execute_workflow( - self, - startWorkflowRequest: StartWorkflowRequest, - requestId: str, - name: str, - version: int, - waitUntilTaskRef: Optional[str] = None + self, + start_workflow_request: StartWorkflowRequest, + request_id: str, + name: str, + version: int, + wait_until_task_ref: Optional[str] = None ) -> WorkflowRun: - kwargs = { "wait_until_task_ref" : waitUntilTaskRef } if waitUntilTaskRef else {} - return self.workflowResourceApi.execute_workflow(startWorkflowRequest, requestId, name, version, **kwargs) + kwargs = {"wait_until_task_ref": wait_until_task_ref} if wait_until_task_ref else {} + return self.workflowResourceApi.execute_workflow(start_workflow_request, request_id, name, version, **kwargs) def pause_workflow(self, workflow_id: str): self.workflowResourceApi.pause_workflow1(workflow_id) @@ -61,11 +62,11 @@ def restart_workflow(self, workflow_id: str, use_latest_def: Optional[bool] = Fa def rerun_workflow(self, workflow_id: str, rerun_workflow_request: RerunWorkflowRequest): self.workflowResourceApi.rerun(rerun_workflow_request, workflow_id) - def retry_workflow(self, workflowId: str, resumeSubworkflowTasks: Optional[bool] = False): - self.workflowResourceApi.retry1(workflowId, resume_subworkflow_tasks=resumeSubworkflowTasks) + def retry_workflow(self, workflow_id: str, resume_subworkflow_tasks: Optional[bool] = False): + self.workflowResourceApi.retry1(workflow_id, resume_subworkflow_tasks=resume_subworkflow_tasks) def terminate_workflow(self, workflow_id: str, reason: Optional[str] = None): - kwargs = { "reason" : reason } if reason else {} + kwargs = {"reason": reason} if reason else {} self.workflowResourceApi.terminate1(workflow_id, **kwargs) def get_workflow(self, workflow_id: str, include_tasks: Optional[bool] = True) -> Workflow: @@ -78,4 +79,4 @@ def skip_task_from_workflow(self, workflow_id: str, task_reference_name: str): self.workflowResourceApi.skip_task_from_workflow(workflow_id, task_reference_name) def test_workflow(self, test_request: WorkflowTestRequest) -> Workflow: - return self.workflowResourceApi.test_workflow(test_request) \ No newline at end of file + return self.workflowResourceApi.test_workflow(test_request) diff --git a/src/conductor/client/workflow_client.py b/src/conductor/client/workflow_client.py index 1474ed0d..27119e04 100644 --- a/src/conductor/client/workflow_client.py +++ b/src/conductor/client/workflow_client.py @@ -1,5 +1,7 @@ from abc import ABC, abstractmethod from typing import Optional, List + +from conductor.client.http.models import WorkflowRun from conductor.client.http.models.workflow import Workflow from conductor.client.http.models.start_workflow_request import StartWorkflowRequest from conductor.client.http.models.rerun_workflow_request import RerunWorkflowRequest @@ -24,7 +26,14 @@ def terminate_workflow(self, workflow_id: str, reason: Optional[str] = None): pass @abstractmethod - def execute_workflow(self): + def execute_workflow( + self, + start_workflow_request: StartWorkflowRequest, + request_id: str, + name: str, + version: int, + wait_until_task_ref: Optional[str] = None + ) -> WorkflowRun: pass @abstractmethod @@ -40,7 +49,7 @@ def restart_workflow(self, workflow_id: str, use_latest_def: Optional[bool] = Fa pass @abstractmethod - def retry_workflow(self): + def retry_workflow(self, workflow_id: str, resume_subworkflow_tasks: Optional[bool] = False): pass @abstractmethod From d7bda10553df64d268a08cd1a42f4dc9f11099f3 Mon Sep 17 00:00:00 2001 From: Viren Baraiya Date: Sat, 2 Dec 2023 21:37:55 -0800 Subject: [PATCH 5/9] more changes --- src/conductor/client/ai/configuration.py | 2 + src/conductor/client/ai/integrations.py | 5 +- src/conductor/client/ai/orchestrator.py | 12 +- .../http/models/integration_api_update.py | 151 ++++++++ src/conductor/client/http/models/prompt.py | 346 ++++++++++++++++++ src/conductor/client/integration_client.py | 37 +- .../client/orkes/orkes_base_client.py | 4 + .../client/orkes/orkes_integration_client.py | 61 ++- .../client/orkes/orkes_prompt_client.py | 51 +++ src/conductor/client/orkes_clients.py | 38 +- src/conductor/client/prompt_client.py | 43 +++ tests/ai_scratchpad/__init__.py | 0 .../ai_scratchpad}/hello.py | 0 .../ai_scratchpad}/hello2.py | 0 .../ai_scratchpad}/hello3.py | 3 +- .../ai_scratchpad}/llm_prompt_test.py | 0 {src => tests/notebook}/test.ipynb | 0 17 files changed, 680 insertions(+), 73 deletions(-) create mode 100644 src/conductor/client/http/models/integration_api_update.py create mode 100644 src/conductor/client/http/models/prompt.py create mode 100644 src/conductor/client/orkes/orkes_prompt_client.py create mode 100644 src/conductor/client/prompt_client.py create mode 100644 tests/ai_scratchpad/__init__.py rename {src/conductor => tests/ai_scratchpad}/hello.py (100%) rename {src/conductor => tests/ai_scratchpad}/hello2.py (100%) rename {src/conductor => tests/ai_scratchpad}/hello3.py (97%) rename {src/conductor/client/ai => tests/ai_scratchpad}/llm_prompt_test.py (100%) rename {src => tests/notebook}/test.ipynb (100%) diff --git a/src/conductor/client/ai/configuration.py b/src/conductor/client/ai/configuration.py index 9a0fa1ee..2445c0b8 100644 --- a/src/conductor/client/ai/configuration.py +++ b/src/conductor/client/ai/configuration.py @@ -4,6 +4,8 @@ class AIConfiguration: + """Default configurations for the AI workflows. + """ def __init__(self, llm_provider: str, text_complete_model: str, chat_complete_model: str, embedding_model: str, vector_db: str) -> Self: self.llm_provider = llm_provider diff --git a/src/conductor/client/ai/integrations.py b/src/conductor/client/ai/integrations.py index 94029d54..64b3d481 100644 --- a/src/conductor/client/ai/integrations.py +++ b/src/conductor/client/ai/integrations.py @@ -1,10 +1,13 @@ from __future__ import annotations +from abc import ABC, abstractmethod -class IntegrationConfig: + +class IntegrationConfig(ABC): def __init__(self): pass + @abstractmethod def to_dict(self) -> dict: pass diff --git a/src/conductor/client/ai/orchestrator.py b/src/conductor/client/ai/orchestrator.py index 1c4a9d6d..8e843ff4 100644 --- a/src/conductor/client/ai/orchestrator.py +++ b/src/conductor/client/ai/orchestrator.py @@ -11,6 +11,7 @@ from conductor.client.http.api.prompt_resource_api import PromptResourceApi from conductor.client.http.api.workflow_resource_api import WorkflowResourceApi from conductor.client.http.api_client import ApiClient +from conductor.client.orkes_clients import OrkesClients from conductor.client.workflow.conductor_workflow import ConductorWorkflow from conductor.client.workflow.executor.workflow_executor import WorkflowExecutor from conductor.client.workflow.task.llm_tasks.llm_text_complete import LlmTextComplete @@ -22,10 +23,13 @@ class AIOrchestrator: def __init__(self, api_configuration: Configuration, ai_configuration: AIConfiguration, prompt_test_workflow_name: str = '') -> Self: self.ai_configuration = ai_configuration - api_client = ApiClient(api_configuration) - self.workflow_executor = WorkflowExecutor(api_configuration) - self.prompt_resource = PromptResourceApi(api_client) - self.workflow_resource = WorkflowResourceApi(api_client) + orkes_clients = OrkesClients(api_configuration) + + self.integration_client = orkes_clients.get_integration_client() + self.workflow_client = orkes_clients.get_integration_client() + self.workflow_executor = orkes_clients.get_workflow_executor() + + # self.prompt_resource = PromptResourceApi(api_client) self.prompt_test_workflow_name = prompt_test_workflow_name if self.prompt_test_workflow_name == '': self.prompt_test_workflow_name = 'prompt_test_' + str(uuid4()) diff --git a/src/conductor/client/http/models/integration_api_update.py b/src/conductor/client/http/models/integration_api_update.py new file mode 100644 index 00000000..f6b76bc9 --- /dev/null +++ b/src/conductor/client/http/models/integration_api_update.py @@ -0,0 +1,151 @@ +import pprint +import re # noqa: F401 + +import six + + +class IntegrationApiUpdate(object): + """NOTE: This class is auto generated by the swagger code generator program. + + Do not edit the class manually. + """ + """ + Attributes: + swagger_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + swagger_types = { + 'configuration': 'dict(str, object)', + 'description': 'str', + 'enabled': 'bool' + } + + attribute_map = { + 'configuration': 'configuration', + 'description': 'description', + 'enabled': 'enabled' + } + + def __init__(self, configuration=None, description=None, enabled=None): # noqa: E501 + """IntegrationApiUpdate - a model defined in Swagger""" # noqa: E501 + self._configuration = None + self._description = None + self._enabled = None + self.discriminator = None + if configuration is not None: + self.configuration = configuration + if description is not None: + self.description = description + if enabled is not None: + self.enabled = enabled + + @property + def configuration(self): + """Gets the configuration of this IntegrationApiUpdate. # noqa: E501 + + + :return: The configuration of this IntegrationApiUpdate. # noqa: E501 + :rtype: dict(str, object) + """ + return self._configuration + + @configuration.setter + def configuration(self, configuration): + """Sets the configuration of this IntegrationApiUpdate. + + + :param configuration: The configuration of this IntegrationApiUpdate. # noqa: E501 + :type: dict(str, object) + """ + + self._configuration = configuration + + @property + def description(self): + """Gets the description of this IntegrationApiUpdate. # noqa: E501 + + + :return: The description of this IntegrationApiUpdate. # noqa: E501 + :rtype: str + """ + return self._description + + @description.setter + def description(self, description): + """Sets the description of this IntegrationApiUpdate. + + + :param description: The description of this IntegrationApiUpdate. # noqa: E501 + :type: str + """ + + self._description = description + + @property + def enabled(self): + """Gets the enabled of this IntegrationApiUpdate. # noqa: E501 + + + :return: The enabled of this IntegrationApiUpdate. # noqa: E501 + :rtype: bool + """ + return self._enabled + + @enabled.setter + def enabled(self, enabled): + """Sets the enabled of this IntegrationApiUpdate. + + + :param enabled: The enabled of this IntegrationApiUpdate. # noqa: E501 + :type: bool + """ + + self._enabled = enabled + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.swagger_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + if issubclass(IntegrationApiUpdate, dict): + for key, value in self.items(): + result[key] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, IntegrationApiUpdate): + return False + + return self.__dict__ == other.__dict__ + + def __ne__(self, other): + """Returns true if both objects are not equal""" + return not self == other diff --git a/src/conductor/client/http/models/prompt.py b/src/conductor/client/http/models/prompt.py new file mode 100644 index 00000000..f62b8e81 --- /dev/null +++ b/src/conductor/client/http/models/prompt.py @@ -0,0 +1,346 @@ +# coding: utf-8 + +""" + Orkes Conductor API Server + + Orkes Conductor API Server # noqa: E501 + + OpenAPI spec version: v2 + + Generated by: https://github.com/swagger-api/swagger-codegen.git +""" + +import pprint +import re # noqa: F401 + +import six + + +class Prompt(object): + """NOTE: This class is auto generated by the swagger code generator program. + + Do not edit the class manually. + """ + """ + Attributes: + swagger_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + swagger_types = { + 'created_by': 'str', + 'created_on': 'int', + 'description': 'str', + 'integrations': 'list[str]', + 'name': 'str', + 'tags': 'list[TagObject]', + 'template': 'str', + 'updated_by': 'str', + 'updated_on': 'int', + 'variables': 'list[str]' + } + + attribute_map = { + 'created_by': 'createdBy', + 'created_on': 'createdOn', + 'description': 'description', + 'integrations': 'integrations', + 'name': 'name', + 'tags': 'tags', + 'template': 'template', + 'updated_by': 'updatedBy', + 'updated_on': 'updatedOn', + 'variables': 'variables' + } + + def __init__(self, created_by=None, created_on=None, description=None, integrations=None, name=None, tags=None, + template=None, updated_by=None, updated_on=None, variables=None): # noqa: E501 + """MessageTemplate - a model defined in Swagger""" # noqa: E501 + self._created_by = None + self._created_on = None + self._description = None + self._integrations = None + self._name = None + self._tags = None + self._template = None + self._updated_by = None + self._updated_on = None + self._variables = None + self.discriminator = None + if created_by is not None: + self.created_by = created_by + if created_on is not None: + self.created_on = created_on + if description is not None: + self.description = description + if integrations is not None: + self.integrations = integrations + if name is not None: + self.name = name + if tags is not None: + self.tags = tags + if template is not None: + self.template = template + if updated_by is not None: + self.updated_by = updated_by + if updated_on is not None: + self.updated_on = updated_on + if variables is not None: + self.variables = variables + + @property + def created_by(self): + """Gets the created_by of this MessageTemplate. # noqa: E501 + + + :return: The created_by of this MessageTemplate. # noqa: E501 + :rtype: str + """ + return self._created_by + + @created_by.setter + def created_by(self, created_by): + """Sets the created_by of this MessageTemplate. + + + :param created_by: The created_by of this MessageTemplate. # noqa: E501 + :type: str + """ + + self._created_by = created_by + + @property + def created_on(self): + """Gets the created_on of this MessageTemplate. # noqa: E501 + + + :return: The created_on of this MessageTemplate. # noqa: E501 + :rtype: int + """ + return self._created_on + + @created_on.setter + def created_on(self, created_on): + """Sets the created_on of this MessageTemplate. + + + :param created_on: The created_on of this MessageTemplate. # noqa: E501 + :type: int + """ + + self._created_on = created_on + + @property + def description(self): + """Gets the description of this MessageTemplate. # noqa: E501 + + + :return: The description of this MessageTemplate. # noqa: E501 + :rtype: str + """ + return self._description + + @description.setter + def description(self, description): + """Sets the description of this MessageTemplate. + + + :param description: The description of this MessageTemplate. # noqa: E501 + :type: str + """ + + self._description = description + + @property + def integrations(self): + """Gets the integrations of this MessageTemplate. # noqa: E501 + + + :return: The integrations of this MessageTemplate. # noqa: E501 + :rtype: list[str] + """ + return self._integrations + + @integrations.setter + def integrations(self, integrations): + """Sets the integrations of this MessageTemplate. + + + :param integrations: The integrations of this MessageTemplate. # noqa: E501 + :type: list[str] + """ + + self._integrations = integrations + + @property + def name(self): + """Gets the name of this MessageTemplate. # noqa: E501 + + + :return: The name of this MessageTemplate. # noqa: E501 + :rtype: str + """ + return self._name + + @name.setter + def name(self, name): + """Sets the name of this MessageTemplate. + + + :param name: The name of this MessageTemplate. # noqa: E501 + :type: str + """ + + self._name = name + + @property + def tags(self): + """Gets the tags of this MessageTemplate. # noqa: E501 + + + :return: The tags of this MessageTemplate. # noqa: E501 + :rtype: list[TagObject] + """ + return self._tags + + @tags.setter + def tags(self, tags): + """Sets the tags of this MessageTemplate. + + + :param tags: The tags of this MessageTemplate. # noqa: E501 + :type: list[TagObject] + """ + + self._tags = tags + + @property + def template(self): + """Gets the template of this MessageTemplate. # noqa: E501 + + + :return: The template of this MessageTemplate. # noqa: E501 + :rtype: str + """ + return self._template + + @template.setter + def template(self, template): + """Sets the template of this MessageTemplate. + + + :param template: The template of this MessageTemplate. # noqa: E501 + :type: str + """ + + self._template = template + + @property + def updated_by(self): + """Gets the updated_by of this MessageTemplate. # noqa: E501 + + + :return: The updated_by of this MessageTemplate. # noqa: E501 + :rtype: str + """ + return self._updated_by + + @updated_by.setter + def updated_by(self, updated_by): + """Sets the updated_by of this MessageTemplate. + + + :param updated_by: The updated_by of this MessageTemplate. # noqa: E501 + :type: str + """ + + self._updated_by = updated_by + + @property + def updated_on(self): + """Gets the updated_on of this MessageTemplate. # noqa: E501 + + + :return: The updated_on of this MessageTemplate. # noqa: E501 + :rtype: int + """ + return self._updated_on + + @updated_on.setter + def updated_on(self, updated_on): + """Sets the updated_on of this MessageTemplate. + + + :param updated_on: The updated_on of this MessageTemplate. # noqa: E501 + :type: int + """ + + self._updated_on = updated_on + + @property + def variables(self): + """Gets the variables of this MessageTemplate. # noqa: E501 + + + :return: The variables of this MessageTemplate. # noqa: E501 + :rtype: list[str] + """ + return self._variables + + @variables.setter + def variables(self, variables): + """Sets the variables of this MessageTemplate. + + + :param variables: The variables of this MessageTemplate. # noqa: E501 + :type: list[str] + """ + + self._variables = variables + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.swagger_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + if issubclass(MessageTemplate, dict): + for key, value in self.items(): + result[key] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, MessageTemplate): + return False + + return self.__dict__ == other.__dict__ + + def __ne__(self, other): + """Returns true if both objects are not equal""" + return not self == other diff --git a/src/conductor/client/integration_client.py b/src/conductor/client/integration_client.py index 9dd98baf..67d617bf 100644 --- a/src/conductor/client/integration_client.py +++ b/src/conductor/client/integration_client.py @@ -1,5 +1,12 @@ from __future__ import absolute_import from abc import ABC, abstractmethod +from typing import List + +from conductor.client.http.models.integration import Integration +from conductor.client.http.models.integration_api import IntegrationApi +from conductor.client.http.models.integration_api_update import IntegrationApiUpdate +from conductor.client.http.models.integration_update import IntegrationUpdate +from conductor.client.http.models.prompt import MessageTemplate class IntegrationClient(ABC): @@ -26,41 +33,33 @@ class IntegrationClient(ABC): """ @abstractmethod - def associate_prompt_with_integration(self, ai_integration, model_name, prompt_name): + def associate_prompt_with_integration(self, ai_integration:str, model_name:str, prompt_name:str): """Associate a prompt with an AI integration and model""" pass @abstractmethod - def delete_integration_api(self, api_name, integration_name): + def delete_integration_api(self, api_name:str, integration_name:str): """Delete a specific integration api for a given integration""" pass - def delete_integration(self, integration_name): + def delete_integration(self, integration_name:str): """Delete an integration""" pass - def get_integration_api(self, name, integration_name): - pass - - def get_integration_apis(self, name): - pass - - def get_integration_available_apis(self, name): - pass - - def get_integration_provider(self, name): + def get_integration_api(self, api_name:str, integration_name:str) -> IntegrationApi: pass - def get_integration_provider_defs(self): + def get_integration_apis(self, integration_name:str) -> List[IntegrationApi]: pass - def get_integration_providers(self): + def get_integration(self, integration_name:str) -> Integration: pass - def get_prompts_with_integration(self, integration_provider, integration_name): + def get_integrations(self) -> List[Integration]: + """Returns the list of all the available integrations""" pass - def get_providers_and_integrations(self): + def get_prompts_with_integration(self, ai_integration:str, model_name:str) -> List[MessageTemplate]: pass def get_token_usage_for_integration(self, name, integration_name): @@ -72,10 +71,10 @@ def get_token_usage_for_integration_provider(self, name): def register_token_usage(self, body, name, integration_name): pass - def save_integration_api(self, body, name, integration_name): + def save_integration_api(self, integration_name, api_name, api_details: IntegrationApiUpdate): pass - def save_integration_provider(self, body, name): + def save_integration(self, integration_name, integration_details: IntegrationUpdate): pass # Tags diff --git a/src/conductor/client/orkes/orkes_base_client.py b/src/conductor/client/orkes/orkes_base_client.py index 0b6e6676..f72c7c22 100644 --- a/src/conductor/client/orkes/orkes_base_client.py +++ b/src/conductor/client/orkes/orkes_base_client.py @@ -1,4 +1,6 @@ from conductor.client.configuration.configuration import Configuration +from conductor.client.http.api.integration_resource_api import IntegrationResourceApi +from conductor.client.http.api.prompt_resource_api import PromptResourceApi from conductor.client.http.api_client import ApiClient from conductor.client.orkes.api.tags_api import TagsApi from conductor.client.http.api.metadata_resource_api import MetadataResourceApi @@ -30,3 +32,5 @@ def __init__(self, configuration: Configuration): self.authorizationResourceApi = AuthorizationResourceApi(self.api_client) self.schedulerResourceApi = SchedulerResourceApi(self.api_client) self.tagsApi = TagsApi(self.api_client) + self.integrationApi = IntegrationResourceApi(self.api_client) + self.promptApi = PromptResourceApi(self.api_client) diff --git a/src/conductor/client/orkes/orkes_integration_client.py b/src/conductor/client/orkes/orkes_integration_client.py index e56dbe54..ed4d06e0 100644 --- a/src/conductor/client/orkes/orkes_integration_client.py +++ b/src/conductor/client/orkes/orkes_integration_client.py @@ -1,7 +1,12 @@ from __future__ import absolute_import -from abc import ABC, abstractmethod +from typing import List from conductor.client.configuration.configuration import Configuration +from conductor.client.http.models.integration import Integration +from conductor.client.http.models.integration_api import IntegrationApi +from conductor.client.http.models.integration_api_update import IntegrationApiUpdate +from conductor.client.http.models.integration_update import IntegrationUpdate +from conductor.client.http.models.prompt import Prompt from conductor.client.integration_client import IntegrationClient from conductor.client.orkes.orkes_base_client import OrkesBaseClient from conductor.client.exceptions.api_exception_handler import api_exception_handler, for_all_methods @@ -13,43 +18,35 @@ class OrkesIntegrationClient(OrkesBaseClient, IntegrationClient): def __init__(self, configuration: Configuration): super(OrkesIntegrationClient, self).__init__(configuration) - @abstractmethod - def associate_prompt_with_integration(self, ai_integration, model_name, prompt_name): - """Associate a prompt with an AI integration and model""" - pass + def associate_prompt_with_integration(self, ai_integration: str, model_name: str, prompt_name: str): + self.integrationApi.associate_prompt_with_integration(ai_integration, model_name, prompt_name) - @abstractmethod - def delete_integration_api(self, api_name, integration_name): - """Delete a specific integration api for a given integration""" - pass + def delete_integration_api(self, api_name: str, integration_name: str): + self.integrationApi.delete_integration_api(api_name, integration_name) - def delete_integration(self, integration_name): - """Delete an integration""" - pass + def delete_integration(self, integration_name: str): + self.integrationApi.delete_integration_provider(integration_name) - def get_integration_api(self, name, integration_name): - pass + def get_integration_api(self, api_name: str, integration_name: str) -> IntegrationApi: + return self.integrationApi.get_integration_api(api_name, integration_name) - def get_integration_apis(self, name): - pass + def get_integration_apis(self, integration_name: str) -> List[IntegrationApi]: + return self.integrationApi.get_integration_apis(integration_name) - def get_integration_available_apis(self, name): - pass + def get_integration(self, integration_name: str) -> Integration: + return self.integrationApi.get_integration_provider(integration_name) - def get_integration_provider(self, name): - pass + def get_integrations(self) -> List[Integration]: + return self.integrationApi.get_integration_providers() - def get_integration_provider_defs(self): - pass + def get_prompts_with_integration(self, ai_integration: str, model_name: str) -> List[Prompt]: + return self.integrationApi.get_prompts_with_integration(ai_integration, model_name) - def get_integration_providers(self): - pass - - def get_prompts_with_integration(self, integration_provider, integration_name): - pass + def save_integration_api(self, integration_name, api_name, api_details: IntegrationApiUpdate): + self.integrationApi.save_integration_api(api_details, api_name, integration_name) - def get_providers_and_integrations(self): - pass + def save_integration(self, integration_name, integration_details: IntegrationUpdate): + self.integrationApi.save_integration_provider(integration_name, integration_details) def get_token_usage_for_integration(self, name, integration_name): pass @@ -60,12 +57,6 @@ def get_token_usage_for_integration_provider(self, name): def register_token_usage(self, body, name, integration_name): pass - def save_integration_api(self, body, name, integration_name): - pass - - def save_integration_provider(self, body, name): - pass - # Tags def delete_tag_for_integration(self, body, tag_name, integration_name): diff --git a/src/conductor/client/orkes/orkes_prompt_client.py b/src/conductor/client/orkes/orkes_prompt_client.py new file mode 100644 index 00000000..b1a929c8 --- /dev/null +++ b/src/conductor/client/orkes/orkes_prompt_client.py @@ -0,0 +1,51 @@ +from __future__ import absolute_import + +import re # noqa: F401 +from abc import ABC, abstractmethod +from typing import List + +# python 2 and python 3 compatibility library +import six + +from conductor.client.configuration.configuration import Configuration +from conductor.client.exceptions.api_exception_handler import api_exception_handler, for_all_methods +from conductor.client.http.api_client import ApiClient +from conductor.client.http.models.prompt import Prompt +from conductor.client.orkes.models.metadata_tag import MetadataTag +from conductor.client.orkes.orkes_base_client import OrkesBaseClient +from conductor.client.prompt_client import PromptClient + + +@for_all_methods(api_exception_handler, ["__init__"]) +class OrkesPromptClient(OrkesBaseClient, PromptClient): + + def __init__(self, configuration: Configuration): + super(PromptClient, self).__init__(configuration) + + @abstractmethod + def save_prompt(self, prompt_name: str, description: str, prompt: Prompt): + self.promptApi.save_message_template(prompt, description, prompt_name) + + @abstractmethod + def get_prompt(self, prompt_name: str) -> Prompt: + return self.promptApi.get_message_template(prompt_name) + + @abstractmethod + def get_prompts(self): + return self.promptApi.get_message_templates() + + @abstractmethod + def delete_prompt(self, prompt_name: str): + self.promptApi.delete_message_template(prompt_name) + + @abstractmethod + def get_tags_for_prompt_template(self, prompt_name: str) -> List[MetadataTag]: + self.promptApi.get_tags_for_prompt_template(prompt_name) + + @abstractmethod + def update_tag_for_prompt_template(self, prompt_name: str, tags: List[MetadataTag]): + self.promptApi.put_tag_for_prompt_template(tags, prompt_name) + + @abstractmethod + def delete_tag_for_prompt_template(self, prompt_name: str, tags: List[MetadataTag]): + self.promptApi.delete_tag_for_prompt_template(tags, prompt_name) diff --git a/src/conductor/client/orkes_clients.py b/src/conductor/client/orkes_clients.py index 348f32a3..29980d33 100644 --- a/src/conductor/client/orkes_clients.py +++ b/src/conductor/client/orkes_clients.py @@ -1,31 +1,45 @@ +from conductor.client.authorization_client import AuthorizationClient from conductor.client.configuration.configuration import Configuration +from conductor.client.integration_client import IntegrationClient +from conductor.client.metadata_client import MetadataClient +from conductor.client.orkes.orkes_integration_client import OrkesIntegrationClient from conductor.client.orkes.orkes_metadata_client import OrkesMetadataClient from conductor.client.orkes.orkes_workflow_client import OrkesWorkflowClient from conductor.client.orkes.orkes_task_client import OrkesTaskClient from conductor.client.orkes.orkes_scheduler_client import OrkesSchedulerClient from conductor.client.orkes.orkes_secret_client import OrkesSecretClient from conductor.client.orkes.orkes_authorization_client import OrkesAuthorizationClient +from conductor.client.scheduler_client import SchedulerClient +from conductor.client.secret_client import SecretClient +from conductor.client.task_client import TaskClient +from conductor.client.workflow.executor.workflow_executor import WorkflowExecutor +from conductor.client.workflow_client import WorkflowClient + class OrkesClients: def __init__(self, configuration: Configuration): self.configuration = configuration - - def get_workflow_client(self) -> OrkesWorkflowClient: + + def get_workflow_client(self) -> WorkflowClient: return OrkesWorkflowClient(self.configuration) - def get_authorization_client(self) -> OrkesAuthorizationClient: + def get_authorization_client(self) -> AuthorizationClient: return OrkesAuthorizationClient(self.configuration) - def get_metadata_client(self) -> OrkesMetadataClient: + def get_metadata_client(self) -> MetadataClient: return OrkesMetadataClient(self.configuration) - - def get_scheduler_client(self) -> OrkesSchedulerClient: + + def get_scheduler_client(self) -> SchedulerClient: return OrkesSchedulerClient(self.configuration) - - def get_secret_client(self) -> OrkesSecretClient: + + def get_secret_client(self) -> SecretClient: return OrkesSecretClient(self.configuration) - - def get_task_client(self) -> OrkesTaskClient: + + def get_task_client(self) -> TaskClient: return OrkesTaskClient(self.configuration) - - \ No newline at end of file + + def get_integration_client(self) -> IntegrationClient: + return OrkesIntegrationClient(self.configuration) + + def get_workflow_executor(self) -> WorkflowExecutor: + return WorkflowExecutor(self.configuration) \ No newline at end of file diff --git a/src/conductor/client/prompt_client.py b/src/conductor/client/prompt_client.py new file mode 100644 index 00000000..bf3c5df5 --- /dev/null +++ b/src/conductor/client/prompt_client.py @@ -0,0 +1,43 @@ +from __future__ import absolute_import + +import re # noqa: F401 +from abc import ABC, abstractmethod +from typing import List + +# python 2 and python 3 compatibility library +import six + +from conductor.client.http.api_client import ApiClient +from conductor.client.http.models.prompt import Prompt +from conductor.client.orkes.models.metadata_tag import MetadataTag + + +class PromptClient(ABC): + + @abstractmethod + def save_prompt(self, prompt_name: str, description: str, prompt: Prompt): + pass + + @abstractmethod + def get_prompt(self, prompt_name: str) -> Prompt: + pass + + @abstractmethod + def get_prompts(self): + pass + + @abstractmethod + def delete_prompt(self, prompt_name: str): + pass + + @abstractmethod + def get_tags_for_prompt_template(self, prompt_name: str) -> List[MetadataTag]: + pass + + @abstractmethod + def update_tag_for_prompt_template(self, prompt_name: str, tags: List[MetadataTag]): + pass + + @abstractmethod + def delete_tag_for_prompt_template(self, prompt_name: str, tags: List[MetadataTag]): + pass diff --git a/tests/ai_scratchpad/__init__.py b/tests/ai_scratchpad/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/conductor/hello.py b/tests/ai_scratchpad/hello.py similarity index 100% rename from src/conductor/hello.py rename to tests/ai_scratchpad/hello.py diff --git a/src/conductor/hello2.py b/tests/ai_scratchpad/hello2.py similarity index 100% rename from src/conductor/hello2.py rename to tests/ai_scratchpad/hello2.py diff --git a/src/conductor/hello3.py b/tests/ai_scratchpad/hello3.py similarity index 97% rename from src/conductor/hello3.py rename to tests/ai_scratchpad/hello3.py index 56378386..036962fc 100644 --- a/src/conductor/hello3.py +++ b/tests/ai_scratchpad/hello3.py @@ -1,4 +1,3 @@ -import functools from typing import List from conductor.client.configuration.configuration import Configuration @@ -8,7 +7,7 @@ from conductor.client.workflow.executor.workflow_executor import WorkflowExecutor from conductor.client.workflow.task.switch_task import SwitchTask from conductor.client.workflow.task.task import TaskInterface -from conductor.hello import workflow +from tests.ai_scratchpad.hello import workflow @WorkerTask(task_definition_name="get_user_info") diff --git a/src/conductor/client/ai/llm_prompt_test.py b/tests/ai_scratchpad/llm_prompt_test.py similarity index 100% rename from src/conductor/client/ai/llm_prompt_test.py rename to tests/ai_scratchpad/llm_prompt_test.py diff --git a/src/test.ipynb b/tests/notebook/test.ipynb similarity index 100% rename from src/test.ipynb rename to tests/notebook/test.ipynb From 034125a80273b25b545939b4b1336f682a8b2cc7 Mon Sep 17 00:00:00 2001 From: Viren Baraiya Date: Sat, 2 Dec 2023 22:49:45 -0800 Subject: [PATCH 6/9] fixes --- src/conductor/client/ai/integrations.py | 13 ++ src/conductor/client/ai/orchestrator.py | 26 +++- .../client/http/api/prompt_resource_api.py | 130 +++++++++++++++++- .../models/{prompt.py => prompt_template.py} | 18 +-- src/conductor/client/integration_client.py | 4 +- .../client/orkes/orkes_integration_client.py | 8 +- .../client/orkes/orkes_prompt_client.py | 17 +-- src/conductor/client/orkes_clients.py | 7 +- src/conductor/client/prompt_client.py | 6 +- tests/ai_scratchpad/llm_prompt_test.py | 27 ++-- 10 files changed, 195 insertions(+), 61 deletions(-) rename src/conductor/client/http/models/{prompt.py => prompt_template.py} (96%) diff --git a/src/conductor/client/ai/integrations.py b/src/conductor/client/ai/integrations.py index 64b3d481..8e6b50d1 100644 --- a/src/conductor/client/ai/integrations.py +++ b/src/conductor/client/ai/integrations.py @@ -37,6 +37,19 @@ def to_dict(self) -> dict: } +class AzureOpenAIConfig(IntegrationConfig): + + def __init__(self, api_key: str, endpoint: str) -> None: + self.api_key = api_key + self.endpoint = endpoint + + def to_dict(self) -> dict: + return { + 'api_key': self.api_key, + 'endpoint': self.endpoint + } + + class PineconeConfig(IntegrationConfig): def __init__(self, api_key: str, endpoint: str, classname: str) -> None: diff --git a/src/conductor/client/ai/orchestrator.py b/src/conductor/client/ai/orchestrator.py index 8e843ff4..e6990afc 100644 --- a/src/conductor/client/ai/orchestrator.py +++ b/src/conductor/client/ai/orchestrator.py @@ -11,6 +11,9 @@ from conductor.client.http.api.prompt_resource_api import PromptResourceApi from conductor.client.http.api.workflow_resource_api import WorkflowResourceApi from conductor.client.http.api_client import ApiClient +from conductor.client.http.models.integration_api_update import IntegrationApiUpdate +from conductor.client.http.models.integration_update import IntegrationUpdate +from conductor.client.http.models.prompt_template import PromptTemplate from conductor.client.orkes_clients import OrkesClients from conductor.client.workflow.conductor_workflow import ConductorWorkflow from conductor.client.workflow.executor.workflow_executor import WorkflowExecutor @@ -28,14 +31,14 @@ def __init__(self, api_configuration: Configuration, ai_configuration: AIConfigu self.integration_client = orkes_clients.get_integration_client() self.workflow_client = orkes_clients.get_integration_client() self.workflow_executor = orkes_clients.get_workflow_executor() + self.prompt_client = orkes_clients.get_prompt_client() - # self.prompt_resource = PromptResourceApi(api_client) self.prompt_test_workflow_name = prompt_test_workflow_name if self.prompt_test_workflow_name == '': self.prompt_test_workflow_name = 'prompt_test_' + str(uuid4()) - def add_prompt_template(self, name: str, template: str, description: str): - self.prompt_resource.save_message_template(template, description, name) + def add_prompt_template(self, name: str, prompt_template: str, description: str): + self.prompt_client.save_prompt(name, description, prompt_template) return self def test_prompt_template(self, name: str, variables: dict, @@ -62,9 +65,20 @@ def test_prompt_template(self, name: str, variables: dict, else: return '' - def add_ai_integration(self, name: str, provider: str, models: List[str], description: str, api_key: str, - config: IntegrationConfig): - pass + def add_ai_integration(self, name: str, provider: str, models: List[str], description: str, config: IntegrationConfig): + details = IntegrationUpdate() + details.configuration = config.to_dict() + details.type = provider + details.category = 'AI_MODEL' + details.enabled = True + details.description = description + self.integration_client.save_integration(name, details) + for model in models: + api_details = IntegrationApiUpdate() + api_details.enabled = True + api_details.description = description + self.integration_client.save_integration_api(name, model, api_details) + def add_vector_store(self, name: str, provider: str, indices: List[str], description: str, api_key: str, config: IntegrationConfig): diff --git a/src/conductor/client/http/api/prompt_resource_api.py b/src/conductor/client/http/api/prompt_resource_api.py index 9f0b6939..2c2243c7 100644 --- a/src/conductor/client/http/api/prompt_resource_api.py +++ b/src/conductor/client/http/api/prompt_resource_api.py @@ -1,3 +1,15 @@ +# coding: utf-8 + +""" + Orkes Conductor API Server + + Orkes Conductor API Server # noqa: E501 + + OpenAPI spec version: v2 + + Generated by: https://github.com/swagger-api/swagger-codegen.git +""" + from __future__ import absolute_import import re # noqa: F401 @@ -74,7 +86,8 @@ def delete_message_template_with_http_info(self, name, **kwargs): # noqa: E501 # verify the required parameter 'name' is set if ('name' not in params or params['name'] is None): - raise ValueError("Missing the required parameter `name` when calling `delete_message_template`") # noqa: E501 + raise ValueError( + "Missing the required parameter `name` when calling `delete_message_template`") # noqa: E501 collection_formats = {} @@ -165,11 +178,13 @@ def delete_tag_for_prompt_template_with_http_info(self, body, name, **kwargs): # verify the required parameter 'body' is set if ('body' not in params or params['body'] is None): - raise ValueError("Missing the required parameter `body` when calling `delete_tag_for_prompt_template`") # noqa: E501 + raise ValueError( + "Missing the required parameter `body` when calling `delete_tag_for_prompt_template`") # noqa: E501 # verify the required parameter 'name' is set if ('name' not in params or params['name'] is None): - raise ValueError("Missing the required parameter `name` when calling `delete_tag_for_prompt_template`") # noqa: E501 + raise ValueError( + "Missing the required parameter `name` when calling `delete_tag_for_prompt_template`") # noqa: E501 collection_formats = {} @@ -442,7 +457,8 @@ def get_tags_for_prompt_template_with_http_info(self, name, **kwargs): # noqa: # verify the required parameter 'name' is set if ('name' not in params or params['name'] is None): - raise ValueError("Missing the required parameter `name` when calling `get_tags_for_prompt_template`") # noqa: E501 + raise ValueError( + "Missing the required parameter `name` when calling `get_tags_for_prompt_template`") # noqa: E501 collection_formats = {} @@ -537,11 +553,13 @@ def put_tag_for_prompt_template_with_http_info(self, body, name, **kwargs): # n # verify the required parameter 'body' is set if ('body' not in params or params['body'] is None): - raise ValueError("Missing the required parameter `body` when calling `put_tag_for_prompt_template`") # noqa: E501 + raise ValueError( + "Missing the required parameter `body` when calling `put_tag_for_prompt_template`") # noqa: E501 # verify the required parameter 'name' is set if ('name' not in params or params['name'] is None): - raise ValueError("Missing the required parameter `name` when calling `put_tag_for_prompt_template`") # noqa: E501 + raise ValueError( + "Missing the required parameter `name` when calling `put_tag_for_prompt_template`") # noqa: E501 collection_formats = {} @@ -646,7 +664,8 @@ def save_message_template_with_http_info(self, body, description, name, **kwargs # verify the required parameter 'description' is set if ('description' not in params or params['description'] is None): - raise ValueError("Missing the required parameter `description` when calling `save_message_template`") # noqa: E501 + raise ValueError( + "Missing the required parameter `description` when calling `save_message_template`") # noqa: E501 # verify the required parameter 'name' is set if ('name' not in params or params['name'] is None): @@ -695,3 +714,100 @@ def save_message_template_with_http_info(self, body, description, name, **kwargs _preload_content=params.get('_preload_content', True), _request_timeout=params.get('_request_timeout'), collection_formats=collection_formats) + + def test_message_template(self, body, **kwargs): # noqa: E501 + """Test Prompt Template # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.test_message_template(body, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param PromptTemplateTestRequest body: (required) + :return: str + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('async_req'): + return self.test_message_template_with_http_info(body, **kwargs) # noqa: E501 + else: + (data) = self.test_message_template_with_http_info(body, **kwargs) # noqa: E501 + return data + + def test_message_template_with_http_info(self, body, **kwargs): # noqa: E501 + """Test Prompt Template # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.test_message_template_with_http_info(body, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param PromptTemplateTestRequest body: (required) + :return: str + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['body'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + + params = locals() + for key, val in six.iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method test_message_template" % key + ) + params[key] = val + del params['kwargs'] + # verify the required parameter 'body' is set + if ('body' not in params or + params['body'] is None): + raise ValueError("Missing the required parameter `body` when calling `test_message_template`") # noqa: E501 + + collection_formats = {} + + path_params = {} + + query_params = [] + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + if 'body' in params: + body_params = params['body'] + # HTTP header `Accept` + header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 + ['application/json']) # noqa: E501 + + # Authentication setting + auth_settings = ['api_key'] # noqa: E501 + + return self.api_client.call_api( + '/prompts/test', 'POST', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type='str', # noqa: E501 + auth_settings=auth_settings, + async_req=params.get('async_req'), + _return_http_data_only=params.get('_return_http_data_only'), + _preload_content=params.get('_preload_content', True), + _request_timeout=params.get('_request_timeout'), + collection_formats=collection_formats) diff --git a/src/conductor/client/http/models/prompt.py b/src/conductor/client/http/models/prompt_template.py similarity index 96% rename from src/conductor/client/http/models/prompt.py rename to src/conductor/client/http/models/prompt_template.py index f62b8e81..d88aa318 100644 --- a/src/conductor/client/http/models/prompt.py +++ b/src/conductor/client/http/models/prompt_template.py @@ -1,22 +1,10 @@ -# coding: utf-8 - -""" - Orkes Conductor API Server - - Orkes Conductor API Server # noqa: E501 - - OpenAPI spec version: v2 - - Generated by: https://github.com/swagger-api/swagger-codegen.git -""" - import pprint import re # noqa: F401 import six -class Prompt(object): +class PromptTemplate(object): """NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. @@ -320,7 +308,7 @@ def to_dict(self): )) else: result[attr] = value - if issubclass(MessageTemplate, dict): + if issubclass(PromptTemplate, dict): for key, value in self.items(): result[key] = value @@ -336,7 +324,7 @@ def __repr__(self): def __eq__(self, other): """Returns true if both objects are equal""" - if not isinstance(other, MessageTemplate): + if not isinstance(other, PromptTemplate): return False return self.__dict__ == other.__dict__ diff --git a/src/conductor/client/integration_client.py b/src/conductor/client/integration_client.py index 67d617bf..fced5b02 100644 --- a/src/conductor/client/integration_client.py +++ b/src/conductor/client/integration_client.py @@ -6,7 +6,7 @@ from conductor.client.http.models.integration_api import IntegrationApi from conductor.client.http.models.integration_api_update import IntegrationApiUpdate from conductor.client.http.models.integration_update import IntegrationUpdate -from conductor.client.http.models.prompt import MessageTemplate +from conductor.client.http.models.prompt_template import PromptTemplate class IntegrationClient(ABC): @@ -59,7 +59,7 @@ def get_integrations(self) -> List[Integration]: """Returns the list of all the available integrations""" pass - def get_prompts_with_integration(self, ai_integration:str, model_name:str) -> List[MessageTemplate]: + def get_prompts_with_integration(self, ai_integration:str, model_name:str) -> List[PromptTemplate]: pass def get_token_usage_for_integration(self, name, integration_name): diff --git a/src/conductor/client/orkes/orkes_integration_client.py b/src/conductor/client/orkes/orkes_integration_client.py index ed4d06e0..d04e61d3 100644 --- a/src/conductor/client/orkes/orkes_integration_client.py +++ b/src/conductor/client/orkes/orkes_integration_client.py @@ -6,7 +6,7 @@ from conductor.client.http.models.integration_api import IntegrationApi from conductor.client.http.models.integration_api_update import IntegrationApiUpdate from conductor.client.http.models.integration_update import IntegrationUpdate -from conductor.client.http.models.prompt import Prompt +from conductor.client.http.models.prompt_template import PromptTemplate from conductor.client.integration_client import IntegrationClient from conductor.client.orkes.orkes_base_client import OrkesBaseClient from conductor.client.exceptions.api_exception_handler import api_exception_handler, for_all_methods @@ -39,14 +39,14 @@ def get_integration(self, integration_name: str) -> Integration: def get_integrations(self) -> List[Integration]: return self.integrationApi.get_integration_providers() - def get_prompts_with_integration(self, ai_integration: str, model_name: str) -> List[Prompt]: + def get_prompts_with_integration(self, ai_integration: str, model_name: str) -> List[PromptTemplate]: return self.integrationApi.get_prompts_with_integration(ai_integration, model_name) def save_integration_api(self, integration_name, api_name, api_details: IntegrationApiUpdate): - self.integrationApi.save_integration_api(api_details, api_name, integration_name) + self.integrationApi.save_integration_api(api_details, integration_name, api_name) def save_integration(self, integration_name, integration_details: IntegrationUpdate): - self.integrationApi.save_integration_provider(integration_name, integration_details) + self.integrationApi.save_integration_provider(integration_details, integration_name) def get_token_usage_for_integration(self, name, integration_name): pass diff --git a/src/conductor/client/orkes/orkes_prompt_client.py b/src/conductor/client/orkes/orkes_prompt_client.py index b1a929c8..281dcdde 100644 --- a/src/conductor/client/orkes/orkes_prompt_client.py +++ b/src/conductor/client/orkes/orkes_prompt_client.py @@ -10,7 +10,7 @@ from conductor.client.configuration.configuration import Configuration from conductor.client.exceptions.api_exception_handler import api_exception_handler, for_all_methods from conductor.client.http.api_client import ApiClient -from conductor.client.http.models.prompt import Prompt +from conductor.client.http.models.prompt_template import PromptTemplate from conductor.client.orkes.models.metadata_tag import MetadataTag from conductor.client.orkes.orkes_base_client import OrkesBaseClient from conductor.client.prompt_client import PromptClient @@ -20,32 +20,25 @@ class OrkesPromptClient(OrkesBaseClient, PromptClient): def __init__(self, configuration: Configuration): - super(PromptClient, self).__init__(configuration) + super(OrkesPromptClient, self).__init__(configuration) - @abstractmethod - def save_prompt(self, prompt_name: str, description: str, prompt: Prompt): - self.promptApi.save_message_template(prompt, description, prompt_name) + def save_prompt(self, prompt_name: str, description: str, prompt_template: str): + self.promptApi.save_message_template(prompt_template, description, prompt_name) - @abstractmethod - def get_prompt(self, prompt_name: str) -> Prompt: + def get_prompt(self, prompt_name: str) -> PromptTemplate: return self.promptApi.get_message_template(prompt_name) - @abstractmethod def get_prompts(self): return self.promptApi.get_message_templates() - @abstractmethod def delete_prompt(self, prompt_name: str): self.promptApi.delete_message_template(prompt_name) - @abstractmethod def get_tags_for_prompt_template(self, prompt_name: str) -> List[MetadataTag]: self.promptApi.get_tags_for_prompt_template(prompt_name) - @abstractmethod def update_tag_for_prompt_template(self, prompt_name: str, tags: List[MetadataTag]): self.promptApi.put_tag_for_prompt_template(tags, prompt_name) - @abstractmethod def delete_tag_for_prompt_template(self, prompt_name: str, tags: List[MetadataTag]): self.promptApi.delete_tag_for_prompt_template(tags, prompt_name) diff --git a/src/conductor/client/orkes_clients.py b/src/conductor/client/orkes_clients.py index 29980d33..f6b2183d 100644 --- a/src/conductor/client/orkes_clients.py +++ b/src/conductor/client/orkes_clients.py @@ -4,11 +4,13 @@ from conductor.client.metadata_client import MetadataClient from conductor.client.orkes.orkes_integration_client import OrkesIntegrationClient from conductor.client.orkes.orkes_metadata_client import OrkesMetadataClient +from conductor.client.orkes.orkes_prompt_client import OrkesPromptClient from conductor.client.orkes.orkes_workflow_client import OrkesWorkflowClient from conductor.client.orkes.orkes_task_client import OrkesTaskClient from conductor.client.orkes.orkes_scheduler_client import OrkesSchedulerClient from conductor.client.orkes.orkes_secret_client import OrkesSecretClient from conductor.client.orkes.orkes_authorization_client import OrkesAuthorizationClient +from conductor.client.prompt_client import PromptClient from conductor.client.scheduler_client import SchedulerClient from conductor.client.secret_client import SecretClient from conductor.client.task_client import TaskClient @@ -42,4 +44,7 @@ def get_integration_client(self) -> IntegrationClient: return OrkesIntegrationClient(self.configuration) def get_workflow_executor(self) -> WorkflowExecutor: - return WorkflowExecutor(self.configuration) \ No newline at end of file + return WorkflowExecutor(self.configuration) + + def get_prompt_client(self) -> PromptClient: + return OrkesPromptClient(self.configuration) \ No newline at end of file diff --git a/src/conductor/client/prompt_client.py b/src/conductor/client/prompt_client.py index bf3c5df5..01427fc2 100644 --- a/src/conductor/client/prompt_client.py +++ b/src/conductor/client/prompt_client.py @@ -8,18 +8,18 @@ import six from conductor.client.http.api_client import ApiClient -from conductor.client.http.models.prompt import Prompt +from conductor.client.http.models.prompt_template import PromptTemplate from conductor.client.orkes.models.metadata_tag import MetadataTag class PromptClient(ABC): @abstractmethod - def save_prompt(self, prompt_name: str, description: str, prompt: Prompt): + def save_prompt(self, prompt_name: str, description: str, prompt_template: str): pass @abstractmethod - def get_prompt(self, prompt_name: str) -> Prompt: + def get_prompt(self, prompt_name: str) -> PromptTemplate: pass @abstractmethod diff --git a/tests/ai_scratchpad/llm_prompt_test.py b/tests/ai_scratchpad/llm_prompt_test.py index a17c6f62..1c386c36 100644 --- a/tests/ai_scratchpad/llm_prompt_test.py +++ b/tests/ai_scratchpad/llm_prompt_test.py @@ -1,6 +1,7 @@ import sys from typing import Dict +from conductor.client.ai.integrations import AzureOpenAIConfig from conductor.client.ai.orchestrator import AIConfiguration, AIOrchestrator from conductor.client.configuration.configuration import Configuration from conductor.client.configuration.settings.authentication_settings import AuthenticationSettings @@ -36,24 +37,28 @@ def get_document(task: Task) -> str: def main(): - ai_config = AIConfiguration('azure_openai', 'text-davinci-003', 'text-embedding-ada-002', 'pineconedb') + ai_config = AIConfiguration('azure_openai', 'text-davinci-003', '', 'text-embedding-ada-002', 'pineconedb') api_config = Configuration( - authentication_settings=AuthenticationSettings(key_id='3bbcc893-66f4-4887-a419-12b8117fac62', - key_secret='t6BhLZUqaKRXLEjzEtnVNnjtO5Ll2C1205SSE1rXg3WrRZ7V')) - - prompt_client = AIOrchestrator(api_configuration=api_config, ai_configuration=ai_config) + authentication_settings=AuthenticationSettings(key_id='0092089d-19ff-4931-b3da-fc093029d0ad', + key_secret='lzCCrpk5NLi0TYmIDiOfnJWLz5vkxMKn5BoCKIHSddOdYyg3')) + ai_orchestrator = AIOrchestrator(api_configuration=api_config, ai_configuration=ai_config) prompt = Prompt(name='say_hi_to_friend', variables={'friend_name': '${get_friend_name_ref.output.result}'}) + ai_orchestrator.add_prompt_template(prompt.name, 'Hello my ${friend_name}', 'test prompt') + + ai_orchestrator.add_ai_integration('my_azure_open_ai', 'azure_openai', ['text-davinci-003', 'text-embedding-ada-002'], 'viren azure openai', + AzureOpenAIConfig('2dba20b4b1324f078ee00775c4d7733b','https://openai-test-dl.openai.azure.com/')) + tasks = [ SimpleTask('get_friend_name', 'get_friend_name_ref'), LlmTextComplete('say_hi', 'say_hi_ref', ai_config.llm_provider, ai_config.text_complete_model, prompt=prompt) ] - workflow = ConductorWorkflow(name='say_hi_to_the_friend') - workflow >> tasks - workflow.output_parameters = {'greetings': '${say_hi_ref.output.result}'} - task_executors = {'get_friend_name_ref': get_document} - wf_result = prompt_client.execute_workflow(workflow=workflow, wait_for_seconds=10, task_to_exec=task_executors) - print(wf_result.output) + # workflow = ConductorWorkflow(executor=None, name='say_hi_to_the_friend') + # workflow >> tasks + # workflow.output_parameters = {'greetings': '${say_hi_ref.output.result}'} + # task_executors = {'get_friend_name_ref': get_document} + # wf_result = prompt_client.execute_workflow(workflow=workflow, wait_for_seconds=10, task_to_exec=task_executors) + # print(wf_result.output) if __name__ == '__main__': From 397c8d42f5123a391c6f63351691b103029551b0 Mon Sep 17 00:00:00 2001 From: Viren Baraiya Date: Sun, 3 Dec 2023 00:00:12 -0800 Subject: [PATCH 7/9] more changes --- src/conductor/client/ai/orchestrator.py | 29 +- .../client/http/api/workflow_resource_api.py | 1215 ++++++++++------- .../client/http/models/prompt_test_request.py | 256 ++++ .../client/orkes/orkes_prompt_client.py | 14 + src/conductor/client/prompt_client.py | 5 + .../client/workflow/conductor_workflow.py | 15 +- .../workflow/executor/workflow_executor.py | 3 +- tests/ai_scratchpad/llm_prompt_test.py | 33 +- 8 files changed, 1052 insertions(+), 518 deletions(-) create mode 100644 src/conductor/client/http/models/prompt_test_request.py diff --git a/src/conductor/client/ai/orchestrator.py b/src/conductor/client/ai/orchestrator.py index e6990afc..df068427 100644 --- a/src/conductor/client/ai/orchestrator.py +++ b/src/conductor/client/ai/orchestrator.py @@ -41,29 +41,18 @@ def add_prompt_template(self, name: str, prompt_template: str, description: str) self.prompt_client.save_prompt(name, description, prompt_template) return self - def test_prompt_template(self, name: str, variables: dict, + def associate_prompt_template(self, name: str, ai_integration: str, ai_models: List[str]): + for ai_model in ai_models: + self.integration_client.associate_prompt_with_integration(ai_integration, ai_model, name) + + def test_prompt_template(self, text: str, variables: dict, + ai_integration: str, + text_complete_model: str, stop_words: Optional[List[str]] = [], max_tokens: Optional[int] = 100, temperature: int = 0, top_p: int = 1): - prompt = Prompt(name, variables) - llm_text_complete = LlmTextComplete( - 'prompt_test', 'prompt_test', - self.ai_configuration.llm_provider, self.ai_configuration.text_complete_model, - prompt, - stop_words, max_tokens, temperature, top_p - ) - name = self.prompt_test_workflow_name - prompt_test_workflow = ConductorWorkflow( - executor=self.workflow_executor, - name=name, - description='Prompt testing workflow from SDK' - ) - prompt_test_workflow.add(llm_text_complete) - output = prompt_test_workflow.execute({}) - if 'result' in output.keys(): - return output['result'] - else: - return '' + + return self.prompt_client.test_prompt(text, variables, ai_integration, text_complete_model, temperature, top_p, stop_words) def add_ai_integration(self, name: str, provider: str, models: List[str], description: str, config: IntegrationConfig): details = IntegrationUpdate() diff --git a/src/conductor/client/http/api/workflow_resource_api.py b/src/conductor/client/http/api/workflow_resource_api.py index 87df8471..c5d470cf 100644 --- a/src/conductor/client/http/api/workflow_resource_api.py +++ b/src/conductor/client/http/api/workflow_resource_api.py @@ -9,12 +9,6 @@ class WorkflowResourceApi(object): - """NOTE: This class is auto generated by the swagger code generator program. - - Do not edit the class manually. - Ref: https://github.com/swagger-api/swagger-codegen - """ - def __init__(self, api_client=None): if api_client is None: api_client = ApiClient() @@ -91,7 +85,7 @@ def decide_with_http_info(self, workflow_id, **kwargs): # noqa: E501 body_params = None # Authentication setting - auth_settings = [] # noqa: E501 + auth_settings = ['api_key'] # noqa: E501 return self.api_client.call_api( '/workflow/decide/{workflowId}', 'PUT', @@ -109,12 +103,12 @@ def decide_with_http_info(self, workflow_id, **kwargs): # noqa: E501 _request_timeout=params.get('_request_timeout'), collection_formats=collection_formats) - def delete(self, workflow_id, **kwargs): # noqa: E501 + def delete1(self, workflow_id, **kwargs): # noqa: E501 """Removes the workflow from the system # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.delete(workflow_id, async_req=True) + >>> thread = api.delete1(workflow_id, async_req=True) >>> result = thread.get() :param async_req bool @@ -126,17 +120,17 @@ def delete(self, workflow_id, **kwargs): # noqa: E501 """ kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): - return self.delete_with_http_info(workflow_id, **kwargs) # noqa: E501 + return self.delete1_with_http_info(workflow_id, **kwargs) # noqa: E501 else: - (data) = self.delete_with_http_info(workflow_id, **kwargs) # noqa: E501 + (data) = self.delete1_with_http_info(workflow_id, **kwargs) # noqa: E501 return data - def delete_with_http_info(self, workflow_id, **kwargs): # noqa: E501 + def delete1_with_http_info(self, workflow_id, **kwargs): # noqa: E501 """Removes the workflow from the system # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.delete_with_http_info(workflow_id, async_req=True) + >>> thread = api.delete1_with_http_info(workflow_id, async_req=True) >>> result = thread.get() :param async_req bool @@ -158,14 +152,14 @@ def delete_with_http_info(self, workflow_id, **kwargs): # noqa: E501 if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" - " to method delete" % key + " to method delete1" % key ) params[key] = val del params['kwargs'] # verify the required parameter 'workflow_id' is set if ('workflow_id' not in params or params['workflow_id'] is None): - raise ValueError("Missing the required parameter `workflow_id` when calling `delete`") # noqa: E501 + raise ValueError("Missing the required parameter `workflow_id` when calling `delete1`") # noqa: E501 collection_formats = {} @@ -184,7 +178,7 @@ def delete_with_http_info(self, workflow_id, **kwargs): # noqa: E501 body_params = None # Authentication setting - auth_settings = [] # noqa: E501 + auth_settings = ['api_key'] # noqa: E501 return self.api_client.call_api( '/workflow/{workflowId}/remove', 'DELETE', @@ -216,6 +210,7 @@ def execute_workflow(self, body, request_id, name, version, **kwargs): # noqa: :param str name: (required) :param int version: (required) :param str wait_until_task_ref: + :param int wait_for_seconds: :return: WorkflowRun If the method is called asynchronously, returns the request thread. @@ -239,14 +234,15 @@ def execute_workflow_with_http_info(self, body, request_id, name, version, **kwa :param StartWorkflowRequest body: (required) :param str request_id: (required) :param str name: (required) - :param int version: (required) set to 0 to use the latest version + :param int version: (required) :param str wait_until_task_ref: + :param int wait_for_seconds: :return: WorkflowRun If the method is called asynchronously, returns the request thread. """ - all_params = ['body', 'request_id', 'name', 'version', 'wait_until_task_ref'] # noqa: E501 + all_params = ['body', 'request_id', 'name', 'version', 'wait_until_task_ref', 'wait_for_seconds'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') @@ -268,7 +264,8 @@ def execute_workflow_with_http_info(self, body, request_id, name, version, **kwa # verify the required parameter 'request_id' is set if ('request_id' not in params or params['request_id'] is None): - raise ValueError("Missing the required parameter `request_id` when calling `execute_workflow`") # noqa: E501 + raise ValueError( + "Missing the required parameter `request_id` when calling `execute_workflow`") # noqa: E501 # verify the required parameter 'name' is set if ('name' not in params or params['name'] is None): @@ -291,6 +288,8 @@ def execute_workflow_with_http_info(self, body, request_id, name, version, **kwa query_params.append(('requestId', params['request_id'])) # noqa: E501 if 'wait_until_task_ref' in params: query_params.append(('waitUntilTaskRef', params['wait_until_task_ref'])) # noqa: E501 + if 'wait_for_seconds' in params: + query_params.append(('waitForSeconds', params['wait_for_seconds'])) # noqa: E501 header_params = {} @@ -309,7 +308,7 @@ def execute_workflow_with_http_info(self, body, request_id, name, version, **kwa ['application/json']) # noqa: E501 # Authentication setting - auth_settings = [] # noqa: E501 + auth_settings = ['api_key'] # noqa: E501 return self.api_client.call_api( '/workflow/execute/{name}/{version}', 'POST', @@ -327,6 +326,249 @@ def execute_workflow_with_http_info(self, body, request_id, name, version, **kwa _request_timeout=params.get('_request_timeout'), collection_formats=collection_formats) + def execute_workflow_as_api(self, body, name, **kwargs): # noqa: E501 + """Execute a workflow synchronously with input and outputs # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.execute_workflow_as_api(body, name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param dict(str, object) body: (required) + :param str name: (required) + :param str request_id: + :param str wait_until_task_ref: + :param int wait_for_seconds: + :param str authorization: + :param int version: + :return: dict(str, object) + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('async_req'): + return self.execute_workflow_as_api_with_http_info(body, name, **kwargs) # noqa: E501 + else: + (data) = self.execute_workflow_as_api_with_http_info(body, name, **kwargs) # noqa: E501 + return data + + def execute_workflow_as_api_with_http_info(self, body, name, **kwargs): # noqa: E501 + """Execute a workflow synchronously with input and outputs # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.execute_workflow_as_api_with_http_info(body, name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param dict(str, object) body: (required) + :param str name: (required) + :param str request_id: + :param str wait_until_task_ref: + :param int wait_for_seconds: + :param str authorization: + :param int version: + :return: dict(str, object) + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['body', 'name', 'request_id', 'wait_until_task_ref', 'wait_for_seconds', 'authorization', + 'version'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + + params = locals() + for key, val in six.iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method execute_workflow_as_api" % key + ) + params[key] = val + del params['kwargs'] + # verify the required parameter 'body' is set + if ('body' not in params or + params['body'] is None): + raise ValueError( + "Missing the required parameter `body` when calling `execute_workflow_as_api`") # noqa: E501 + # verify the required parameter 'name' is set + if ('name' not in params or + params['name'] is None): + raise ValueError( + "Missing the required parameter `name` when calling `execute_workflow_as_api`") # noqa: E501 + + collection_formats = {} + + path_params = {} + if 'name' in params: + path_params['name'] = params['name'] # noqa: E501 + + query_params = [] + if 'version' in params: + query_params.append(('version', params['version'])) # noqa: E501 + + header_params = {} + if 'request_id' in params: + header_params['requestId'] = params['request_id'] # noqa: E501 + if 'wait_until_task_ref' in params: + header_params['waitUntilTaskRef'] = params['wait_until_task_ref'] # noqa: E501 + if 'wait_for_seconds' in params: + header_params['waitForSeconds'] = params['wait_for_seconds'] # noqa: E501 + if 'authorization' in params: + header_params['authorization'] = params['authorization'] # noqa: E501 + + form_params = [] + local_var_files = {} + + body_params = None + if 'body' in params: + body_params = params['body'] + # HTTP header `Accept` + header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 + ['application/json']) # noqa: E501 + + # Authentication setting + auth_settings = ['api_key'] # noqa: E501 + + return self.api_client.call_api( + '/workflow/execute/{name}', 'POST', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type='dict(str, object)', # noqa: E501 + auth_settings=auth_settings, + async_req=params.get('async_req'), + _return_http_data_only=params.get('_return_http_data_only'), + _preload_content=params.get('_preload_content', True), + _request_timeout=params.get('_request_timeout'), + collection_formats=collection_formats) + + def execute_workflow_as_get_api(self, name, **kwargs): # noqa: E501 + """Execute a workflow synchronously with input and outputs using get api # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.execute_workflow_as_get_api(name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param str name: (required) + :param int version: + :param str request_id: + :param str wait_until_task_ref: + :param int wait_for_seconds: + :param str authorization: + :return: dict(str, object) + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('async_req'): + return self.execute_workflow_as_get_api_with_http_info(name, **kwargs) # noqa: E501 + else: + (data) = self.execute_workflow_as_get_api_with_http_info(name, **kwargs) # noqa: E501 + return data + + def execute_workflow_as_get_api_with_http_info(self, name, **kwargs): # noqa: E501 + """Execute a workflow synchronously with input and outputs using get api # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.execute_workflow_as_get_api_with_http_info(name, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param str name: (required) + :param int version: + :param str request_id: + :param str wait_until_task_ref: + :param int wait_for_seconds: + :param str authorization: + :return: dict(str, object) + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['name', 'version', 'request_id', 'wait_until_task_ref', 'wait_for_seconds', + 'authorization'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + + params = locals() + for key, val in six.iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method execute_workflow_as_get_api" % key + ) + params[key] = val + del params['kwargs'] + # verify the required parameter 'name' is set + if ('name' not in params or + params['name'] is None): + raise ValueError( + "Missing the required parameter `name` when calling `execute_workflow_as_get_api`") # noqa: E501 + + collection_formats = {} + + path_params = {} + if 'name' in params: + path_params['name'] = params['name'] # noqa: E501 + + query_params = [] + if 'version' in params: + query_params.append(('version', params['version'])) # noqa: E501 + + header_params = {} + if 'request_id' in params: + header_params['requestId'] = params['request_id'] # noqa: E501 + if 'wait_until_task_ref' in params: + header_params['waitUntilTaskRef'] = params['wait_until_task_ref'] # noqa: E501 + if 'wait_for_seconds' in params: + header_params['waitForSeconds'] = params['wait_for_seconds'] # noqa: E501 + if 'authorization' in params: + header_params['authorization'] = params['authorization'] # noqa: E501 + + form_params = [] + local_var_files = {} + + body_params = None + # HTTP header `Accept` + header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # Authentication setting + auth_settings = ['api_key'] # noqa: E501 + + return self.api_client.call_api( + '/workflow/execute/{name}', 'GET', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type='dict(str, object)', # noqa: E501 + auth_settings=auth_settings, + async_req=params.get('async_req'), + _return_http_data_only=params.get('_return_http_data_only'), + _preload_content=params.get('_preload_content', True), + _request_timeout=params.get('_request_timeout'), + collection_formats=collection_formats) + def get_execution_status(self, workflow_id, **kwargs): # noqa: E501 """Gets the workflow by workflow id # noqa: E501 @@ -338,6 +580,7 @@ def get_execution_status(self, workflow_id, **kwargs): # noqa: E501 :param async_req bool :param str workflow_id: (required) :param bool include_tasks: + :param bool summarize: :return: Workflow If the method is called asynchronously, returns the request thread. @@ -360,12 +603,13 @@ def get_execution_status_with_http_info(self, workflow_id, **kwargs): # noqa: E :param async_req bool :param str workflow_id: (required) :param bool include_tasks: + :param bool summarize: :return: Workflow If the method is called asynchronously, returns the request thread. """ - all_params = ['workflow_id', 'include_tasks'] # noqa: E501 + all_params = ['workflow_id', 'include_tasks', 'summarize'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') @@ -383,7 +627,8 @@ def get_execution_status_with_http_info(self, workflow_id, **kwargs): # noqa: E # verify the required parameter 'workflow_id' is set if ('workflow_id' not in params or params['workflow_id'] is None): - raise ValueError("Missing the required parameter `workflow_id` when calling `get_execution_status`") # noqa: E501 + raise ValueError( + "Missing the required parameter `workflow_id` when calling `get_execution_status`") # noqa: E501 collection_formats = {} @@ -394,6 +639,8 @@ def get_execution_status_with_http_info(self, workflow_id, **kwargs): # noqa: E query_params = [] if 'include_tasks' in params: query_params.append(('includeTasks', params['include_tasks'])) # noqa: E501 + if 'summarize' in params: + query_params.append(('summarize', params['summarize'])) # noqa: E501 header_params = {} @@ -406,7 +653,7 @@ def get_execution_status_with_http_info(self, workflow_id, **kwargs): # noqa: E ['*/*']) # noqa: E501 # Authentication setting - auth_settings = [] # noqa: E501 + auth_settings = ['api_key'] # noqa: E501 return self.api_client.call_api( '/workflow/{workflowId}', 'GET', @@ -424,47 +671,49 @@ def get_execution_status_with_http_info(self, workflow_id, **kwargs): # noqa: E _request_timeout=params.get('_request_timeout'), collection_formats=collection_formats) - def get_external_storage_location(self, path, operation, payload_type, **kwargs): # noqa: E501 - """Get the uri and path of the external storage where the workflow payload is to be stored # noqa: E501 + def get_execution_status_task_list(self, workflow_id, **kwargs): # noqa: E501 + """Gets the workflow tasks by workflow id # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_external_storage_location(path, operation, payload_type, async_req=True) + >>> thread = api.get_execution_status_task_list(workflow_id, async_req=True) >>> result = thread.get() :param async_req bool - :param str path: (required) - :param str operation: (required) - :param str payload_type: (required) - :return: ExternalStorageLocation + :param str workflow_id: (required) + :param int start: + :param int count: + :param list[str] status: + :return: TaskListSearchResultSummary If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): - return self.get_external_storage_location_with_http_info(path, operation, payload_type, **kwargs) # noqa: E501 + return self.get_execution_status_task_list_with_http_info(workflow_id, **kwargs) # noqa: E501 else: - (data) = self.get_external_storage_location_with_http_info(path, operation, payload_type, **kwargs) # noqa: E501 + (data) = self.get_execution_status_task_list_with_http_info(workflow_id, **kwargs) # noqa: E501 return data - def get_external_storage_location_with_http_info(self, path, operation, payload_type, **kwargs): # noqa: E501 - """Get the uri and path of the external storage where the workflow payload is to be stored # noqa: E501 + def get_execution_status_task_list_with_http_info(self, workflow_id, **kwargs): # noqa: E501 + """Gets the workflow tasks by workflow id # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_external_storage_location_with_http_info(path, operation, payload_type, async_req=True) + >>> thread = api.get_execution_status_task_list_with_http_info(workflow_id, async_req=True) >>> result = thread.get() :param async_req bool - :param str path: (required) - :param str operation: (required) - :param str payload_type: (required) - :return: ExternalStorageLocation + :param str workflow_id: (required) + :param int start: + :param int count: + :param list[str] status: + :return: TaskListSearchResultSummary If the method is called asynchronously, returns the request thread. """ - all_params = ['path', 'operation', 'payload_type'] # noqa: E501 + all_params = ['workflow_id', 'start', 'count', 'status'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') @@ -475,34 +724,30 @@ def get_external_storage_location_with_http_info(self, path, operation, payload_ if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" - " to method get_external_storage_location" % key + " to method get_execution_status_task_list" % key ) params[key] = val del params['kwargs'] - # verify the required parameter 'path' is set - if ('path' not in params or - params['path'] is None): - raise ValueError("Missing the required parameter `path` when calling `get_external_storage_location`") # noqa: E501 - # verify the required parameter 'operation' is set - if ('operation' not in params or - params['operation'] is None): - raise ValueError("Missing the required parameter `operation` when calling `get_external_storage_location`") # noqa: E501 - # verify the required parameter 'payload_type' is set - if ('payload_type' not in params or - params['payload_type'] is None): - raise ValueError("Missing the required parameter `payload_type` when calling `get_external_storage_location`") # noqa: E501 + # verify the required parameter 'workflow_id' is set + if ('workflow_id' not in params or + params['workflow_id'] is None): + raise ValueError( + "Missing the required parameter `workflow_id` when calling `get_execution_status_task_list`") # noqa: E501 collection_formats = {} path_params = {} + if 'workflow_id' in params: + path_params['workflowId'] = params['workflow_id'] # noqa: E501 query_params = [] - if 'path' in params: - query_params.append(('path', params['path'])) # noqa: E501 - if 'operation' in params: - query_params.append(('operation', params['operation'])) # noqa: E501 - if 'payload_type' in params: - query_params.append(('payloadType', params['payload_type'])) # noqa: E501 + if 'start' in params: + query_params.append(('start', params['start'])) # noqa: E501 + if 'count' in params: + query_params.append(('count', params['count'])) # noqa: E501 + if 'status' in params: + query_params.append(('status', params['status'])) # noqa: E501 + collection_formats['status'] = 'multi' # noqa: E501 header_params = {} @@ -515,17 +760,17 @@ def get_external_storage_location_with_http_info(self, path, operation, payload_ ['*/*']) # noqa: E501 # Authentication setting - auth_settings = [] # noqa: E501 + auth_settings = ['api_key'] # noqa: E501 return self.api_client.call_api( - '/workflow/externalstoragelocation', 'GET', + '/workflow/{workflowId}/tasks', 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='ExternalStorageLocation', # noqa: E501 + response_type='TaskListSearchResultSummary', # noqa: E501 auth_settings=auth_settings, async_req=params.get('async_req'), _return_http_data_only=params.get('_return_http_data_only'), @@ -620,7 +865,7 @@ def get_running_workflow_with_http_info(self, name, **kwargs): # noqa: E501 ['*/*']) # noqa: E501 # Authentication setting - auth_settings = [] # noqa: E501 + auth_settings = ['api_key'] # noqa: E501 return self.api_client.call_api( '/workflow/running/{name}', 'GET', @@ -696,7 +941,8 @@ def get_workflow_status_summary_with_http_info(self, workflow_id, **kwargs): # # verify the required parameter 'workflow_id' is set if ('workflow_id' not in params or params['workflow_id'] is None): - raise ValueError("Missing the required parameter `workflow_id` when calling `get_workflow_status_summary`") # noqa: E501 + raise ValueError( + "Missing the required parameter `workflow_id` when calling `get_workflow_status_summary`") # noqa: E501 collection_formats = {} @@ -721,7 +967,7 @@ def get_workflow_status_summary_with_http_info(self, workflow_id, **kwargs): # ['*/*']) # noqa: E501 # Authentication setting - auth_settings = [] # noqa: E501 + auth_settings = ['api_key'] # noqa: E501 return self.api_client.call_api( '/workflow/{workflowId}/status', 'GET', @@ -834,7 +1080,7 @@ def get_workflows_with_http_info(self, body, name, **kwargs): # noqa: E501 ['application/json']) # noqa: E501 # Authentication setting - auth_settings = [] # noqa: E501 + auth_settings = ['api_key'] # noqa: E501 return self.api_client.call_api( '/workflow/{name}/correlated', 'POST', @@ -852,49 +1098,47 @@ def get_workflows_with_http_info(self, body, name, **kwargs): # noqa: E501 _request_timeout=params.get('_request_timeout'), collection_formats=collection_formats) - def get_workflows1(self, name, correlation_id, **kwargs): # noqa: E501 - """Lists workflows for the given correlation id # noqa: E501 + def get_workflows1(self, body, **kwargs): # noqa: E501 + """Lists workflows for the given correlation id list and workflow name list # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_workflows1(name, correlation_id, async_req=True) + >>> thread = api.get_workflows1(body, async_req=True) >>> result = thread.get() :param async_req bool - :param str name: (required) - :param str correlation_id: (required) + :param CorrelationIdsSearchRequest body: (required) :param bool include_closed: :param bool include_tasks: - :return: list[Workflow] + :return: dict(str, list[Workflow]) If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): - return self.get_workflows1_with_http_info(name, correlation_id, **kwargs) # noqa: E501 + return self.get_workflows1_with_http_info(body, **kwargs) # noqa: E501 else: - (data) = self.get_workflows1_with_http_info(name, correlation_id, **kwargs) # noqa: E501 + (data) = self.get_workflows1_with_http_info(body, **kwargs) # noqa: E501 return data - def get_workflows1_with_http_info(self, name, correlation_id, **kwargs): # noqa: E501 - """Lists workflows for the given correlation id # noqa: E501 + def get_workflows1_with_http_info(self, body, **kwargs): # noqa: E501 + """Lists workflows for the given correlation id list and workflow name list # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_workflows1_with_http_info(name, correlation_id, async_req=True) + >>> thread = api.get_workflows1_with_http_info(body, async_req=True) >>> result = thread.get() :param async_req bool - :param str name: (required) - :param str correlation_id: (required) + :param CorrelationIdsSearchRequest body: (required) :param bool include_closed: :param bool include_tasks: - :return: list[Workflow] + :return: dict(str, list[Workflow]) If the method is called asynchronously, returns the request thread. """ - all_params = ['name', 'correlation_id', 'include_closed', 'include_tasks'] # noqa: E501 + all_params = ['body', 'include_closed', 'include_tasks'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') @@ -909,22 +1153,14 @@ def get_workflows1_with_http_info(self, name, correlation_id, **kwargs): # noqa ) params[key] = val del params['kwargs'] - # verify the required parameter 'name' is set - if ('name' not in params or - params['name'] is None): - raise ValueError("Missing the required parameter `name` when calling `get_workflows1`") # noqa: E501 - # verify the required parameter 'correlation_id' is set - if ('correlation_id' not in params or - params['correlation_id'] is None): - raise ValueError("Missing the required parameter `correlation_id` when calling `get_workflows1`") # noqa: E501 + # verify the required parameter 'body' is set + if ('body' not in params or + params['body'] is None): + raise ValueError("Missing the required parameter `body` when calling `get_workflows1`") # noqa: E501 collection_formats = {} path_params = {} - if 'name' in params: - path_params['name'] = params['name'] # noqa: E501 - if 'correlation_id' in params: - path_params['correlationId'] = params['correlation_id'] # noqa: E501 query_params = [] if 'include_closed' in params: @@ -938,70 +1174,78 @@ def get_workflows1_with_http_info(self, name, correlation_id, **kwargs): # noqa local_var_files = {} body_params = None + if 'body' in params: + body_params = params['body'] # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept( ['*/*']) # noqa: E501 + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 + ['application/json']) # noqa: E501 + # Authentication setting - auth_settings = [] # noqa: E501 + auth_settings = ['api_key'] # noqa: E501 return self.api_client.call_api( - '/workflow/{name}/correlated/{correlationId}', 'GET', + '/workflow/correlated/batch', 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[Workflow]', # noqa: E501 + response_type='dict(str, list[Workflow])', # noqa: E501 auth_settings=auth_settings, async_req=params.get('async_req'), _return_http_data_only=params.get('_return_http_data_only'), _preload_content=params.get('_preload_content', True), _request_timeout=params.get('_request_timeout'), collection_formats=collection_formats) - - def get_workflows_batch(self, body, **kwargs): # noqa: E501 - """Lists workflows for the given correlation id list and workflow name list # noqa: E501 + + def get_workflows2(self, name, correlation_id, **kwargs): # noqa: E501 + """Lists workflows for the given correlation id # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_workflows1(body, async_req=True) + >>> thread = api.get_workflows2(name, correlation_id, async_req=True) >>> result = thread.get() :param async_req bool - :param CorrelationIdsSearchRequest body: (required) + :param str name: (required) + :param str correlation_id: (required) :param bool include_closed: :param bool include_tasks: - :return: dict(str, list[Workflow]) + :return: list[Workflow] If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): - return self.get_workflows_batch_with_http_info(body, **kwargs) # noqa: E501 + return self.get_workflows2_with_http_info(name, correlation_id, **kwargs) # noqa: E501 else: - (data) = self.get_workflows_batch_with_http_info(body, **kwargs) # noqa: E501 + (data) = self.get_workflows2_with_http_info(name, correlation_id, **kwargs) # noqa: E501 return data - def get_workflows_batch_with_http_info(self, body, **kwargs): # noqa: E501 - """Lists workflows for the given correlation id list and workflow name list # noqa: E501 + def get_workflows2_with_http_info(self, name, correlation_id, **kwargs): # noqa: E501 + """Lists workflows for the given correlation id # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_workflows1_with_http_info(body, async_req=True) + >>> thread = api.get_workflows2_with_http_info(name, correlation_id, async_req=True) >>> result = thread.get() :param async_req bool - :param CorrelationIdsSearchRequest body: (required) + :param str name: (required) + :param str correlation_id: (required) :param bool include_closed: :param bool include_tasks: - :return: dict(str, list[Workflow]) + :return: list[Workflow] If the method is called asynchronously, returns the request thread. """ - all_params = ['body', 'include_closed', 'include_tasks'] # noqa: E501 + all_params = ['name', 'correlation_id', 'include_closed', 'include_tasks'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') @@ -1012,18 +1256,27 @@ def get_workflows_batch_with_http_info(self, body, **kwargs): # noqa: E501 if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" - " to method get_workflows_batch" % key + " to method get_workflows2" % key ) params[key] = val del params['kwargs'] - # verify the required parameter 'body' is set - if ('body' not in params or - params['body'] is None): - raise ValueError("Missing the required parameter `body` when calling `get_workflows_batch`") # noqa: E501 + # verify the required parameter 'name' is set + if ('name' not in params or + params['name'] is None): + raise ValueError("Missing the required parameter `name` when calling `get_workflows2`") # noqa: E501 + # verify the required parameter 'correlation_id' is set + if ('correlation_id' not in params or + params['correlation_id'] is None): + raise ValueError( + "Missing the required parameter `correlation_id` when calling `get_workflows2`") # noqa: E501 collection_formats = {} path_params = {} + if 'name' in params: + path_params['name'] = params['name'] # noqa: E501 + if 'correlation_id' in params: + path_params['correlationId'] = params['correlation_id'] # noqa: E501 query_params = [] if 'include_closed' in params: @@ -1037,28 +1290,129 @@ def get_workflows_batch_with_http_info(self, body, **kwargs): # noqa: E501 local_var_files = {} body_params = None - if 'body' in params: - body_params = params['body'] # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept( ['*/*']) # noqa: E501 + # Authentication setting + auth_settings = ['api_key'] # noqa: E501 + + return self.api_client.call_api( + '/workflow/{name}/correlated/{correlationId}', 'GET', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type='list[Workflow]', # noqa: E501 + auth_settings=auth_settings, + async_req=params.get('async_req'), + _return_http_data_only=params.get('_return_http_data_only'), + _preload_content=params.get('_preload_content', True), + _request_timeout=params.get('_request_timeout'), + collection_formats=collection_formats) + + def jump_to_task(self, body, workflow_id, **kwargs): # noqa: E501 + """Jump workflow execution to given task # noqa: E501 + + Jump workflow execution to given task. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.jump_to_task(body, workflow_id, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param dict(str, object) body: (required) + :param str workflow_id: (required) + :param str task_reference_name: + :return: None + If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + if kwargs.get('async_req'): + return self.jump_to_task_with_http_info(body, workflow_id, **kwargs) # noqa: E501 + else: + (data) = self.jump_to_task_with_http_info(body, workflow_id, **kwargs) # noqa: E501 + return data + + def jump_to_task_with_http_info(self, body, workflow_id, **kwargs): # noqa: E501 + """Jump workflow execution to given task # noqa: E501 + + Jump workflow execution to given task. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.jump_to_task_with_http_info(body, workflow_id, async_req=True) + >>> result = thread.get() + + :param async_req bool + :param dict(str, object) body: (required) + :param str workflow_id: (required) + :param str task_reference_name: + :return: None + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['body', 'workflow_id', 'task_reference_name'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + + params = locals() + for key, val in six.iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method jump_to_task" % key + ) + params[key] = val + del params['kwargs'] + # verify the required parameter 'body' is set + if ('body' not in params or + params['body'] is None): + raise ValueError("Missing the required parameter `body` when calling `jump_to_task`") # noqa: E501 + # verify the required parameter 'workflow_id' is set + if ('workflow_id' not in params or + params['workflow_id'] is None): + raise ValueError("Missing the required parameter `workflow_id` when calling `jump_to_task`") # noqa: E501 + + collection_formats = {} + + path_params = {} + if 'workflow_id' in params: + path_params['workflowId'] = params['workflow_id'] # noqa: E501 + + query_params = [] + if 'task_reference_name' in params: + query_params.append(('taskReferenceName', params['task_reference_name'])) # noqa: E501 + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + if 'body' in params: + body_params = params['body'] # HTTP header `Content-Type` header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 ['application/json']) # noqa: E501 # Authentication setting - auth_settings = [] # noqa: E501 + auth_settings = ['api_key'] # noqa: E501 return self.api_client.call_api( - '/workflow/correlated/batch', 'POST', + '/workflow/{workflowId}/jump/{taskReferenceName}', 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='dict(str, list[Workflow])', # noqa: E501 + response_type=None, # noqa: E501 auth_settings=auth_settings, async_req=params.get('async_req'), _return_http_data_only=params.get('_return_http_data_only'), @@ -1066,12 +1420,12 @@ def get_workflows_batch_with_http_info(self, body, **kwargs): # noqa: E501 _request_timeout=params.get('_request_timeout'), collection_formats=collection_formats) - def pause_workflow1(self, workflow_id, **kwargs): # noqa: E501 + def pause_workflow(self, workflow_id, **kwargs): # noqa: E501 """Pauses the workflow # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.pause_workflow1(workflow_id, async_req=True) + >>> thread = api.pause_workflow(workflow_id, async_req=True) >>> result = thread.get() :param async_req bool @@ -1082,17 +1436,17 @@ def pause_workflow1(self, workflow_id, **kwargs): # noqa: E501 """ kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): - return self.pause_workflow1_with_http_info(workflow_id, **kwargs) # noqa: E501 + return self.pause_workflow_with_http_info(workflow_id, **kwargs) # noqa: E501 else: - (data) = self.pause_workflow1_with_http_info(workflow_id, **kwargs) # noqa: E501 + (data) = self.pause_workflow_with_http_info(workflow_id, **kwargs) # noqa: E501 return data - def pause_workflow1_with_http_info(self, workflow_id, **kwargs): # noqa: E501 + def pause_workflow_with_http_info(self, workflow_id, **kwargs): # noqa: E501 """Pauses the workflow # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.pause_workflow1_with_http_info(workflow_id, async_req=True) + >>> thread = api.pause_workflow_with_http_info(workflow_id, async_req=True) >>> result = thread.get() :param async_req bool @@ -1113,14 +1467,14 @@ def pause_workflow1_with_http_info(self, workflow_id, **kwargs): # noqa: E501 if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" - " to method pause_workflow1" % key + " to method pause_workflow" % key ) params[key] = val del params['kwargs'] # verify the required parameter 'workflow_id' is set if ('workflow_id' not in params or params['workflow_id'] is None): - raise ValueError("Missing the required parameter `workflow_id` when calling `pause_workflow1`") # noqa: E501 + raise ValueError("Missing the required parameter `workflow_id` when calling `pause_workflow`") # noqa: E501 collection_formats = {} @@ -1137,7 +1491,7 @@ def pause_workflow1_with_http_info(self, workflow_id, **kwargs): # noqa: E501 body_params = None # Authentication setting - auth_settings = [] # noqa: E501 + auth_settings = ['api_key'] # noqa: E501 return self.api_client.call_api( '/workflow/{workflowId}/pause', 'PUT', @@ -1242,7 +1596,7 @@ def rerun_with_http_info(self, body, workflow_id, **kwargs): # noqa: E501 ['application/json']) # noqa: E501 # Authentication setting - auth_settings = [] # noqa: E501 + auth_settings = ['api_key'] # noqa: E501 return self.api_client.call_api( '/workflow/{workflowId}/rerun', 'POST', @@ -1331,7 +1685,7 @@ def reset_workflow_with_http_info(self, workflow_id, **kwargs): # noqa: E501 body_params = None # Authentication setting - auth_settings = [] # noqa: E501 + auth_settings = ['api_key'] # noqa: E501 return self.api_client.call_api( '/workflow/{workflowId}/resetcallbacks', 'POST', @@ -1349,12 +1703,12 @@ def reset_workflow_with_http_info(self, workflow_id, **kwargs): # noqa: E501 _request_timeout=params.get('_request_timeout'), collection_formats=collection_formats) - def restart1(self, workflow_id, **kwargs): # noqa: E501 + def restart(self, workflow_id, **kwargs): # noqa: E501 """Restarts a completed workflow # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.restart1(workflow_id, async_req=True) + >>> thread = api.restart(workflow_id, async_req=True) >>> result = thread.get() :param async_req bool @@ -1366,17 +1720,17 @@ def restart1(self, workflow_id, **kwargs): # noqa: E501 """ kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): - return self.restart1_with_http_info(workflow_id, **kwargs) # noqa: E501 + return self.restart_with_http_info(workflow_id, **kwargs) # noqa: E501 else: - (data) = self.restart1_with_http_info(workflow_id, **kwargs) # noqa: E501 + (data) = self.restart_with_http_info(workflow_id, **kwargs) # noqa: E501 return data - def restart1_with_http_info(self, workflow_id, **kwargs): # noqa: E501 + def restart_with_http_info(self, workflow_id, **kwargs): # noqa: E501 """Restarts a completed workflow # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.restart1_with_http_info(workflow_id, async_req=True) + >>> thread = api.restart_with_http_info(workflow_id, async_req=True) >>> result = thread.get() :param async_req bool @@ -1398,14 +1752,14 @@ def restart1_with_http_info(self, workflow_id, **kwargs): # noqa: E501 if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" - " to method restart1" % key + " to method restart" % key ) params[key] = val del params['kwargs'] # verify the required parameter 'workflow_id' is set if ('workflow_id' not in params or params['workflow_id'] is None): - raise ValueError("Missing the required parameter `workflow_id` when calling `restart1`") # noqa: E501 + raise ValueError("Missing the required parameter `workflow_id` when calling `restart`") # noqa: E501 collection_formats = {} @@ -1424,7 +1778,7 @@ def restart1_with_http_info(self, workflow_id, **kwargs): # noqa: E501 body_params = None # Authentication setting - auth_settings = [] # noqa: E501 + auth_settings = ['api_key'] # noqa: E501 return self.api_client.call_api( '/workflow/{workflowId}/restart', 'POST', @@ -1442,12 +1796,12 @@ def restart1_with_http_info(self, workflow_id, **kwargs): # noqa: E501 _request_timeout=params.get('_request_timeout'), collection_formats=collection_formats) - def resume_workflow1(self, workflow_id, **kwargs): # noqa: E501 + def resume_workflow(self, workflow_id, **kwargs): # noqa: E501 """Resumes the workflow # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.resume_workflow1(workflow_id, async_req=True) + >>> thread = api.resume_workflow(workflow_id, async_req=True) >>> result = thread.get() :param async_req bool @@ -1458,17 +1812,17 @@ def resume_workflow1(self, workflow_id, **kwargs): # noqa: E501 """ kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): - return self.resume_workflow1_with_http_info(workflow_id, **kwargs) # noqa: E501 + return self.resume_workflow_with_http_info(workflow_id, **kwargs) # noqa: E501 else: - (data) = self.resume_workflow1_with_http_info(workflow_id, **kwargs) # noqa: E501 + (data) = self.resume_workflow_with_http_info(workflow_id, **kwargs) # noqa: E501 return data - def resume_workflow1_with_http_info(self, workflow_id, **kwargs): # noqa: E501 + def resume_workflow_with_http_info(self, workflow_id, **kwargs): # noqa: E501 """Resumes the workflow # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.resume_workflow1_with_http_info(workflow_id, async_req=True) + >>> thread = api.resume_workflow_with_http_info(workflow_id, async_req=True) >>> result = thread.get() :param async_req bool @@ -1489,14 +1843,15 @@ def resume_workflow1_with_http_info(self, workflow_id, **kwargs): # noqa: E501 if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" - " to method resume_workflow1" % key + " to method resume_workflow" % key ) params[key] = val del params['kwargs'] # verify the required parameter 'workflow_id' is set if ('workflow_id' not in params or params['workflow_id'] is None): - raise ValueError("Missing the required parameter `workflow_id` when calling `resume_workflow1`") # noqa: E501 + raise ValueError( + "Missing the required parameter `workflow_id` when calling `resume_workflow`") # noqa: E501 collection_formats = {} @@ -1513,7 +1868,7 @@ def resume_workflow1_with_http_info(self, workflow_id, **kwargs): # noqa: E501 body_params = None # Authentication setting - auth_settings = [] # noqa: E501 + auth_settings = ['api_key'] # noqa: E501 return self.api_client.call_api( '/workflow/{workflowId}/resume', 'PUT', @@ -1531,45 +1886,47 @@ def resume_workflow1_with_http_info(self, workflow_id, **kwargs): # noqa: E501 _request_timeout=params.get('_request_timeout'), collection_formats=collection_formats) - def retry1(self, workflow_id, **kwargs): # noqa: E501 + def retry(self, workflow_id, **kwargs): # noqa: E501 """Retries the last failed task # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.retry1(workflow_id, async_req=True) + >>> thread = api.retry(workflow_id, async_req=True) >>> result = thread.get() :param async_req bool :param str workflow_id: (required) :param bool resume_subworkflow_tasks: + :param bool retry_if_retried_by_parent: :return: None If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): - return self.retry1_with_http_info(workflow_id, **kwargs) # noqa: E501 + return self.retry_with_http_info(workflow_id, **kwargs) # noqa: E501 else: - (data) = self.retry1_with_http_info(workflow_id, **kwargs) # noqa: E501 + (data) = self.retry_with_http_info(workflow_id, **kwargs) # noqa: E501 return data - def retry1_with_http_info(self, workflow_id, **kwargs): # noqa: E501 + def retry_with_http_info(self, workflow_id, **kwargs): # noqa: E501 """Retries the last failed task # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.retry1_with_http_info(workflow_id, async_req=True) + >>> thread = api.retry_with_http_info(workflow_id, async_req=True) >>> result = thread.get() :param async_req bool :param str workflow_id: (required) :param bool resume_subworkflow_tasks: + :param bool retry_if_retried_by_parent: :return: None If the method is called asynchronously, returns the request thread. """ - all_params = ['workflow_id', 'resume_subworkflow_tasks'] # noqa: E501 + all_params = ['workflow_id', 'resume_subworkflow_tasks', 'retry_if_retried_by_parent'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') @@ -1580,14 +1937,14 @@ def retry1_with_http_info(self, workflow_id, **kwargs): # noqa: E501 if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" - " to method retry1" % key + " to method retry" % key ) params[key] = val del params['kwargs'] # verify the required parameter 'workflow_id' is set if ('workflow_id' not in params or params['workflow_id'] is None): - raise ValueError("Missing the required parameter `workflow_id` when calling `retry1`") # noqa: E501 + raise ValueError("Missing the required parameter `workflow_id` when calling `retry`") # noqa: E501 collection_formats = {} @@ -1598,6 +1955,8 @@ def retry1_with_http_info(self, workflow_id, **kwargs): # noqa: E501 query_params = [] if 'resume_subworkflow_tasks' in params: query_params.append(('resumeSubworkflowTasks', params['resume_subworkflow_tasks'])) # noqa: E501 + if 'retry_if_retried_by_parent' in params: + query_params.append(('retryIfRetriedByParent', params['retry_if_retried_by_parent'])) # noqa: E501 header_params = {} @@ -1606,7 +1965,7 @@ def retry1_with_http_info(self, workflow_id, **kwargs): # noqa: E501 body_params = None # Authentication setting - auth_settings = [] # noqa: E501 + auth_settings = ['api_key'] # noqa: E501 return self.api_client.call_api( '/workflow/{workflowId}/retry', 'POST', @@ -1627,7 +1986,7 @@ def retry1_with_http_info(self, workflow_id, **kwargs): # noqa: E501 def search(self, **kwargs): # noqa: E501 """Search for workflows based on payload and other parameters # noqa: E501 - use sort options as sort=:ASC|DESC e.g. sort=name&sort=workflowId:DESC. If order is not specified, defaults to ASC. # noqa: E501 + Search for workflows based on payload and other parameters. The query parameter accepts exact matches using `=` and `IN` on the following fields: `workflowId`, `correlationId`, `taskId`, `workflowType`, `taskType`, and `status`. Matches using `=` can be written as `taskType = HTTP`. Matches using `IN` are written as `status IN (SCHEDULED, IN_PROGRESS)`. The 'startTime' and 'modifiedTime' field uses unix timestamps and accepts queries using `<` and `>`, for example `startTime < 1696143600000`. Queries can be combined using `AND`, for example `taskType = HTTP AND status = SCHEDULED`. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.search(async_req=True) @@ -1637,7 +1996,6 @@ def search(self, **kwargs): # noqa: E501 :param str query_id: :param int start: :param int size: - :param str sort: :param str free_text: :param str query: :param bool skip_cache: @@ -1655,7 +2013,7 @@ def search(self, **kwargs): # noqa: E501 def search_with_http_info(self, **kwargs): # noqa: E501 """Search for workflows based on payload and other parameters # noqa: E501 - use sort options as sort=:ASC|DESC e.g. sort=name&sort=workflowId:DESC. If order is not specified, defaults to ASC. # noqa: E501 + Search for workflows based on payload and other parameters. The query parameter accepts exact matches using `=` and `IN` on the following fields: `workflowId`, `correlationId`, `taskId`, `workflowType`, `taskType`, and `status`. Matches using `=` can be written as `taskType = HTTP`. Matches using `IN` are written as `status IN (SCHEDULED, IN_PROGRESS)`. The 'startTime' and 'modifiedTime' field uses unix timestamps and accepts queries using `<` and `>`, for example `startTime < 1696143600000`. Queries can be combined using `AND`, for example `taskType = HTTP AND status = SCHEDULED`. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.search_with_http_info(async_req=True) @@ -1665,7 +2023,6 @@ def search_with_http_info(self, **kwargs): # noqa: E501 :param str query_id: :param int start: :param int size: - :param str sort: :param str free_text: :param str query: :param bool skip_cache: @@ -1674,7 +2031,7 @@ def search_with_http_info(self, **kwargs): # noqa: E501 returns the request thread. """ - all_params = ['query_id', 'start', 'size', 'sort', 'free_text', 'query', 'skip_cache'] # noqa: E501 + all_params = ['query_id', 'start', 'size', 'free_text', 'query', 'skip_cache'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') @@ -1701,8 +2058,6 @@ def search_with_http_info(self, **kwargs): # noqa: E501 query_params.append(('start', params['start'])) # noqa: E501 if 'size' in params: query_params.append(('size', params['size'])) # noqa: E501 - if 'sort' in params: - query_params.append(('sort', params['sort'])) # noqa: E501 if 'free_text' in params: query_params.append(('freeText', params['free_text'])) # noqa: E501 if 'query' in params: @@ -1721,7 +2076,7 @@ def search_with_http_info(self, **kwargs): # noqa: E501 ['*/*']) # noqa: E501 # Authentication setting - auth_settings = [] # noqa: E501 + auth_settings = ['api_key'] # noqa: E501 return self.api_client.call_api( '/workflow/search', 'GET', @@ -1739,53 +2094,50 @@ def search_with_http_info(self, **kwargs): # noqa: E501 _request_timeout=params.get('_request_timeout'), collection_formats=collection_formats) - def search_v22(self, **kwargs): # noqa: E501 - """Search for workflows based on payload and other parameters # noqa: E501 + def skip_task_from_workflow(self, workflow_id, task_reference_name, skip_task_request, **kwargs): # noqa: E501 + """Skips a given task from a current running workflow # noqa: E501 - use sort options as sort=:ASC|DESC e.g. sort=name&sort=workflowId:DESC. If order is not specified, defaults to ASC. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.search_v22(async_req=True) + >>> thread = api.skip_task_from_workflow(workflow_id, task_reference_name, skip_task_request, async_req=True) >>> result = thread.get() :param async_req bool - :param int start: - :param int size: - :param str sort: - :param str free_text: - :param str query: - :return: SearchResultWorkflow + :param str workflow_id: (required) + :param str task_reference_name: (required) + :param SkipTaskRequest skip_task_request: (required) + :return: None If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): - return self.search_v22_with_http_info(**kwargs) # noqa: E501 + return self.skip_task_from_workflow_with_http_info(workflow_id, task_reference_name, skip_task_request, + **kwargs) # noqa: E501 else: - (data) = self.search_v22_with_http_info(**kwargs) # noqa: E501 + (data) = self.skip_task_from_workflow_with_http_info(workflow_id, task_reference_name, skip_task_request, + **kwargs) # noqa: E501 return data - def search_v22_with_http_info(self, **kwargs): # noqa: E501 - """Search for workflows based on payload and other parameters # noqa: E501 + def skip_task_from_workflow_with_http_info(self, workflow_id, task_reference_name, skip_task_request, + **kwargs): # noqa: E501 + """Skips a given task from a current running workflow # noqa: E501 - use sort options as sort=:ASC|DESC e.g. sort=name&sort=workflowId:DESC. If order is not specified, defaults to ASC. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.search_v22_with_http_info(async_req=True) + >>> thread = api.skip_task_from_workflow_with_http_info(workflow_id, task_reference_name, skip_task_request, async_req=True) >>> result = thread.get() :param async_req bool - :param int start: - :param int size: - :param str sort: - :param str free_text: - :param str query: - :return: SearchResultWorkflow + :param str workflow_id: (required) + :param str task_reference_name: (required) + :param SkipTaskRequest skip_task_request: (required) + :return: None If the method is called asynchronously, returns the request thread. """ - all_params = ['start', 'size', 'sort', 'free_text', 'query'] # noqa: E501 + all_params = ['workflow_id', 'task_reference_name', 'skip_task_request'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') @@ -1796,26 +2148,37 @@ def search_v22_with_http_info(self, **kwargs): # noqa: E501 if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" - " to method search_v22" % key + " to method skip_task_from_workflow" % key ) params[key] = val del params['kwargs'] + # verify the required parameter 'workflow_id' is set + if ('workflow_id' not in params or + params['workflow_id'] is None): + raise ValueError( + "Missing the required parameter `workflow_id` when calling `skip_task_from_workflow`") # noqa: E501 + # verify the required parameter 'task_reference_name' is set + if ('task_reference_name' not in params or + params['task_reference_name'] is None): + raise ValueError( + "Missing the required parameter `task_reference_name` when calling `skip_task_from_workflow`") # noqa: E501 + # verify the required parameter 'skip_task_request' is set + if ('skip_task_request' not in params or + params['skip_task_request'] is None): + raise ValueError( + "Missing the required parameter `skip_task_request` when calling `skip_task_from_workflow`") # noqa: E501 collection_formats = {} path_params = {} + if 'workflow_id' in params: + path_params['workflowId'] = params['workflow_id'] # noqa: E501 + if 'task_reference_name' in params: + path_params['taskReferenceName'] = params['task_reference_name'] # noqa: E501 query_params = [] - if 'start' in params: - query_params.append(('start', params['start'])) # noqa: E501 - if 'size' in params: - query_params.append(('size', params['size'])) # noqa: E501 - if 'sort' in params: - query_params.append(('sort', params['sort'])) # noqa: E501 - if 'free_text' in params: - query_params.append(('freeText', params['free_text'])) # noqa: E501 - if 'query' in params: - query_params.append(('query', params['query'])) # noqa: E501 + if 'skip_task_request' in params: + query_params.append(('skipTaskRequest', params['skip_task_request'])) # noqa: E501 header_params = {} @@ -1823,22 +2186,18 @@ def search_v22_with_http_info(self, **kwargs): # noqa: E501 local_var_files = {} body_params = None - # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['*/*']) # noqa: E501 - # Authentication setting - auth_settings = [] # noqa: E501 + auth_settings = ['api_key'] # noqa: E501 return self.api_client.call_api( - '/workflow/search-v2', 'GET', + '/workflow/{workflowId}/skiptask/{taskReferenceName}', 'PUT', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='SearchResultWorkflow', # noqa: E501 + response_type=None, # noqa: E501 auth_settings=auth_settings, async_req=params.get('async_req'), _return_http_data_only=params.get('_return_http_data_only'), @@ -1846,53 +2205,43 @@ def search_v22_with_http_info(self, **kwargs): # noqa: E501 _request_timeout=params.get('_request_timeout'), collection_formats=collection_formats) - def search_workflows_by_tasks(self, **kwargs): # noqa: E501 - """Search for workflows based on task parameters # noqa: E501 + def start_workflow(self, body, **kwargs): # noqa: E501 + """Start a new workflow with StartWorkflowRequest, which allows task to be executed in a domain # noqa: E501 - use sort options as sort=:ASC|DESC e.g. sort=name&sort=workflowId:DESC. If order is not specified, defaults to ASC # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.search_workflows_by_tasks(async_req=True) + >>> thread = api.start_workflow(body, async_req=True) >>> result = thread.get() :param async_req bool - :param int start: - :param int size: - :param str sort: - :param str free_text: - :param str query: - :return: SearchResultWorkflowSummary + :param StartWorkflowRequest body: (required) + :return: str If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): - return self.search_workflows_by_tasks_with_http_info(**kwargs) # noqa: E501 + return self.start_workflow_with_http_info(body, **kwargs) # noqa: E501 else: - (data) = self.search_workflows_by_tasks_with_http_info(**kwargs) # noqa: E501 + (data) = self.start_workflow_with_http_info(body, **kwargs) # noqa: E501 return data - def search_workflows_by_tasks_with_http_info(self, **kwargs): # noqa: E501 - """Search for workflows based on task parameters # noqa: E501 + def start_workflow_with_http_info(self, body, **kwargs): # noqa: E501 + """Start a new workflow with StartWorkflowRequest, which allows task to be executed in a domain # noqa: E501 - use sort options as sort=:ASC|DESC e.g. sort=name&sort=workflowId:DESC. If order is not specified, defaults to ASC # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.search_workflows_by_tasks_with_http_info(async_req=True) + >>> thread = api.start_workflow_with_http_info(body, async_req=True) >>> result = thread.get() :param async_req bool - :param int start: - :param int size: - :param str sort: - :param str free_text: - :param str query: - :return: SearchResultWorkflowSummary + :param StartWorkflowRequest body: (required) + :return: str If the method is called asynchronously, returns the request thread. """ - all_params = ['start', 'size', 'sort', 'free_text', 'query'] # noqa: E501 + all_params = ['body'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') @@ -1903,26 +2252,20 @@ def search_workflows_by_tasks_with_http_info(self, **kwargs): # noqa: E501 if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" - " to method search_workflows_by_tasks" % key + " to method start_workflow" % key ) params[key] = val del params['kwargs'] + # verify the required parameter 'body' is set + if ('body' not in params or + params['body'] is None): + raise ValueError("Missing the required parameter `body` when calling `start_workflow`") # noqa: E501 collection_formats = {} path_params = {} query_params = [] - if 'start' in params: - query_params.append(('start', params['start'])) # noqa: E501 - if 'size' in params: - query_params.append(('size', params['size'])) # noqa: E501 - if 'sort' in params: - query_params.append(('sort', params['sort'])) # noqa: E501 - if 'free_text' in params: - query_params.append(('freeText', params['free_text'])) # noqa: E501 - if 'query' in params: - query_params.append(('query', params['query'])) # noqa: E501 header_params = {} @@ -1930,22 +2273,28 @@ def search_workflows_by_tasks_with_http_info(self, **kwargs): # noqa: E501 local_var_files = {} body_params = None + if 'body' in params: + body_params = params['body'] # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept( - ['*/*']) # noqa: E501 + ['text/plain']) # noqa: E501 + + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 + ['application/json']) # noqa: E501 # Authentication setting - auth_settings = [] # noqa: E501 + auth_settings = ['api_key'] # noqa: E501 return self.api_client.call_api( - '/workflow/search-by-tasks', 'GET', + '/workflow', 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='SearchResultWorkflowSummary', # noqa: E501 + response_type='str', # noqa: E501 auth_settings=auth_settings, async_req=params.get('async_req'), _return_http_data_only=params.get('_return_http_data_only'), @@ -1953,53 +2302,51 @@ def search_workflows_by_tasks_with_http_info(self, **kwargs): # noqa: E501 _request_timeout=params.get('_request_timeout'), collection_formats=collection_formats) - def search_workflows_by_tasks_v2(self, **kwargs): # noqa: E501 - """Search for workflows based on task parameters # noqa: E501 + def start_workflow1(self, body, name, **kwargs): # noqa: E501 + """Start a new workflow. Returns the ID of the workflow instance that can be later used for tracking # noqa: E501 - use sort options as sort=:ASC|DESC e.g. sort=name&sort=workflowId:DESC. If order is not specified, defaults to ASC # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.search_workflows_by_tasks_v2(async_req=True) + >>> thread = api.start_workflow1(body, name, async_req=True) >>> result = thread.get() :param async_req bool - :param int start: - :param int size: - :param str sort: - :param str free_text: - :param str query: - :return: SearchResultWorkflow + :param dict(str, object) body: (required) + :param str name: (required) + :param int version: + :param str correlation_id: + :param int priority: + :return: str If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): - return self.search_workflows_by_tasks_v2_with_http_info(**kwargs) # noqa: E501 + return self.start_workflow1_with_http_info(body, name, **kwargs) # noqa: E501 else: - (data) = self.search_workflows_by_tasks_v2_with_http_info(**kwargs) # noqa: E501 + (data) = self.start_workflow1_with_http_info(body, name, **kwargs) # noqa: E501 return data - def search_workflows_by_tasks_v2_with_http_info(self, **kwargs): # noqa: E501 - """Search for workflows based on task parameters # noqa: E501 + def start_workflow1_with_http_info(self, body, name, **kwargs): # noqa: E501 + """Start a new workflow. Returns the ID of the workflow instance that can be later used for tracking # noqa: E501 - use sort options as sort=:ASC|DESC e.g. sort=name&sort=workflowId:DESC. If order is not specified, defaults to ASC # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.search_workflows_by_tasks_v2_with_http_info(async_req=True) + >>> thread = api.start_workflow1_with_http_info(body, name, async_req=True) >>> result = thread.get() :param async_req bool - :param int start: - :param int size: - :param str sort: - :param str free_text: - :param str query: - :return: SearchResultWorkflow + :param dict(str, object) body: (required) + :param str name: (required) + :param int version: + :param str correlation_id: + :param int priority: + :return: str If the method is called asynchronously, returns the request thread. """ - all_params = ['start', 'size', 'sort', 'free_text', 'query'] # noqa: E501 + all_params = ['body', 'name', 'version', 'correlation_id', 'priority'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') @@ -2010,26 +2357,32 @@ def search_workflows_by_tasks_v2_with_http_info(self, **kwargs): # noqa: E501 if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" - " to method search_workflows_by_tasks_v2" % key + " to method start_workflow1" % key ) params[key] = val del params['kwargs'] + # verify the required parameter 'body' is set + if ('body' not in params or + params['body'] is None): + raise ValueError("Missing the required parameter `body` when calling `start_workflow1`") # noqa: E501 + # verify the required parameter 'name' is set + if ('name' not in params or + params['name'] is None): + raise ValueError("Missing the required parameter `name` when calling `start_workflow1`") # noqa: E501 collection_formats = {} path_params = {} + if 'name' in params: + path_params['name'] = params['name'] # noqa: E501 query_params = [] - if 'start' in params: - query_params.append(('start', params['start'])) # noqa: E501 - if 'size' in params: - query_params.append(('size', params['size'])) # noqa: E501 - if 'sort' in params: - query_params.append(('sort', params['sort'])) # noqa: E501 - if 'free_text' in params: - query_params.append(('freeText', params['free_text'])) # noqa: E501 - if 'query' in params: - query_params.append(('query', params['query'])) # noqa: E501 + if 'version' in params: + query_params.append(('version', params['version'])) # noqa: E501 + if 'correlation_id' in params: + query_params.append(('correlationId', params['correlation_id'])) # noqa: E501 + if 'priority' in params: + query_params.append(('priority', params['priority'])) # noqa: E501 header_params = {} @@ -2037,22 +2390,28 @@ def search_workflows_by_tasks_v2_with_http_info(self, **kwargs): # noqa: E501 local_var_files = {} body_params = None + if 'body' in params: + body_params = params['body'] # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept( - ['*/*']) # noqa: E501 + ['text/plain']) # noqa: E501 + + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 + ['application/json']) # noqa: E501 # Authentication setting - auth_settings = [] # noqa: E501 + auth_settings = ['api_key'] # noqa: E501 return self.api_client.call_api( - '/workflow/search-by-tasks-v2', 'GET', + '/workflow/{name}', 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='SearchResultWorkflow', # noqa: E501 + response_type='str', # noqa: E501 auth_settings=auth_settings, async_req=params.get('async_req'), _return_http_data_only=params.get('_return_http_data_only'), @@ -2060,47 +2419,47 @@ def search_workflows_by_tasks_v2_with_http_info(self, **kwargs): # noqa: E501 _request_timeout=params.get('_request_timeout'), collection_formats=collection_formats) - def skip_task_from_workflow(self, workflow_id, task_reference_name, **kwargs): # noqa: E501 - """Skips a given task from a current running workflow # noqa: E501 + def terminate1(self, workflow_id, **kwargs): # noqa: E501 + """Terminate workflow execution # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.skip_task_from_workflow(workflow_id, task_reference_name, async_req=True) + >>> thread = api.terminate1(workflow_id, async_req=True) >>> result = thread.get() :param async_req bool :param str workflow_id: (required) - :param str task_reference_name: (required) - :param SkipTaskRequest body: + :param str reason: + :param bool trigger_failure_workflow: :return: None If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): - return self.skip_task_from_workflow_with_http_info(workflow_id, task_reference_name, **kwargs) # noqa: E501 + return self.terminate1_with_http_info(workflow_id, **kwargs) # noqa: E501 else: - (data) = self.skip_task_from_workflow_with_http_info(workflow_id, task_reference_name, **kwargs) # noqa: E501 + (data) = self.terminate1_with_http_info(workflow_id, **kwargs) # noqa: E501 return data - def skip_task_from_workflow_with_http_info(self, workflow_id, task_reference_name, **kwargs): # noqa: E501 - """Skips a given task from a current running workflow # noqa: E501 + def terminate1_with_http_info(self, workflow_id, **kwargs): # noqa: E501 + """Terminate workflow execution # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.skip_task_from_workflow_with_http_info(workflow_id, task_reference_name, async_req=True) + >>> thread = api.terminate1_with_http_info(workflow_id, async_req=True) >>> result = thread.get() :param async_req bool :param str workflow_id: (required) - :param str task_reference_name: (required) - :param SkipTaskRequest body: + :param str reason: + :param bool trigger_failure_workflow: :return: None If the method is called asynchronously, returns the request thread. """ - all_params = ['workflow_id', 'task_reference_name', 'body'] # noqa: E501 + all_params = ['workflow_id', 'reason', 'trigger_failure_workflow'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') @@ -2111,28 +2470,26 @@ def skip_task_from_workflow_with_http_info(self, workflow_id, task_reference_nam if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" - " to method skip_task_from_workflow" % key + " to method terminate1" % key ) params[key] = val del params['kwargs'] # verify the required parameter 'workflow_id' is set if ('workflow_id' not in params or params['workflow_id'] is None): - raise ValueError("Missing the required parameter `workflow_id` when calling `skip_task_from_workflow`") # noqa: E501 - # verify the required parameter 'task_reference_name' is set - if ('task_reference_name' not in params or - params['task_reference_name'] is None): - raise ValueError("Missing the required parameter `task_reference_name` when calling `skip_task_from_workflow`") # noqa: E501 + raise ValueError("Missing the required parameter `workflow_id` when calling `terminate1`") # noqa: E501 collection_formats = {} path_params = {} if 'workflow_id' in params: path_params['workflowId'] = params['workflow_id'] # noqa: E501 - if 'task_reference_name' in params: - path_params['taskReferenceName'] = params['task_reference_name'] # noqa: E501 query_params = [] + if 'reason' in params: + query_params.append(('reason', params['reason'])) # noqa: E501 + if 'trigger_failure_workflow' in params: + query_params.append(('triggerFailureWorkflow', params['trigger_failure_workflow'])) # noqa: E501 header_params = {} @@ -2140,17 +2497,11 @@ def skip_task_from_workflow_with_http_info(self, workflow_id, task_reference_nam local_var_files = {} body_params = None - if 'body' in params: - body_params = params['body'] - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 - # Authentication setting - auth_settings = [] # noqa: E501 + auth_settings = ['api_key'] # noqa: E501 return self.api_client.call_api( - '/workflow/{workflowId}/skiptask/{taskReferenceName}', 'PUT', + '/workflow/{workflowId}', 'DELETE', path_params, query_params, header_params, @@ -2165,38 +2516,38 @@ def skip_task_from_workflow_with_http_info(self, workflow_id, task_reference_nam _request_timeout=params.get('_request_timeout'), collection_formats=collection_formats) - def start_workflow(self, body, **kwargs): # noqa: E501 - """Start a new workflow with StartWorkflowRequest, which allows task to be executed in a domain # noqa: E501 + def test_workflow(self, body, **kwargs): # noqa: E501 + """Test workflow execution using mock data # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.start_workflow(body, async_req=True) + >>> thread = api.test_workflow(body, async_req=True) >>> result = thread.get() :param async_req bool - :param StartWorkflowRequest body: (required) - :return: str + :param WorkflowTestRequest body: (required) + :return: Workflow If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): - return self.start_workflow_with_http_info(body, **kwargs) # noqa: E501 + return self.test_workflow_with_http_info(body, **kwargs) # noqa: E501 else: - (data) = self.start_workflow_with_http_info(body, **kwargs) # noqa: E501 + (data) = self.test_workflow_with_http_info(body, **kwargs) # noqa: E501 return data - def start_workflow_with_http_info(self, body, **kwargs): # noqa: E501 - """Start a new workflow with StartWorkflowRequest, which allows task to be executed in a domain # noqa: E501 + def test_workflow_with_http_info(self, body, **kwargs): # noqa: E501 + """Test workflow execution using mock data # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.start_workflow_with_http_info(body, async_req=True) + >>> thread = api.test_workflow_with_http_info(body, async_req=True) >>> result = thread.get() :param async_req bool - :param StartWorkflowRequest body: (required) - :return: str + :param WorkflowTestRequest body: (required) + :return: Workflow If the method is called asynchronously, returns the request thread. """ @@ -2212,14 +2563,14 @@ def start_workflow_with_http_info(self, body, **kwargs): # noqa: E501 if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" - " to method start_workflow" % key + " to method test_workflow" % key ) params[key] = val del params['kwargs'] # verify the required parameter 'body' is set if ('body' not in params or params['body'] is None): - raise ValueError("Missing the required parameter `body` when calling `start_workflow`") # noqa: E501 + raise ValueError("Missing the required parameter `body` when calling `test_workflow`") # noqa: E501 collection_formats = {} @@ -2237,24 +2588,24 @@ def start_workflow_with_http_info(self, body, **kwargs): # noqa: E501 body_params = params['body'] # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept( - ['text/plain']) # noqa: E501 + ['application/json']) # noqa: E501 # HTTP header `Content-Type` header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 ['application/json']) # noqa: E501 # Authentication setting - auth_settings = [] # noqa: E501 + auth_settings = ['api_key'] # noqa: E501 return self.api_client.call_api( - '/workflow', 'POST', + '/workflow/test', 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='str', # noqa: E501 + response_type='Workflow', # noqa: E501 auth_settings=auth_settings, async_req=params.get('async_req'), _return_http_data_only=params.get('_return_http_data_only'), @@ -2262,51 +2613,47 @@ def start_workflow_with_http_info(self, body, **kwargs): # noqa: E501 _request_timeout=params.get('_request_timeout'), collection_formats=collection_formats) - def start_workflow1(self, body, name, **kwargs): # noqa: E501 - """Start a new workflow. Returns the ID of the workflow instance that can be later used for tracking # noqa: E501 + def update_workflow_state(self, body, workflow_id, **kwargs): # noqa: E501 + """Update workflow variables # noqa: E501 + Updates the workflow variables and triggers evaluation. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.start_workflow1(body, name, async_req=True) + >>> thread = api.update_workflow_state(body, workflow_id, async_req=True) >>> result = thread.get() :param async_req bool :param dict(str, object) body: (required) - :param str name: (required) - :param int version: - :param str correlation_id: - :param int priority: - :return: str + :param str workflow_id: (required) + :return: Workflow If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): - return self.start_workflow1_with_http_info(body, name, **kwargs) # noqa: E501 + return self.update_workflow_state_with_http_info(body, workflow_id, **kwargs) # noqa: E501 else: - (data) = self.start_workflow1_with_http_info(body, name, **kwargs) # noqa: E501 + (data) = self.update_workflow_state_with_http_info(body, workflow_id, **kwargs) # noqa: E501 return data - def start_workflow1_with_http_info(self, body, name, **kwargs): # noqa: E501 - """Start a new workflow. Returns the ID of the workflow instance that can be later used for tracking # noqa: E501 + def update_workflow_state_with_http_info(self, body, workflow_id, **kwargs): # noqa: E501 + """Update workflow variables # noqa: E501 + Updates the workflow variables and triggers evaluation. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.start_workflow1_with_http_info(body, name, async_req=True) + >>> thread = api.update_workflow_state_with_http_info(body, workflow_id, async_req=True) >>> result = thread.get() :param async_req bool :param dict(str, object) body: (required) - :param str name: (required) - :param int version: - :param str correlation_id: - :param int priority: - :return: str + :param str workflow_id: (required) + :return: Workflow If the method is called asynchronously, returns the request thread. """ - all_params = ['body', 'name', 'version', 'correlation_id', 'priority'] # noqa: E501 + all_params = ['body', 'workflow_id'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') @@ -2317,32 +2664,27 @@ def start_workflow1_with_http_info(self, body, name, **kwargs): # noqa: E501 if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" - " to method start_workflow1" % key + " to method update_workflow_state" % key ) params[key] = val del params['kwargs'] # verify the required parameter 'body' is set if ('body' not in params or params['body'] is None): - raise ValueError("Missing the required parameter `body` when calling `start_workflow1`") # noqa: E501 - # verify the required parameter 'name' is set - if ('name' not in params or - params['name'] is None): - raise ValueError("Missing the required parameter `name` when calling `start_workflow1`") # noqa: E501 + raise ValueError("Missing the required parameter `body` when calling `update_workflow_state`") # noqa: E501 + # verify the required parameter 'workflow_id' is set + if ('workflow_id' not in params or + params['workflow_id'] is None): + raise ValueError( + "Missing the required parameter `workflow_id` when calling `update_workflow_state`") # noqa: E501 collection_formats = {} path_params = {} - if 'name' in params: - path_params['name'] = params['name'] # noqa: E501 + if 'workflow_id' in params: + path_params['workflowId'] = params['workflow_id'] # noqa: E501 query_params = [] - if 'version' in params: - query_params.append(('version', params['version'])) # noqa: E501 - if 'correlation_id' in params: - query_params.append(('correlationId', params['correlation_id'])) # noqa: E501 - if 'priority' in params: - query_params.append(('priority', params['priority'])) # noqa: E501 header_params = {} @@ -2354,24 +2696,24 @@ def start_workflow1_with_http_info(self, body, name, **kwargs): # noqa: E501 body_params = params['body'] # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept( - ['text/plain']) # noqa: E501 + ['*/*']) # noqa: E501 # HTTP header `Content-Type` header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 ['application/json']) # noqa: E501 # Authentication setting - auth_settings = [] # noqa: E501 + auth_settings = ['api_key'] # noqa: E501 return self.api_client.call_api( - '/workflow/{name}', 'POST', + '/workflow/{workflowId}/variables', 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='str', # noqa: E501 + response_type='Workflow', # noqa: E501 auth_settings=auth_settings, async_req=params.get('async_req'), _return_http_data_only=params.get('_return_http_data_only'), @@ -2379,47 +2721,47 @@ def start_workflow1_with_http_info(self, body, name, **kwargs): # noqa: E501 _request_timeout=params.get('_request_timeout'), collection_formats=collection_formats) - def terminate1(self, workflow_id, **kwargs): # noqa: E501 - """Terminate workflow execution # noqa: E501 + def upgrade_running_workflow_to_version(self, body, workflow_id, **kwargs): # noqa: E501 + """Upgrade running workflow to newer version # noqa: E501 + Upgrade running workflow to newer version # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.terminate1(workflow_id, async_req=True) + >>> thread = api.upgrade_running_workflow_to_version(body, workflow_id, async_req=True) >>> result = thread.get() :param async_req bool + :param UpgradeWorkflowRequest body: (required) :param str workflow_id: (required) - :param str reason: - :param bool trigger_failure_workflow: :return: None If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): - return self.terminate1_with_http_info(workflow_id, **kwargs) # noqa: E501 + return self.upgrade_running_workflow_to_version_with_http_info(body, workflow_id, **kwargs) # noqa: E501 else: - (data) = self.terminate1_with_http_info(workflow_id, **kwargs) # noqa: E501 + (data) = self.upgrade_running_workflow_to_version_with_http_info(body, workflow_id, **kwargs) # noqa: E501 return data - def terminate1_with_http_info(self, workflow_id, **kwargs): # noqa: E501 - """Terminate workflow execution # noqa: E501 + def upgrade_running_workflow_to_version_with_http_info(self, body, workflow_id, **kwargs): # noqa: E501 + """Upgrade running workflow to newer version # noqa: E501 + Upgrade running workflow to newer version # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.terminate1_with_http_info(workflow_id, async_req=True) + >>> thread = api.upgrade_running_workflow_to_version_with_http_info(body, workflow_id, async_req=True) >>> result = thread.get() :param async_req bool + :param UpgradeWorkflowRequest body: (required) :param str workflow_id: (required) - :param str reason: - :param bool trigger_failure_workflow: :return: None If the method is called asynchronously, returns the request thread. """ - all_params = ['workflow_id', 'reason', 'triggerFailureWorkflow'] # noqa: E501 + all_params = ['body', 'workflow_id'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') @@ -2430,14 +2772,20 @@ def terminate1_with_http_info(self, workflow_id, **kwargs): # noqa: E501 if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" - " to method terminate1" % key + " to method upgrade_running_workflow_to_version" % key ) params[key] = val del params['kwargs'] + # verify the required parameter 'body' is set + if ('body' not in params or + params['body'] is None): + raise ValueError( + "Missing the required parameter `body` when calling `upgrade_running_workflow_to_version`") # noqa: E501 # verify the required parameter 'workflow_id' is set if ('workflow_id' not in params or params['workflow_id'] is None): - raise ValueError("Missing the required parameter `workflow_id` when calling `terminate1`") # noqa: E501 + raise ValueError( + "Missing the required parameter `workflow_id` when calling `upgrade_running_workflow_to_version`") # noqa: E501 collection_formats = {} @@ -2445,99 +2793,6 @@ def terminate1_with_http_info(self, workflow_id, **kwargs): # noqa: E501 if 'workflow_id' in params: path_params['workflowId'] = params['workflow_id'] # noqa: E501 - query_params = [] - if 'reason' in params: - query_params.append(('reason', params['reason'])) # noqa: E501 - - if 'triggerFailureWorkflow' in params: - query_params.append(('triggerFailureWorkflow', params['triggerFailureWorkflow'])) # noqa: E501 - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - # Authentication setting - auth_settings = [] # noqa: E501 - - return self.api_client.call_api( - '/workflow/{workflowId}', 'DELETE', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type=None, # noqa: E501 - auth_settings=auth_settings, - async_req=params.get('async_req'), - _return_http_data_only=params.get('_return_http_data_only'), - _preload_content=params.get('_preload_content', True), - _request_timeout=params.get('_request_timeout'), - collection_formats=collection_formats) - - - def test_workflow(self, body, **kwargs): # noqa: E501 - """Test workflow execution using mock data # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.test_workflow(body, async_req=True) - >>> result = thread.get() - - :param async_req bool - :param WorkflowTestRequest body: (required) - :return: Workflow - If the method is called asynchronously, - returns the request thread. - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.test_workflow_with_http_info(body, **kwargs) # noqa: E501 - else: - (data) = self.test_workflow_with_http_info(body, **kwargs) # noqa: E501 - return data - - def test_workflow_with_http_info(self, body, **kwargs): # noqa: E501 - """Test workflow execution using mock data # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.test_workflow_with_http_info(body, async_req=True) - >>> result = thread.get() - - :param async_req bool - :param WorkflowTestRequest body: (required) - :return: Workflow - If the method is called asynchronously, - returns the request thread. - """ - - all_params = ['body'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - params = locals() - for key, val in six.iteritems(params['kwargs']): - if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method test_workflow" % key - ) - params[key] = val - del params['kwargs'] - # verify the required parameter 'body' is set - if ('body' not in params or - params['body'] is None): - raise ValueError("Missing the required parameter `body` when calling `test_workflow`") # noqa: E501 - - collection_formats = {} - - path_params = {} - query_params = [] header_params = {} @@ -2548,10 +2803,6 @@ def test_workflow_with_http_info(self, body, **kwargs): # noqa: E501 body_params = None if 'body' in params: body_params = params['body'] - # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 - # HTTP header `Content-Type` header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 ['application/json']) # noqa: E501 @@ -2560,14 +2811,14 @@ def test_workflow_with_http_info(self, body, **kwargs): # noqa: E501 auth_settings = ['api_key'] # noqa: E501 return self.api_client.call_api( - '/workflow/test', 'POST', + '/workflow/{workflowId}/upgrade', 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='Workflow', # noqa: E501 + response_type=None, # noqa: E501 auth_settings=auth_settings, async_req=params.get('async_req'), _return_http_data_only=params.get('_return_http_data_only'), diff --git a/src/conductor/client/http/models/prompt_test_request.py b/src/conductor/client/http/models/prompt_test_request.py new file mode 100644 index 00000000..b06ffa13 --- /dev/null +++ b/src/conductor/client/http/models/prompt_test_request.py @@ -0,0 +1,256 @@ +import pprint +import re # noqa: F401 + +import six + + +class PromptTemplateTestRequest(object): + """NOTE: This class is auto generated by the swagger code generator program. + + Do not edit the class manually. + """ + """ + Attributes: + swagger_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + swagger_types = { + 'llm_provider': 'str', + 'model': 'str', + 'prompt': 'str', + 'prompt_variables': 'dict(str, object)', + 'stop_words': 'list[str]', + 'temperature': 'float', + 'top_p': 'float' + } + + attribute_map = { + 'llm_provider': 'llmProvider', + 'model': 'model', + 'prompt': 'prompt', + 'prompt_variables': 'promptVariables', + 'stop_words': 'stopWords', + 'temperature': 'temperature', + 'top_p': 'topP' + } + + def __init__(self, llm_provider=None, model=None, prompt=None, prompt_variables=None, stop_words=None, + temperature=None, top_p=None): # noqa: E501 + """PromptTemplateTestRequest - a model defined in Swagger""" # noqa: E501 + self._llm_provider = None + self._model = None + self._prompt = None + self._prompt_variables = None + self._stop_words = None + self._temperature = None + self._top_p = None + self.discriminator = None + if llm_provider is not None: + self.llm_provider = llm_provider + if model is not None: + self.model = model + if prompt is not None: + self.prompt = prompt + if prompt_variables is not None: + self.prompt_variables = prompt_variables + if stop_words is not None: + self.stop_words = stop_words + if temperature is not None: + self.temperature = temperature + if top_p is not None: + self.top_p = top_p + + @property + def llm_provider(self): + """Gets the llm_provider of this PromptTemplateTestRequest. # noqa: E501 + + + :return: The llm_provider of this PromptTemplateTestRequest. # noqa: E501 + :rtype: str + """ + return self._llm_provider + + @llm_provider.setter + def llm_provider(self, llm_provider): + """Sets the llm_provider of this PromptTemplateTestRequest. + + + :param llm_provider: The llm_provider of this PromptTemplateTestRequest. # noqa: E501 + :type: str + """ + + self._llm_provider = llm_provider + + @property + def model(self): + """Gets the model of this PromptTemplateTestRequest. # noqa: E501 + + + :return: The model of this PromptTemplateTestRequest. # noqa: E501 + :rtype: str + """ + return self._model + + @model.setter + def model(self, model): + """Sets the model of this PromptTemplateTestRequest. + + + :param model: The model of this PromptTemplateTestRequest. # noqa: E501 + :type: str + """ + + self._model = model + + @property + def prompt(self): + """Gets the prompt of this PromptTemplateTestRequest. # noqa: E501 + + + :return: The prompt of this PromptTemplateTestRequest. # noqa: E501 + :rtype: str + """ + return self._prompt + + @prompt.setter + def prompt(self, prompt): + """Sets the prompt of this PromptTemplateTestRequest. + + + :param prompt: The prompt of this PromptTemplateTestRequest. # noqa: E501 + :type: str + """ + + self._prompt = prompt + + @property + def prompt_variables(self): + """Gets the prompt_variables of this PromptTemplateTestRequest. # noqa: E501 + + + :return: The prompt_variables of this PromptTemplateTestRequest. # noqa: E501 + :rtype: dict(str, object) + """ + return self._prompt_variables + + @prompt_variables.setter + def prompt_variables(self, prompt_variables): + """Sets the prompt_variables of this PromptTemplateTestRequest. + + + :param prompt_variables: The prompt_variables of this PromptTemplateTestRequest. # noqa: E501 + :type: dict(str, object) + """ + + self._prompt_variables = prompt_variables + + @property + def stop_words(self): + """Gets the stop_words of this PromptTemplateTestRequest. # noqa: E501 + + + :return: The stop_words of this PromptTemplateTestRequest. # noqa: E501 + :rtype: list[str] + """ + return self._stop_words + + @stop_words.setter + def stop_words(self, stop_words): + """Sets the stop_words of this PromptTemplateTestRequest. + + + :param stop_words: The stop_words of this PromptTemplateTestRequest. # noqa: E501 + :type: list[str] + """ + + self._stop_words = stop_words + + @property + def temperature(self): + """Gets the temperature of this PromptTemplateTestRequest. # noqa: E501 + + + :return: The temperature of this PromptTemplateTestRequest. # noqa: E501 + :rtype: float + """ + return self._temperature + + @temperature.setter + def temperature(self, temperature): + """Sets the temperature of this PromptTemplateTestRequest. + + + :param temperature: The temperature of this PromptTemplateTestRequest. # noqa: E501 + :type: float + """ + + self._temperature = temperature + + @property + def top_p(self): + """Gets the top_p of this PromptTemplateTestRequest. # noqa: E501 + + + :return: The top_p of this PromptTemplateTestRequest. # noqa: E501 + :rtype: float + """ + return self._top_p + + @top_p.setter + def top_p(self, top_p): + """Sets the top_p of this PromptTemplateTestRequest. + + + :param top_p: The top_p of this PromptTemplateTestRequest. # noqa: E501 + :type: float + """ + + self._top_p = top_p + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.swagger_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + if issubclass(PromptTemplateTestRequest, dict): + for key, value in self.items(): + result[key] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, PromptTemplateTestRequest): + return False + + return self.__dict__ == other.__dict__ + + def __ne__(self, other): + """Returns true if both objects are not equal""" + return not self == other diff --git a/src/conductor/client/orkes/orkes_prompt_client.py b/src/conductor/client/orkes/orkes_prompt_client.py index 281dcdde..75df1161 100644 --- a/src/conductor/client/orkes/orkes_prompt_client.py +++ b/src/conductor/client/orkes/orkes_prompt_client.py @@ -11,6 +11,7 @@ from conductor.client.exceptions.api_exception_handler import api_exception_handler, for_all_methods from conductor.client.http.api_client import ApiClient from conductor.client.http.models.prompt_template import PromptTemplate +from conductor.client.http.models.prompt_test_request import PromptTemplateTestRequest from conductor.client.orkes.models.metadata_tag import MetadataTag from conductor.client.orkes.orkes_base_client import OrkesBaseClient from conductor.client.prompt_client import PromptClient @@ -42,3 +43,16 @@ def update_tag_for_prompt_template(self, prompt_name: str, tags: List[MetadataTa def delete_tag_for_prompt_template(self, prompt_name: str, tags: List[MetadataTag]): self.promptApi.delete_tag_for_prompt_template(tags, prompt_name) + + def test_prompt(self, prompt_text: str, variables: dict, ai_integration: str, text_complete_model: str, + temperature: float = 0.1, top_p: float = 0.9, stop_words: List[str] = None) -> str: + request = PromptTemplateTestRequest() + request.prompt = prompt_text + request.llm_provider = ai_integration + request.model = text_complete_model + request.prompt_variables = variables + request.temperature = temperature + request.top_p = top_p + if stop_words is not None: + request.stop_words = stop_words + return self.promptApi.test_message_template(request) \ No newline at end of file diff --git a/src/conductor/client/prompt_client.py b/src/conductor/client/prompt_client.py index 01427fc2..554019f3 100644 --- a/src/conductor/client/prompt_client.py +++ b/src/conductor/client/prompt_client.py @@ -41,3 +41,8 @@ def update_tag_for_prompt_template(self, prompt_name: str, tags: List[MetadataTa @abstractmethod def delete_tag_for_prompt_template(self, prompt_name: str, tags: List[MetadataTag]): pass + + @abstractmethod + def test_prompt(self, prompt_text: str, variables: dict, ai_integration: str, text_complete_model: str, + temperature : float = 0.1, top_p : float = 0.9, stop_words: List[str] = None) -> str: + pass \ No newline at end of file diff --git a/src/conductor/client/workflow/conductor_workflow.py b/src/conductor/client/workflow/conductor_workflow.py index 6a3c3b60..e296541c 100644 --- a/src/conductor/client/workflow/conductor_workflow.py +++ b/src/conductor/client/workflow/conductor_workflow.py @@ -163,6 +163,15 @@ def start_workflow(self, start_workflow_request: StartWorkflowRequest): start_workflow_request.workflow_def = self.to_workflow_def() return self._executor.start_workflow(start_workflow_request) + def execute(self, workflow_input: dict, wait_until_task_ref: str = '', wait_for_seconds : int = 10) -> dict: + request = StartWorkflowRequest() + request.workflow_def = self.to_workflow_def() + request.input = workflow_input + request.name = request.workflow_def.name + request.version = 1 + run = self._executor.execute_workflow(request, wait_until_task_ref=wait_until_task_ref, wait_for_seconds=wait_for_seconds) + return run.output + # Converts the workflow to the JSON serializable format def to_workflow_def(self) -> WorkflowDef: return WorkflowDef( @@ -205,7 +214,11 @@ def __rshift__(self, task: Union[TaskInterface, List[TaskInterface], List[List[T return self.__add_task(task) # Append task - def add(self, task: TaskInterface) -> Self: + def add(self, task: Union[TaskInterface, List[TaskInterface]]) -> Self: + if isinstance(task, list): + for t in task: + self.__add_task(t) + return self return self.__add_task(task) def __add_task(self, task: TaskInterface) -> Self: diff --git a/src/conductor/client/workflow/executor/workflow_executor.py b/src/conductor/client/workflow/executor/workflow_executor.py index 5d087cee..0348c614 100644 --- a/src/conductor/client/workflow/executor/workflow_executor.py +++ b/src/conductor/client/workflow/executor/workflow_executor.py @@ -42,7 +42,7 @@ def start_workflows(self, *start_workflow_request: StartWorkflowRequest) -> List ) return workflow_id_list - def execute_workflow(self, request: StartWorkflowRequest, wait_until_task_ref: str) -> WorkflowRun: + def execute_workflow(self, request: StartWorkflowRequest, wait_until_task_ref: str, wait_for_seconds : int = 10) -> WorkflowRun: """Executes a workflow with StartWorkflowRequest and waits for the completion of the workflow or until a specific task in the workflow """ return self.workflow_client.execute_workflow( @@ -51,6 +51,7 @@ def execute_workflow(self, request: StartWorkflowRequest, wait_until_task_ref: s version=request.version, name=request.name, wait_until_task_ref=wait_until_task_ref, + wait_for_seconds = wait_for_seconds, ) def remove_workflow(self, workflow_id: str, archive_workflow: bool = None) -> None: diff --git a/tests/ai_scratchpad/llm_prompt_test.py b/tests/ai_scratchpad/llm_prompt_test.py index 1c386c36..5975b29d 100644 --- a/tests/ai_scratchpad/llm_prompt_test.py +++ b/tests/ai_scratchpad/llm_prompt_test.py @@ -37,28 +37,33 @@ def get_document(task: Task) -> str: def main(): - ai_config = AIConfiguration('azure_openai', 'text-davinci-003', '', 'text-embedding-ada-002', 'pineconedb') + ai_config = AIConfiguration('my_azure_open_ai', 'text-davinci-003', '', 'text-embedding-ada-002', 'pineconedb') api_config = Configuration( authentication_settings=AuthenticationSettings(key_id='0092089d-19ff-4931-b3da-fc093029d0ad', key_secret='lzCCrpk5NLi0TYmIDiOfnJWLz5vkxMKn5BoCKIHSddOdYyg3')) ai_orchestrator = AIOrchestrator(api_configuration=api_config, ai_configuration=ai_config) prompt = Prompt(name='say_hi_to_friend', variables={'friend_name': '${get_friend_name_ref.output.result}'}) + + ai_orchestrator.add_ai_integration('my_azure_open_ai', 'azure_openai', + ['text-davinci-003', 'text-embedding-ada-002'], 'viren azure openai', + AzureOpenAIConfig('2dba20b4b1324f078ee00775c4d7733b', + 'https://openai-test-dl.openai.azure.com/')) ai_orchestrator.add_prompt_template(prompt.name, 'Hello my ${friend_name}', 'test prompt') + ai_orchestrator.associate_prompt_template(prompt.name, 'my_azure_open_ai', ['text-davinci-003']) + result = ai_orchestrator.test_prompt_template('give an evening greeting to ${friend_name}. go: ', + {'friend_name': 'viren'}, ai_config.llm_provider, + ai_config.text_complete_model) + + print(result) + + t1 = SimpleTask('get_friend_name', 'get_friend_name_ref') + t2 = LlmTextComplete('say_hi', 'say_hi_ref', ai_config.llm_provider, ai_config.text_complete_model, prompt=prompt) - ai_orchestrator.add_ai_integration('my_azure_open_ai', 'azure_openai', ['text-davinci-003', 'text-embedding-ada-002'], 'viren azure openai', - AzureOpenAIConfig('2dba20b4b1324f078ee00775c4d7733b','https://openai-test-dl.openai.azure.com/')) - - tasks = [ - SimpleTask('get_friend_name', 'get_friend_name_ref'), - LlmTextComplete('say_hi', 'say_hi_ref', ai_config.llm_provider, ai_config.text_complete_model, prompt=prompt) - ] - # workflow = ConductorWorkflow(executor=None, name='say_hi_to_the_friend') - # workflow >> tasks - # workflow.output_parameters = {'greetings': '${say_hi_ref.output.result}'} - # task_executors = {'get_friend_name_ref': get_document} - # wf_result = prompt_client.execute_workflow(workflow=workflow, wait_for_seconds=10, task_to_exec=task_executors) - # print(wf_result.output) + workflow = ConductorWorkflow(executor=ai_orchestrator.workflow_executor, name='say_hi_to_the_friend') + workflow >> [t1, t2] + workflow.output_parameters = {'greetings': '${say_hi_ref.output.result}'} + workflow.execute({}, wait_for_seconds=1) if __name__ == '__main__': From 5001e9e8feb3be15c9682836c9cb00bf6236a486 Mon Sep 17 00:00:00 2001 From: Viren Baraiya Date: Sun, 3 Dec 2023 00:14:48 -0800 Subject: [PATCH 8/9] more --- src/conductor/client/ai/orchestrator.py | 34 ++++++++++++------- src/conductor/client/integration_client.py | 4 +-- .../client/orkes/orkes_integration_client.py | 8 ++--- tests/ai_scratchpad/llm_prompt_test.py | 3 +- 4 files changed, 30 insertions(+), 19 deletions(-) diff --git a/src/conductor/client/ai/orchestrator.py b/src/conductor/client/ai/orchestrator.py index df068427..88e1f068 100644 --- a/src/conductor/client/ai/orchestrator.py +++ b/src/conductor/client/ai/orchestrator.py @@ -8,17 +8,9 @@ from conductor.client.ai.integrations import IntegrationConfig from conductor.client.configuration.configuration import Configuration -from conductor.client.http.api.prompt_resource_api import PromptResourceApi -from conductor.client.http.api.workflow_resource_api import WorkflowResourceApi -from conductor.client.http.api_client import ApiClient from conductor.client.http.models.integration_api_update import IntegrationApiUpdate from conductor.client.http.models.integration_update import IntegrationUpdate -from conductor.client.http.models.prompt_template import PromptTemplate from conductor.client.orkes_clients import OrkesClients -from conductor.client.workflow.conductor_workflow import ConductorWorkflow -from conductor.client.workflow.executor.workflow_executor import WorkflowExecutor -from conductor.client.workflow.task.llm_tasks.llm_text_complete import LlmTextComplete -from conductor.client.workflow.task.llm_tasks.utils.prompt import Prompt from conductor.client.ai.configuration import AIConfiguration @@ -52,9 +44,11 @@ def test_prompt_template(self, text: str, variables: dict, temperature: int = 0, top_p: int = 1): - return self.prompt_client.test_prompt(text, variables, ai_integration, text_complete_model, temperature, top_p, stop_words) + return self.prompt_client.test_prompt(text, variables, ai_integration, text_complete_model, temperature, top_p, + stop_words) - def add_ai_integration(self, name: str, provider: str, models: List[str], description: str, config: IntegrationConfig): + def add_ai_integration(self, name: str, provider: str, models: List[str], description: str, + config: IntegrationConfig): details = IntegrationUpdate() details.configuration = config.to_dict() details.type = provider @@ -68,8 +62,24 @@ def add_ai_integration(self, name: str, provider: str, models: List[str], descri api_details.description = description self.integration_client.save_integration_api(name, model, api_details) - - def add_vector_store(self, name: str, provider: str, indices: List[str], description: str, api_key: str, + def add_vector_store(self, name: str, provider: str, indices: List[str], description: str, config: IntegrationConfig): + vector_db = IntegrationUpdate() + vector_db.configuration = config.to_dict() + vector_db.type = provider + vector_db.category = 'VECTOR_DB' + vector_db.enabled = True + vector_db.description = description + self.integration_client.save_integration(name, vector_db) + for index in indices: + api_details = IntegrationApiUpdate() + api_details.enabled = True + api_details.description = description + self.integration_client.save_integration_api(name, index, api_details) pass + def get_token_used(self, ai_integration: str) -> dict: + return self.integration_client.get_token_usage_for_integration_provider(ai_integration) + + def get_token_used_by_model(self, ai_integration: str, model: str) -> int: + return self.integration_client.get_token_usage_for_integration(ai_integration, model) diff --git a/src/conductor/client/integration_client.py b/src/conductor/client/integration_client.py index fced5b02..ecbac872 100644 --- a/src/conductor/client/integration_client.py +++ b/src/conductor/client/integration_client.py @@ -62,10 +62,10 @@ def get_integrations(self) -> List[Integration]: def get_prompts_with_integration(self, ai_integration:str, model_name:str) -> List[PromptTemplate]: pass - def get_token_usage_for_integration(self, name, integration_name): + def get_token_usage_for_integration(self, name, integration_name) -> int: pass - def get_token_usage_for_integration_provider(self, name): + def get_token_usage_for_integration_provider(self, name) -> dict: pass def register_token_usage(self, body, name, integration_name): diff --git a/src/conductor/client/orkes/orkes_integration_client.py b/src/conductor/client/orkes/orkes_integration_client.py index d04e61d3..766abc9f 100644 --- a/src/conductor/client/orkes/orkes_integration_client.py +++ b/src/conductor/client/orkes/orkes_integration_client.py @@ -48,11 +48,11 @@ def save_integration_api(self, integration_name, api_name, api_details: Integrat def save_integration(self, integration_name, integration_details: IntegrationUpdate): self.integrationApi.save_integration_provider(integration_details, integration_name) - def get_token_usage_for_integration(self, name, integration_name): - pass + def get_token_usage_for_integration(self, name, integration_name) -> int: + return self.integrationApi.get_token_usage_for_integration(name, integration_name) - def get_token_usage_for_integration_provider(self, name): - pass + def get_token_usage_for_integration_provider(self, name) -> dict: + return self.integrationApi.get_token_usage_for_integration_provider(name) def register_token_usage(self, body, name, integration_name): pass diff --git a/tests/ai_scratchpad/llm_prompt_test.py b/tests/ai_scratchpad/llm_prompt_test.py index 5975b29d..9dd830d9 100644 --- a/tests/ai_scratchpad/llm_prompt_test.py +++ b/tests/ai_scratchpad/llm_prompt_test.py @@ -64,7 +64,8 @@ def main(): workflow >> [t1, t2] workflow.output_parameters = {'greetings': '${say_hi_ref.output.result}'} workflow.execute({}, wait_for_seconds=1) - + print('tokens used: ') + print(ai_orchestrator.get_token_used_by_model(ai_config.llm_provider, ai_config.text_complete_model)) if __name__ == '__main__': sys.exit(main()) # next section explains the use of sys.exit From 69fecb742b4d1602824329c7f41fd388eacd55fc Mon Sep 17 00:00:00 2001 From: Viren Baraiya Date: Sun, 3 Dec 2023 00:45:38 -0800 Subject: [PATCH 9/9] fixes --- docs/metadata/README.md | 2 +- .../client/http/api/workflow_resource_api.py | 4 +- src/conductor/client/metadata_client.py | 5 + .../client/orkes/orkes_metadata_client.py | 4 +- .../client/orkes/orkes_workflow_client.py | 11 +- src/conductor/client/workflow_client.py | 4 +- .../client/orkes/test_orkes_clients.py | 177 +++++++++--------- tests/integration/main.py | 26 ++- tests/notebook/test.ipynb | 48 +++-- tests/unit/orkes/test_metadata_client.py | 2 +- 10 files changed, 144 insertions(+), 139 deletions(-) diff --git a/docs/metadata/README.md b/docs/metadata/README.md index 0e4513b8..93719e23 100644 --- a/docs/metadata/README.md +++ b/docs/metadata/README.md @@ -157,7 +157,7 @@ You should be able to add a single tag to your workflow: ```python tag = MetadataTag("wftag", "val") -metadata_client.addWorkflowTag(tag, 'python_workflow_example_from_code') +metadata_client.add_workflow_tag(tag, 'python_workflow_example_from_code') ``` ### Fetch tags added to your workflow diff --git a/src/conductor/client/http/api/workflow_resource_api.py b/src/conductor/client/http/api/workflow_resource_api.py index c5d470cf..db18e29f 100644 --- a/src/conductor/client/http/api/workflow_resource_api.py +++ b/src/conductor/client/http/api/workflow_resource_api.py @@ -103,12 +103,12 @@ def decide_with_http_info(self, workflow_id, **kwargs): # noqa: E501 _request_timeout=params.get('_request_timeout'), collection_formats=collection_formats) - def delete1(self, workflow_id, **kwargs): # noqa: E501 + def delete(self, workflow_id, **kwargs): # noqa: E501 """Removes the workflow from the system # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.delete1(workflow_id, async_req=True) + >>> thread = api.delete(workflow_id, async_req=True) >>> result = thread.get() :param async_req bool diff --git a/src/conductor/client/metadata_client.py b/src/conductor/client/metadata_client.py index 5e9355a5..bbc958b6 100644 --- a/src/conductor/client/metadata_client.py +++ b/src/conductor/client/metadata_client.py @@ -2,6 +2,7 @@ from typing import Optional, List from conductor.client.http.models.workflow_def import WorkflowDef from conductor.client.http.models.task_def import TaskDef +from conductor.client.orkes.models.metadata_tag import MetadataTag class MetadataClient(ABC): @@ -50,3 +51,7 @@ def get_task_def(self, task_type: str) -> TaskDef: @abstractmethod def get_all_task_defs(self) -> List[TaskDef]: pass + + @abstractmethod + def add_workflow_tag(self, tag: MetadataTag, workflow_name: str): + pass diff --git a/src/conductor/client/orkes/orkes_metadata_client.py b/src/conductor/client/orkes/orkes_metadata_client.py index 89a9cbfa..49f26d17 100644 --- a/src/conductor/client/orkes/orkes_metadata_client.py +++ b/src/conductor/client/orkes/orkes_metadata_client.py @@ -50,8 +50,8 @@ def get_task_def(self, task_type: str) -> TaskDef: def get_all_task_defs(self) -> List[TaskDef]: return self.metadataResourceApi.get_task_defs() - def addWorkflowTag(self, tag: MetadataTag, workflowName: str): - self.tagsApi.add_workflow_tag(tag, workflowName) + def add_workflow_tag(self, tag: MetadataTag, workflow_name: str): + self.tagsApi.add_workflow_tag(tag, workflow_name) def deleteWorkflowTag(self, tag: MetadataTag, workflowName: str): tagStr = TagString(tag.key, tag.type, tag.value) diff --git a/src/conductor/client/orkes/orkes_workflow_client.py b/src/conductor/client/orkes/orkes_workflow_client.py index 7ea93065..175a8fbe 100644 --- a/src/conductor/client/orkes/orkes_workflow_client.py +++ b/src/conductor/client/orkes/orkes_workflow_client.py @@ -1,5 +1,6 @@ from typing import Optional, List from conductor.client.configuration.configuration import Configuration +from conductor.client.http.models import SkipTaskRequest from conductor.client.http.models.workflow import Workflow from conductor.client.http.models.workflow_run import WorkflowRun from conductor.client.http.models.start_workflow_request import StartWorkflowRequest @@ -51,13 +52,13 @@ def execute_workflow( return self.workflowResourceApi.execute_workflow(start_workflow_request, request_id, name, version, **kwargs) def pause_workflow(self, workflow_id: str): - self.workflowResourceApi.pause_workflow1(workflow_id) + self.workflowResourceApi.pause_workflow(workflow_id) def resume_workflow(self, workflow_id: str): - self.workflowResourceApi.resume_workflow1(workflow_id) + self.workflowResourceApi.resume_workflow(workflow_id) def restart_workflow(self, workflow_id: str, use_latest_def: Optional[bool] = False): - self.workflowResourceApi.restart1(workflow_id, use_latest_definitions=use_latest_def) + self.workflowResourceApi.restart(workflow_id, use_latest_definitions=use_latest_def) def rerun_workflow(self, workflow_id: str, rerun_workflow_request: RerunWorkflowRequest): self.workflowResourceApi.rerun(rerun_workflow_request, workflow_id) @@ -75,8 +76,8 @@ def get_workflow(self, workflow_id: str, include_tasks: Optional[bool] = True) - def delete_workflow(self, workflow_id: str, archive_workflow: Optional[bool] = True): self.workflowResourceApi.delete(workflow_id, archive_workflow=archive_workflow) - def skip_task_from_workflow(self, workflow_id: str, task_reference_name: str): - self.workflowResourceApi.skip_task_from_workflow(workflow_id, task_reference_name) + def skip_task_from_workflow(self, workflow_id: str, task_reference_name: str, request: SkipTaskRequest): + self.workflowResourceApi.skip_task_from_workflow(workflow_id, task_reference_name, request) def test_workflow(self, test_request: WorkflowTestRequest) -> Workflow: return self.workflowResourceApi.test_workflow(test_request) diff --git a/src/conductor/client/workflow_client.py b/src/conductor/client/workflow_client.py index 27119e04..22ebfb13 100644 --- a/src/conductor/client/workflow_client.py +++ b/src/conductor/client/workflow_client.py @@ -1,7 +1,7 @@ from abc import ABC, abstractmethod from typing import Optional, List -from conductor.client.http.models import WorkflowRun +from conductor.client.http.models import WorkflowRun, SkipTaskRequest from conductor.client.http.models.workflow import Workflow from conductor.client.http.models.start_workflow_request import StartWorkflowRequest from conductor.client.http.models.rerun_workflow_request import RerunWorkflowRequest @@ -57,7 +57,7 @@ def rerun_workflow(self, workflow_id: str, rerun_workflow_request: RerunWorkflow pass @abstractmethod - def skip_task_from_workflow(self, workflow_id: str, task_reference_name: str): + def skip_task_from_workflow(self, workflow_id: str, task_reference_name: str, request: SkipTaskRequest): pass @abstractmethod diff --git a/tests/integration/client/orkes/test_orkes_clients.py b/tests/integration/client/orkes/test_orkes_clients.py index 0d6c7d01..b7daef0a 100644 --- a/tests/integration/client/orkes/test_orkes_clients.py +++ b/tests/integration/client/orkes/test_orkes_clients.py @@ -2,6 +2,7 @@ from shortuuid import uuid from conductor.client.configuration.configuration import Configuration from conductor.client.http.api_client import ApiClient +from conductor.client.http.models import SkipTaskRequest from conductor.client.orkes_clients import OrkesClients from conductor.client.workflow.conductor_workflow import ConductorWorkflow from conductor.client.workflow.executor.workflow_executor import WorkflowExecutor @@ -34,6 +35,7 @@ TEST_WF_JSON = 'tests/integration/resources/test_data/calculate_loan_workflow.json' TEST_IP_JSON = 'tests/integration/resources/test_data/loan_workflow_input.json' + class TestOrkesClients: def __init__(self, configuration: Configuration): self.api_client = ApiClient(configuration) @@ -58,7 +60,7 @@ def run(self) -> None: workflow.input_parameters(["a", "b"]) workflow >> SimpleTask("simple_task", "simple_task_ref") workflowDef = workflow.to_workflow_def() - + self.test_workflow_lifecycle(workflowDef, workflow) self.test_task_lifecycle() self.test_secret_lifecycle() @@ -77,7 +79,7 @@ def test_workflow_lifecycle(self, workflowDef, workflow): def test_task_lifecycle(self): taskDef = TaskDef( - name= TASK_TYPE, + name=TASK_TYPE, description="Integration Test Task", input_keys=["a", "b"] ) @@ -105,43 +107,41 @@ def test_task_lifecycle(self): assert e.code == APIErrorCode.NOT_FOUND assert e.message == "Task {0} not found".format(TASK_TYPE) - def test_secret_lifecycle(self): self.secret_client.put_secret(SECRET_NAME, "secret_value") - + assert self.secret_client.get_secret(SECRET_NAME), "secret_value" - + self.secret_client.put_secret(SECRET_NAME + "_2", "secret_value_2") - + secret_names = self.secret_client.list_all_secret_names() - + assert secret_names, [SECRET_NAME, SECRET_NAME + "_2"] - + tags = [ MetadataTag("sec_tag", "val"), MetadataTag("sec_tag_2", "val2") ] self.secret_client.set_secret_tags(tags, SECRET_NAME) fetched_tags = self.secret_client.get_secret_tags(SECRET_NAME) assert len(fetched_tags) == 2 - + self.secret_client.delete_secret_tags(tags, SECRET_NAME) fetched_tags = self.secret_client.get_secret_tags(SECRET_NAME) assert len(fetched_tags) == 0 - + assert self.secret_client.secret_exists(SECRET_NAME) - + self.secret_client.delete_secret(SECRET_NAME) - + assert self.secret_client.secret_exists(SECRET_NAME) == False - + self.secret_client.delete_secret(SECRET_NAME + "_2") - + try: self.secret_client.get_secret(SECRET_NAME + "_2") except APIError as e: assert e.code == APIErrorCode.NOT_FOUND - def test_scheduler_lifecycle(self, workflowDef): startWorkflowRequest = StartWorkflowRequest( name=WORKFLOW_NAME, workflow_def=workflowDef @@ -149,42 +149,42 @@ def test_scheduler_lifecycle(self, workflowDef): saveScheduleRequest = SaveScheduleRequest( name=SCHEDULE_NAME, start_workflow_request=startWorkflowRequest, - cron_expression= "0 */5 * ? * *" + cron_expression="0 */5 * ? * *" ) self.scheduler_client.save_schedule(saveScheduleRequest) schedule = self.scheduler_client.get_schedule(SCHEDULE_NAME) - + assert schedule['name'] == SCHEDULE_NAME - + self.scheduler_client.pause_schedule(SCHEDULE_NAME) - + schedules = self.scheduler_client.get_all_schedules(WORKFLOW_NAME) assert len(schedules) == 1 assert schedules[0].name == SCHEDULE_NAME assert schedules[0].paused - + self.scheduler_client.resume_schedule(SCHEDULE_NAME) schedule = self.scheduler_client.get_schedule(SCHEDULE_NAME) assert not schedule['paused'] - + times = self.scheduler_client.get_next_few_schedule_execution_times("0 */5 * ? * *", limit=1) - assert(len(times) == 1) - + assert (len(times) == 1) + tags = [ MetadataTag("sch_tag", "val"), MetadataTag("sch_tag_2", "val2") ] self.scheduler_client.set_scheduler_tags(tags, SCHEDULE_NAME) fetched_tags = self.scheduler_client.get_scheduler_tags(SCHEDULE_NAME) assert len(fetched_tags) == 2 - + self.scheduler_client.delete_scheduler_tags(tags, SCHEDULE_NAME) fetched_tags = self.scheduler_client.get_scheduler_tags(SCHEDULE_NAME) assert len(fetched_tags) == 0 - + self.scheduler_client.delete_schedule(SCHEDULE_NAME) - + try: schedule = self.scheduler_client.get_schedule(SCHEDULE_NAME) except APIError as e: @@ -195,7 +195,7 @@ def test_application_lifecycle(self): req = CreateOrUpdateApplicationRequest(APPLICATION_NAME) created_app = self.authorization_client.create_application(req) assert created_app.name == APPLICATION_NAME - + application = self.authorization_client.get_application(created_app.id) assert application.id == created_app.id @@ -205,7 +205,7 @@ def test_application_lifecycle(self): req.name = APPLICATION_NAME + "_updated" app_updated = self.authorization_client.update_application(req, created_app.id) assert app_updated.name == req.name - + self.authorization_client.add_role_to_application_user(created_app.id, "USER") app_user_id = "app:" + created_app.id app_user = self.authorization_client.get_user(app_user_id) @@ -214,7 +214,7 @@ def test_application_lifecycle(self): self.authorization_client.remove_role_from_application_user(created_app.id, "USER") app_user = self.authorization_client.get_user(app_user_id) assert True not in [r.name == "USER" for r in app_user.roles] - + tags = [MetadataTag("auth_tag", "val"), MetadataTag("auth_tag_2", "val2")] self.authorization_client.set_application_tags(tags, created_app.id) fetched_tags = self.authorization_client.get_application_tags(created_app.id) @@ -226,14 +226,14 @@ def test_application_lifecycle(self): created_access_key = self.authorization_client.create_access_key(created_app.id) access_keys = self.authorization_client.get_access_keys(created_app.id) - assert(access_keys[0].id == created_access_key.id) - assert(access_keys[0].status == AccessKeyStatus.ACTIVE) + assert (access_keys[0].id == created_access_key.id) + assert (access_keys[0].status == AccessKeyStatus.ACTIVE) access_key = self.authorization_client.toggle_access_key_status(created_app.id, created_access_key.id) assert access_key.status == AccessKeyStatus.INACTIVE - + self.authorization_client.delete_access_key(created_app.id, created_access_key.id) - + self.authorization_client.delete_application(created_app.id) try: application = self.authorization_client.get_application(created_app.id) @@ -249,86 +249,85 @@ def test_user_group_permissions_lifecycle(self, workflowDef): user = self.authorization_client.get_user(USER_ID) assert user.id == USER_ID assert user.name == req.name - + users = self.authorization_client.list_users() assert [user.id == USER_ID for u in users] - + req.name = "Integration " + "Updated" updated_user = self.authorization_client.upsert_user(req, USER_ID) assert updated_user.name == req.name - + # Test Groups req = UpsertGroupRequest("Integration Test Group", ["USER"]) created_group = self.authorization_client.upsert_group(req, GROUP_ID) assert created_group.id == GROUP_ID - + group = self.authorization_client.get_group(GROUP_ID) assert group.id == GROUP_ID - + groups = self.authorization_client.list_groups() assert True in [group.id == GROUP_ID for group in groups] - + self.authorization_client.add_user_to_group(GROUP_ID, USER_ID) users = self.authorization_client.get_users_in_group(GROUP_ID) assert users[0].id == USER_ID - + # Test Granting Permissions workflowDef.name = WORKFLOW_NAME + "_permissions" self.__create_workflow_definition(workflowDef) - + target = TargetRef(TargetType.WORKFLOW_DEF, WORKFLOW_NAME + "_permissions") subject_group = SubjectRef(SubjectType.GROUP, GROUP_ID) access_group = [AccessType.EXECUTE] - + subject_user = SubjectRef(SubjectType.USER, USER_ID) access_user = [AccessType.EXECUTE, AccessType.READ] - + self.authorization_client.grant_permissions(subject_group, target, access_group) self.authorization_client.grant_permissions(subject_user, target, access_user) - + target_perms = self.authorization_client.get_permissions(target) assert True in [s == subject_group for s in target_perms[AccessType.EXECUTE]] assert True in [s == subject_user for s in target_perms[AccessType.EXECUTE]] assert True in [s == subject_user for s in target_perms[AccessType.READ]] - + group_perms = self.authorization_client.get_granted_permissions_for_group(GROUP_ID) assert len(group_perms) == 1 assert group_perms[0].target == target assert group_perms[0].access == access_group - + user_perms = self.authorization_client.get_granted_permissions_for_user(USER_ID) assert len(user_perms) == 1 assert user_perms[0].target == target assert sorted(user_perms[0].access) == sorted(access_user) - + self.authorization_client.remove_permissions(subject_group, target, access_group) self.authorization_client.remove_permissions(subject_user, target, access_user) target_perms = self.authorization_client.get_permissions(target) - + assert True not in [s == subject_group for s in target_perms[AccessType.EXECUTE]] assert True not in [s == subject_user for s in target_perms[AccessType.EXECUTE]] assert True not in [s == subject_user for s in target_perms[AccessType.READ]] - + self.authorization_client.remove_user_from_group(GROUP_ID, USER_ID) - + self.authorization_client.delete_user(USER_ID) try: self.authorization_client.get_user(USER_ID) except APIError as e: assert e.code == APIErrorCode.NOT_FOUND - assert e.message == "User '{0}' not found".format(USER_ID) - + assert e.message == "User '{0}' not found".format(USER_ID) + self.authorization_client.delete_group(GROUP_ID) try: self.authorization_client.get_group(GROUP_ID) except APIError as e: assert e.code == APIErrorCode.NOT_FOUND - assert e.message == "Group '{0}' not found".format(GROUP_ID) - + assert e.message == "Group '{0}' not found".format(GROUP_ID) def __test_register_workflow_definition(self, workflowDef: WorkflowDef): self.__create_workflow_definition(workflowDef) - + def __create_workflow_definition(self, workflowDef) -> str: return self.metadata_client.register_workflow_def(workflowDef, True) @@ -349,7 +348,7 @@ def __test_update_workflow_definition(self, workflow: ConductorWorkflow): def __test_unit_test_workflow(self): workflowDef = self.__get_workflow_definition(TEST_WF_JSON) assert workflowDef != None - + testTaskInputs = self.__get_test_inputs(TEST_IP_JSON) assert testTaskInputs != None @@ -359,17 +358,17 @@ def __test_unit_test_workflow(self): "userEmail": "user@example.com", "loanAmount": 11000, } - + testRequest.name = workflowDef.name testRequest.version = workflowDef.version testRequest.task_ref_to_mock_output = testTaskInputs execution = self.workflow_client.test_workflow(testRequest) assert execution != None - + # Ensure workflow is completed successfully assert execution.status == "COMPLETED" - + # Ensure the inputs were captured correctly assert execution.input["loanAmount"] == testRequest.input["loanAmount"] assert execution.input["userEmail"] == testRequest.input["userEmail"] @@ -401,13 +400,13 @@ def __test_unit_test_workflow(self): # Calculate loan amount gets the right loan amount from workflow input expectedLoanAmount = testRequest.input["loanAmount"] assert calculateLoanAmount.input_data["loanAmount"] == expectedLoanAmount - + # Calculate loan amount gets the right credit rating from the previous task assert calculateLoanAmount.input_data["creditRating"] == expectedCreditRating - + authorizedLoanAmount = 10_000 assert calculateLoanAmount.output_data["authorizedLoanAmount"] == authorizedLoanAmount - + assert not phoneNumberValidAttempt1.output_data["valid"] assert not phoneNumberValidAttempt2.output_data["valid"] assert phoneNumberValidAttempt3.output_data["valid"] @@ -416,18 +415,18 @@ def __test_unit_test_workflow(self): assert execution.output["accountNumber"] == userAccountNo assert execution.output["creditRating"] == expectedCreditRating assert execution.output["authorizedLoanAmount"] == authorizedLoanAmount - + # Workflow output takes the latest iteration output of a loopOver task. assert execution.output["phoneNumberValid"] def __test_unregister_workflow_definition(self): self.metadata_client.unregister_workflow_def(WORKFLOW_NAME, 1) - + try: self.metadata_client.get_workflow_def(WORKFLOW_NAME, 1) except APIError as e: assert e.code == APIErrorCode.NOT_FOUND - assert e.message == 'No such workflow found by name: {0}, version: 1'.format(WORKFLOW_NAME) + assert e.message == 'No such workflow found by name: {0}, version: 1'.format(WORKFLOW_NAME) def __test_task_tags(self): tags = [ @@ -447,7 +446,7 @@ def __test_task_tags(self): tagStr = MetadataTag("tag2", "val2") self.metadata_client.deleteTaskTag(tagStr, TASK_TYPE) - assert(len(self.metadata_client.getTaskTags(TASK_TYPE))) == 2 + assert (len(self.metadata_client.getTaskTags(TASK_TYPE))) == 2 def __test_workflow_tags(self): singleTag = MetadataTag("wftag", "val") @@ -469,7 +468,7 @@ def __test_workflow_tags(self): tag = MetadataTag("wftag2", "val2") self.metadata_client.deleteWorkflowTag(tag, WORKFLOW_NAME) - assert(len(self.metadata_client.getWorkflowTags(WORKFLOW_NAME))) == 2 + assert (len(self.metadata_client.getWorkflowTags(WORKFLOW_NAME))) == 2 def __test_workflow_rate_limit(self): assert self.metadata_client.getWorkflowRateLimit(WORKFLOW_NAME) == None @@ -484,7 +483,7 @@ def __test_workflow_rate_limit(self): assert self.metadata_client.getWorkflowRateLimit(WORKFLOW_NAME) == None def __test_workflow_execution_lifecycle(self): - wfInput = { "a" : 5, "b": "+", "c" : [7, 8] } + wfInput = {"a": 5, "b": "+", "c": [7, 8]} workflow_uuid = self.workflow_client.startWorkflowByName(WORKFLOW_NAME, wfInput) assert workflow_uuid is not None @@ -509,8 +508,8 @@ def __test_workflow_execution_lifecycle(self): self.workflow_client.restart_workflow(workflow_uuid) workflow = self.workflow_client.get_workflow(workflow_uuid, False) assert workflow.status == "RUNNING" - - self.workflow_client.skip_task_from_workflow(workflow_uuid, "simple_task_ref_2") + + self.workflow_client.skip_task_from_workflow(workflow_uuid, "simple_task_ref_2", SkipTaskRequest()) workflow = self.workflow_client.get_workflow(workflow_uuid, False) assert workflow.status == "RUNNING" @@ -522,7 +521,7 @@ def __test_workflow_execution_lifecycle(self): assert e.message == "Workflow with Id: {} not found.".format(workflow_uuid) def __test_task_execution_lifecycle(self): - + workflow = ConductorWorkflow( executor=self.workflow_executor, name=WORKFLOW_NAME + "_task", @@ -532,44 +531,44 @@ def __test_task_execution_lifecycle(self): workflow.input_parameters(["a", "b"]) workflow >> SimpleTask(TASK_TYPE, "simple_task_ref") workflow >> SimpleTask(TASK_TYPE, "simple_task_ref_2") - + startWorkflowRequest = StartWorkflowRequest( name=WORKFLOW_NAME + "_task", version=1, workflow_def=workflow.to_workflow_def(), - input={ "a" : 15, "b": 3, "op" : "+" } + input={"a": 15, "b": 3, "op": "+"} ) - + workflow_uuid = self.workflow_client.start_workflow(startWorkflowRequest) workflow = self.workflow_client.get_workflow(workflow_uuid, False) - + workflow_uuid_2 = self.workflow_client.start_workflow(startWorkflowRequest) - + # First task of each workflow is in the queue assert self.task_client.get_queue_size_for_task(TASK_TYPE) == 2 - + polledTask = self.task_client.poll_task(TASK_TYPE) assert polledTask.status == TaskResultStatus.IN_PROGRESS - + self.task_client.add_task_log(polledTask.task_id, "Polled task...") - + taskExecLogs = self.task_client.get_task_logs(polledTask.task_id) taskExecLogs[0].log == "Polled task..." - + # First task of second workflow is in the queue assert self.task_client.get_queue_size_for_task(TASK_TYPE) == 1 - + taskResult = TaskResult( workflow_instance_id=workflow_uuid, task_id=polledTask.task_id, status=TaskResultStatus.COMPLETED ) - + self.task_client.update_task(taskResult) - + task = self.task_client.get_task(polledTask.task_id) assert task.status == TaskResultStatus.COMPLETED - + batchPolledTasks = self.task_client.batch_poll_tasks(TASK_TYPE) assert len(batchPolledTasks) == 1 @@ -581,12 +580,12 @@ def __test_task_execution_lifecycle(self): "COMPLETED", "task 2 op 2nd wf" ) - + # Update second task of first workflow self.task_client.update_task_by_ref_name( workflow_uuid_2, "simple_task_ref_2", "COMPLETED", "task 2 op 1st wf" ) - + # # Second task of second workflow is in the queue # assert self.task_client.getQueueSizeForTask(TASK_TYPE) == 1 polledTask = self.task_client.poll_task(TASK_TYPE) @@ -595,7 +594,7 @@ def __test_task_execution_lifecycle(self): self.task_client.update_task_sync( workflow_uuid, "simple_task_ref_2", "COMPLETED", "task 1 op 2nd wf" ) - + assert self.task_client.get_queue_size_for_task(TASK_TYPE) == 0 def __get_workflow_definition(self, path): @@ -603,8 +602,8 @@ def __get_workflow_definition(self, path): workflowJSON = json.loads(f.read()) workflowDef = self.api_client.deserialize_class(workflowJSON, "WorkflowDef") return workflowDef - + def __get_test_inputs(self, path): f = open(path, "r") inputJSON = json.loads(f.read()) - return inputJSON \ No newline at end of file + return inputJSON diff --git a/tests/integration/main.py b/tests/integration/main.py index f7833391..3fee493f 100644 --- a/tests/integration/main.py +++ b/tests/integration/main.py @@ -46,19 +46,25 @@ def generate_configuration(): def main(): args = sys.argv[1:] - configuration = generate_configuration() + # configuration = generate_configuration() + configuration = Configuration( + authentication_settings=AuthenticationSettings(key_id='0092089d-19ff-4931-b3da-fc093029d0ad', + key_secret='lzCCrpk5NLi0TYmIDiOfnJWLz5vkxMKn5BoCKIHSddOdYyg3')) + api_client = ApiClient(configuration) workflow_executor = WorkflowExecutor(configuration) - if len(args) == 1 and args[0] == '--orkes-clients-only': - TestOrkesClients(configuration=configuration).run() - elif len(args) == 1 and args[0] == '--workflow-execution-only': - run_workflow_execution_tests(configuration, workflow_executor) - else: - test_async.test_async_method(api_client) - run_workflow_definition_tests(workflow_executor) - run_workflow_execution_tests(configuration, workflow_executor) - TestOrkesClients(configuration=configuration).run() + run_workflow_definition_tests(workflow_executor) + + TestOrkesClients(configuration=configuration).run() + run_workflow_execution_tests(configuration, workflow_executor) + test_async.test_async_method(api_client) + + + + + + if __name__ == "__main__": main() diff --git a/tests/notebook/test.ipynb b/tests/notebook/test.ipynb index 03f995d3..72816609 100644 --- a/tests/notebook/test.ipynb +++ b/tests/notebook/test.ipynb @@ -2,47 +2,42 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, + "execution_count": 4, "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/Users/viren/workspace/github/orkes/sdk/conductor-python/venv/lib/python3.9/site-packages/urllib3/__init__.py:34: NotOpenSSLWarning: urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'LibreSSL 2.8.3'. See: https://github.com/urllib3/urllib3/issues/3020\n", - " warnings.warn(\n" - ] - }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "\n", - "Good morning, Viren! It's nice to meet you.\n" + "Good evening Viren! I hope you're having a great day.\n" ] } ], "source": [ - "from conductor.client.ai.ai_orchestrator import AIOrchestrator\n", - "from conductor.client.ai.ai_orchestrator import AIConfiguration\n", + "from conductor.client.ai.orchestrator import AIOrchestrator\n", + "from conductor.client.ai.configuration import AIConfiguration\n", "from conductor.client.configuration.configuration import Configuration\n", "from conductor.client.configuration.settings.authentication_settings import AuthenticationSettings\n", "from conductor.client.workflow.task.switch_task import SwitchTask\n", "\n", - "ai_config = AIConfiguration('azure_openai', 'text-davinci-003', 'text-embedding-ada-002', 'pineconedb')\n", + "ai_config = AIConfiguration('my_azure_open_ai', 'text-davinci-003', '', 'text-embedding-ada-002', 'pineconedb')\n", "api_config = Configuration(\n", - " authentication_settings=AuthenticationSettings(key_id='3bbcc893-66f4-4887-a419-12b8117fac62', key_secret='t6BhLZUqaKRXLEjzEtnVNnjtO5Ll2C1205SSE1rXg3WrRZ7V'))\n", + " authentication_settings=AuthenticationSettings(key_id='0092089d-19ff-4931-b3da-fc093029d0ad',\n", + " key_secret='lzCCrpk5NLi0TYmIDiOfnJWLz5vkxMKn5BoCKIHSddOdYyg3'))\n", + "\n", + "ai_orchestrator = AIOrchestrator(api_configuration=api_config, ai_configuration=ai_config)\n", "\n", - "prompt_client = AIOrchestrator(api_configuration=api_config, ai_configuration=ai_config)\n", - "prompt_client.add_prompt_template('say_hi_to_friend', 'Say hello to your new friend ${friend_name} based on the time of the day.', 'xxx template')\n", - "result = prompt_client.test_prompt_template('say_hi_to_friend', {'friend_name': 'viren'})\n", + "result = ai_orchestrator.test_prompt_template('give an evening greeting to ${friend_name}. go: ',\n", + " {'friend_name': 'viren'}, ai_config.llm_provider,\n", + " ai_config.text_complete_model)\n", "print(result)" ], "metadata": { "collapsed": false, "ExecuteTime": { - "end_time": "2023-11-20T19:17:05.140695Z", - "start_time": "2023-11-20T19:17:04.482083Z" + "end_time": "2023-12-03T08:17:17.499667Z", + "start_time": "2023-12-03T08:17:14.377979Z" } }, "id": "866c99bc07c3d0cd" @@ -59,18 +54,17 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 5, "outputs": [ { "ename": "TypeError", - "evalue": "can only concatenate str (not \"list\") to str", + "evalue": "__init__() missing 1 required positional argument: 'executor'", "output_type": "error", "traceback": [ "\u001B[0;31m---------------------------------------------------------------------------\u001B[0m", "\u001B[0;31mTypeError\u001B[0m Traceback (most recent call last)", - "Cell \u001B[0;32mIn[6], line 18\u001B[0m\n\u001B[1;32m 13\u001B[0m workflow\u001B[38;5;241m.\u001B[39moutput_parameters \u001B[38;5;241m=\u001B[39m {\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mgreetings\u001B[39m\u001B[38;5;124m'\u001B[39m: \u001B[38;5;124m'\u001B[39m\u001B[38;5;124m$\u001B[39m\u001B[38;5;132;01m{say_hi_ref.output.result}\u001B[39;00m\u001B[38;5;124m'\u001B[39m}\n\u001B[1;32m 15\u001B[0m \u001B[38;5;66;03m# When running from the notebook\u001B[39;00m\n\u001B[1;32m 16\u001B[0m \u001B[38;5;66;03m# task_executors = {'get_friend_name_ref': getName}\u001B[39;00m\n\u001B[0;32m---> 18\u001B[0m wf_result \u001B[38;5;241m=\u001B[39m \u001B[43mprompt_client\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mexecute_workflow\u001B[49m\u001B[43m(\u001B[49m\u001B[43mworkflow\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mworkflow\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mwait_for_seconds\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[38;5;241;43m5\u001B[39;49m\u001B[43m)\u001B[49m\n\u001B[1;32m 19\u001B[0m \u001B[38;5;28mprint\u001B[39m(wf_result\u001B[38;5;241m.\u001B[39moutput)\n", - "File \u001B[0;32m~/workspace/github/orkes/sdk/conductor-python/src/conductor/client/ai/ai_orchestrator.py:78\u001B[0m, in \u001B[0;36mAIOrchestrator.execute_workflow\u001B[0;34m(self, workflow, task_to_exec, wait_for_seconds)\u001B[0m\n\u001B[1;32m 76\u001B[0m task_to_exec \u001B[38;5;241m=\u001B[39m task_to_exec \u001B[38;5;129;01mor\u001B[39;00m {}\n\u001B[1;32m 77\u001B[0m task_to_exec \u001B[38;5;241m=\u001B[39m workflow\u001B[38;5;241m.\u001B[39mtasks\n\u001B[0;32m---> 78\u001B[0m \u001B[38;5;28mprint\u001B[39m(\u001B[38;5;124;43m'\u001B[39;49m\u001B[38;5;124;43mHello\u001B[39;49m\u001B[38;5;124;43m'\u001B[39;49m\u001B[43m \u001B[49m\u001B[38;5;241;43m+\u001B[39;49m\u001B[43m \u001B[49m\u001B[43mtask_to_exec\u001B[49m)\n\u001B[1;32m 79\u001B[0m workflow\u001B[38;5;241m.\u001B[39mexecutor \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mworkflow_executor\n\u001B[1;32m 80\u001B[0m request \u001B[38;5;241m=\u001B[39m StartWorkflowRequest()\n", - "\u001B[0;31mTypeError\u001B[0m: can only concatenate str (not \"list\") to str" + "Cell \u001B[0;32mIn[5], line 11\u001B[0m\n\u001B[1;32m 8\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[38;5;124m'\u001B[39m\u001B[38;5;124mSteve Jobs\u001B[39m\u001B[38;5;124m'\u001B[39m\n\u001B[1;32m 10\u001B[0m prompt \u001B[38;5;241m=\u001B[39m Prompt(name\u001B[38;5;241m=\u001B[39m\u001B[38;5;124m'\u001B[39m\u001B[38;5;124msay_hi_to_friend\u001B[39m\u001B[38;5;124m'\u001B[39m, variables\u001B[38;5;241m=\u001B[39m{\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mfriend_name\u001B[39m\u001B[38;5;124m'\u001B[39m: \u001B[38;5;124m'\u001B[39m\u001B[38;5;124m$\u001B[39m\u001B[38;5;132;01m{get_friend_name_ref.output.result}\u001B[39;00m\u001B[38;5;124m'\u001B[39m})\n\u001B[0;32m---> 11\u001B[0m workflow \u001B[38;5;241m=\u001B[39m \u001B[43mConductorWorkflow\u001B[49m\u001B[43m(\u001B[49m\u001B[43mname\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[38;5;124;43m'\u001B[39;49m\u001B[38;5;124;43msay_hi_to_the_friend\u001B[39;49m\u001B[38;5;124;43m'\u001B[39;49m\u001B[43m)\u001B[49m\n\u001B[1;32m 12\u001B[0m workflow \u001B[38;5;241m>>\u001B[39m SimpleTask(task_def_name\u001B[38;5;241m=\u001B[39m\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mget_friend_name\u001B[39m\u001B[38;5;124m'\u001B[39m, task_reference_name\u001B[38;5;241m=\u001B[39m\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mget_friend_name_ref\u001B[39m\u001B[38;5;124m'\u001B[39m, execute_fn\u001B[38;5;241m=\u001B[39mgetName) \u001B[38;5;241m>>\u001B[39m LlmTextComplete(\u001B[38;5;124m'\u001B[39m\u001B[38;5;124msay_hi\u001B[39m\u001B[38;5;124m'\u001B[39m, \u001B[38;5;124m'\u001B[39m\u001B[38;5;124msay_hi_ref\u001B[39m\u001B[38;5;124m'\u001B[39m, ai_config\u001B[38;5;241m.\u001B[39mllm_provider, ai_config\u001B[38;5;241m.\u001B[39mtext_complete_model, prompt\u001B[38;5;241m=\u001B[39mprompt) \n\u001B[1;32m 13\u001B[0m workflow\u001B[38;5;241m.\u001B[39moutput_parameters \u001B[38;5;241m=\u001B[39m {\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mgreetings\u001B[39m\u001B[38;5;124m'\u001B[39m: \u001B[38;5;124m'\u001B[39m\u001B[38;5;124m$\u001B[39m\u001B[38;5;132;01m{say_hi_ref.output.result}\u001B[39;00m\u001B[38;5;124m'\u001B[39m}\n", + "\u001B[0;31mTypeError\u001B[0m: __init__() missing 1 required positional argument: 'executor'" ] } ], @@ -92,14 +86,14 @@ "# When running from the notebook\n", "# task_executors = {'get_friend_name_ref': getName}\n", "\n", - "wf_result = prompt_client.execute_workflow(workflow=workflow, wait_for_seconds=5)\n", + "wf_result = ai_orchestrator.execute_workflow(workflow=workflow, wait_for_seconds=5)\n", "print(wf_result.output)" ], "metadata": { "collapsed": false, "ExecuteTime": { - "end_time": "2023-11-20T19:17:20.277641Z", - "start_time": "2023-11-20T19:17:20.261670Z" + "end_time": "2023-12-03T08:17:34.292670Z", + "start_time": "2023-12-03T08:17:34.277184Z" } }, "id": "5d6999207803bd5f" diff --git a/tests/unit/orkes/test_metadata_client.py b/tests/unit/orkes/test_metadata_client.py index aa73d622..08ef3f91 100644 --- a/tests/unit/orkes/test_metadata_client.py +++ b/tests/unit/orkes/test_metadata_client.py @@ -132,7 +132,7 @@ def test_getAllTaskDefs(self, mock): @patch.object(TagsApi, 'add_workflow_tag') def test_addWorkflowTag(self, mock): - self.metadata_client.addWorkflowTag(self.wfTagObj, WORKFLOW_NAME) + self.metadata_client.add_workflow_tag(self.wfTagObj, WORKFLOW_NAME) mock.assert_called_with(self.wfTagObj, WORKFLOW_NAME) @patch.object(TagsApi, 'delete_workflow_tag')