feat: http instead of grpc (#18)

* feat: http

* feat: http

* fix: git ignore

* fix: better formatting

* docs: add missing print

* fix: add protocol

* fix: bump version
This commit is contained in:
Florian Hönicke
2023-04-19 14:11:21 +02:00
committed by GitHub
parent d4d80a1628
commit a336907a21
7 changed files with 11 additions and 9 deletions

2
.gitignore vendored
View File

@@ -1,4 +1,4 @@
/executor_level2/ /microservice/
.env .env
config.yml config.yml

View File

@@ -7,7 +7,7 @@ def read_requirements():
setup( setup(
name='gptdeploy', name='gptdeploy',
version='0.18.18', version='0.18.19',
description='Use natural language interface to generate, deploy and update your microservice infrastructure.', description='Use natural language interface to generate, deploy and update your microservice infrastructure.',
long_description=open('README.md', 'r', encoding='utf-8').read(), long_description=open('README.md', 'r', encoding='utf-8').read(),
long_description_content_type='text/markdown', long_description_content_type='text/markdown',

View File

@@ -1,2 +1,2 @@
__version__ = '0.18.18' __version__ = '0.18.19'
from src.cli import main from src.cli import main

View File

@@ -155,7 +155,7 @@ streamlit run {os.path.join(microservice_path, "app.py")} --server.port 8081 --s
def run_streamlit_app(app_path): def run_streamlit_app(app_path):
subprocess.run(['streamlit', 'run', app_path, 'server.address', '0.0.0.0', '--server.port', '8081', '--', '--host', subprocess.run(['streamlit', 'run', app_path, 'server.address', '0.0.0.0', '--server.port', '8081', '--', '--host',
'grpc://localhost:8080']) 'http://localhost:8080'])
def run_locally(executor_name, microservice_version_path): def run_locally(executor_name, microservice_version_path):
@@ -207,6 +207,7 @@ jtype: Flow
with: with:
name: nowapi name: nowapi
port: 8080 port: 8080
protocol: http
jcloud: jcloud:
version: 3.14.2.dev18 version: 3.14.2.dev18
labels: labels:

View File

@@ -54,7 +54,7 @@ metas:
def generate_and_persist_file(self, section_title, template, destination_folder, file_name, **template_kwargs): def generate_and_persist_file(self, section_title, template, destination_folder, file_name, **template_kwargs):
print_colored('', f'\n############# {section_title} #############', 'blue') print_colored('', f'\n\n############# {section_title} #############', 'blue')
conversation = self.gpt_session.get_conversation() conversation = self.gpt_session.get_conversation()
template_kwargs = {k: v for k, v in template_kwargs.items() if k in template.input_variables} template_kwargs = {k: v for k, v in template_kwargs.items() if k in template.input_variables}
content_raw = conversation.chat( content_raw = conversation.chat(
@@ -139,7 +139,7 @@ metas:
print('\nFirst version of the microservice generated. Start iterating on it to make the tests pass...') print('\nFirst version of the microservice generated. Start iterating on it to make the tests pass...')
def generate_playground(self, microservice_name, microservice_path): def generate_playground(self, microservice_name, microservice_path):
print_colored('', '\n############# Playground #############', 'blue') print_colored('', '\n\n############# Playground #############', 'blue')
file_name_to_content = get_all_microservice_files_with_content(microservice_path) file_name_to_content = get_all_microservice_files_with_content(microservice_path)
conversation = self.gpt_session.get_conversation([]) conversation = self.gpt_session.get_conversation([])
@@ -222,13 +222,14 @@ metas:
return 'yes' in answer.lower() return 'yes' in answer.lower()
def generate_microservice_name(self, description): def generate_microservice_name(self, description):
print_colored('', '\n\n############# What should be the name of the Microservice? #############', 'blue')
conversation = self.gpt_session.get_conversation() conversation = self.gpt_session.get_conversation()
name_raw = conversation.chat(template_generate_microservice_name.format(description=description)) name_raw = conversation.chat(template_generate_microservice_name.format(description=description))
name = self.extract_content_from_result(name_raw, 'name.txt') name = self.extract_content_from_result(name_raw, 'name.txt')
return name return name
def get_possible_packages(self): def get_possible_packages(self):
print_colored('', '############# What packages to use? #############', 'blue') print_colored('', '\n\n############# What packages to use? #############', 'blue')
conversation = self.gpt_session.get_conversation() conversation = self.gpt_session.get_conversation()
packages_raw = conversation.chat( packages_raw = conversation.chat(
template_generate_possible_packages.format(description=self.task_description) template_generate_possible_packages.format(description=self.task_description)

View File

@@ -64,7 +64,7 @@ Here is an example of a client file:
**client.py** **client.py**
```python ```python
from jina import Client, Document, DocumentArray from jina import Client, Document, DocumentArray
client = Client(host='{FLOW_URL_PLACEHOLDER}') client = Client(host='{FLOW_URL_PLACEHOLDER}', protocol='http')
d = Document(uri='...') d = Document(uri='...')
d.load_uri_to_blob() d.load_uri_to_blob()
response = client.post('/', inputs=DocumentArray([d])) # the client must be called on '/' response = client.post('/', inputs=DocumentArray([d])) # the client must be called on '/'

View File

@@ -274,7 +274,7 @@ print(response[0].text) # can also be blob in case of image/audio..., this shoul
``` ```
Note that the response will always be in response[0].text Note that the response will always be in response[0].text
You must provide the complete app.py file with the exact same syntax to wrap the code. You must provide the complete app.py file with the exact same syntax to wrap the code.
The playground (app.py) must read the host from sys.argv because it will be started with a custom host: streamlit run app.py -- --host grpc://... The playground (app.py) must read the host from sys.argv because it will be started with a custom host: streamlit run app.py -- --host http(s)://...
The playground (app.py) must not let the user configure the host on the ui. The playground (app.py) must not let the user configure the host on the ui.
''' '''
) )