fix: deployment

This commit is contained in:
Florian Hönicke
2023-04-15 00:51:42 +02:00
parent f7b1688e0a
commit ced758acbd
2 changed files with 25 additions and 18 deletions

View File

@@ -41,7 +41,6 @@ To ensure the microservice accurately aligns with your intended task a test scen
## Quickstart
### Requirements
- OpenAI key with access to GPT-4
- Create an account at [cloud.jina.ai](https://cloud.jina.ai) where your microservice will be deployed
### Installation
```bash
@@ -64,23 +63,22 @@ To generate your personal microservice two things are required:
The creation process should take between 5 and 15 minutes.
During this time, GPT iteratively builds your microservice until it finds a strategy that make your test scenario pass.
Be aware that the costs you have to pay for openai vary between $0.50 and $3.00 per microservice (using GPT-4).
### Run Microservice
Run the microservice locally. With this command a playground opens in your browser where you can test the microservice.
```bash
gptdeploy run --path <path to microservice>
```
### Deploy Microservice
It is required to have a [Jina account](https://cloud.jina.ai/) to deploy your microservice.
If you want to deploy your microservice to the cloud a [Jina account](https://cloud.jina.ai/) is required.
When creating a Jina account, you get some free credits, which you can use to deploy your microservice ($0.025/hour).
If you run out of credits, you can purchase more.
```bash
gptdeploy deploy --microservice_path <path to microservice>
```
[//]: # (Once the microservice is generated and deployed, you can test it using the generated Streamlit playground.)
[//]: # (The deployment is made on the Jina`s infrastructure. )
[//]: # (When creating a Jina account, you get some free credits, which you can use to deploy your microservice &#40;$0.025/hour&#41;.)
[//]: # (Be aware that the costs you have to pay for openai vary between $0.50 and $3.00 per microservice.)
[//]: # (If you run out of credits, you can purchase more.)
### Delete Microservice
To save credits you can delete your microservice via the following commands:

View File

@@ -4,11 +4,13 @@ import os
import re
import subprocess
import threading
import time
import webbrowser
from pathlib import Path
import click
import hubble
import requests
from hubble.executor.helper import upload_file, archive_package, get_request_header
from jcloud.flow import CloudFlow
from jina import Flow
@@ -18,9 +20,6 @@ from src.utils.io import suppress_stdout, is_docker_running
from src.utils.string_tools import print_colored
import requests
import time
def wait_until_app_is_ready(url):
is_app_ready = False
while not is_app_ready:
@@ -33,6 +32,7 @@ def wait_until_app_is_ready(url):
pass
time.sleep(0.5)
def open_streamlit_app():
url = "http://localhost:8081/playground"
wait_until_app_is_ready(url)
@@ -129,6 +129,12 @@ def deploy_on_jcloud(executor_name, microservice_path):
except Exception as e:
print(f'Could not deploy on Jina Cloud. Trying again in 5 seconds. Error: {e}')
time.sleep(5)
except SystemExit as e:
raise SystemExit(f'''
Looks like your free credits ran out.
Please add payment information to your account and try again.
Visit https://cloud.jina.ai/
''') from e
if i == 2:
raise Exception('''
Could not deploy on Jina Cloud.
@@ -141,13 +147,15 @@ def deploy_on_jcloud(executor_name, microservice_path):
Your Microservice is deployed.
Run the following command to start the playground:
streamlit run {os.path.join(microservice_path, "app.py")} --server.port 8081 --server.address 0.0.0.0 -- --host http://{host}
streamlit run {os.path.join(microservice_path, "app.py")} --server.port 8081 --server.address 0.0.0.0 -- --host {host}
'''
)
return host
def run_streamlit_app(app_path):
subprocess.run(['streamlit', 'run', app_path, 'server.address', '0.0.0.0', '--server.port', '8081', '--', '--host', 'grpc://localhost:8080'])
subprocess.run(['streamlit', 'run', app_path, 'server.address', '0.0.0.0', '--server.port', '8081', '--', '--host',
'grpc://localhost:8080'])
def run_locally(executor_name, microservice_version_path):
@@ -176,6 +184,7 @@ We now start the playground for you.
flow.block()
def create_flow_yaml(dest_folder, executor_name, use_docker):
if use_docker:
prefix = 'jinaai+docker'