SoumyaJ commited on
Commit
8e06e17
·
verified ·
1 Parent(s): e445ad4

Update workflow_invocation.py

Browse files
Files changed (1) hide show
  1. workflow_invocation.py +31 -30
workflow_invocation.py CHANGED
@@ -1,30 +1,31 @@
1
- from workflowschema import LibraryModel
2
- import httpx
3
- import asyncio
4
- import yaml
5
-
6
-
7
- class WorkflowInvocation:
8
- def __init__(self, payload):
9
- self.config = self.load_config()
10
- self.payload = payload
11
-
12
- def load_config(self):
13
- with open("config.yaml","r") as file:
14
- config = yaml.safe_load(file)
15
- return config
16
-
17
-
18
- async def invoke_workflow(self):
19
- try:
20
- webHookUrl = self.config['workflow']['webhook_url']
21
-
22
- async with httpx.AsyncClient() as client:
23
- response = await client.post(webHookUrl, json=self.payload)
24
- response.raise_for_status()
25
- json_response = response.json()
26
- return json_response
27
- #print("Response status code:", response.json())
28
- except Exception as e:
29
- print(f"An error occurred: {e}")
30
-
 
 
1
+ from workflowschema import LibraryModel
2
+ import httpx
3
+ import asyncio
4
+ import yaml
5
+
6
+
7
+ class WorkflowInvocation:
8
+ def __init__(self, payload):
9
+ self.config = self.load_config()
10
+ self.payload = payload
11
+
12
+ def load_config(self):
13
+ with open("config.yaml","r") as file:
14
+ config = yaml.safe_load(file)
15
+ return config
16
+
17
+
18
+ async def invoke_workflow(self):
19
+ try:
20
+ webHookUrl = self.config['workflow']['webhook_url']
21
+ print(webHookUrl)
22
+ async with httpx.AsyncClient() as client:
23
+ response = await client.post(webHookUrl, json=self.payload)
24
+ response.raise_for_status()
25
+ json_response = response.json()
26
+ print(json_response)
27
+ return json_response
28
+ #print("Response status code:", response.json())
29
+ except Exception as e:
30
+ print(f"An error occurred: {e}")
31
+