feat: server

This commit is contained in:
Florian Hönicke
2023-03-19 21:02:07 +01:00
parent 61ef41f073
commit 45b709ed15
8 changed files with 198 additions and 51 deletions

View File

@@ -1,9 +1,12 @@
import os
from multiprocessing.connection import Client
import hubble
from jcloud.flow import CloudFlow
from jina import Flow
from src.constants import FLOW_URL_PLACEHOLDER
def push_executor():
cmd = 'jina hub push executor/. --verbose'
@@ -46,4 +49,24 @@ executors:
with flow:
pass
return CloudFlow(path=full_flow_path).__enter__().endpoints['gateway']
return CloudFlow(path=full_flow_path).__enter__().endpoints['gateway']
def replace_client_line(file_content: str, replacement: str) -> str:
lines = file_content.split('\n')
for index, line in enumerate(lines):
if 'Client(' in line:
lines[index] = replacement
break
return '\n'.join(lines)
def run_client_file(file_path, host):
with open(file_path, 'r') as file:
content = file.read()
replaced_content = replace_client_line(content, f"client = Client(host='{host}')")
with open(file_path, 'w') as file:
file.write(replaced_content)
import executor.client # runs the client script for validation