diff --git a/README.md b/README.md index 9f962eb..ec5f896 100644 --- a/README.md +++ b/README.md @@ -183,6 +183,13 @@ gptdeploy create --description "Generate QR code from URL" --test "https://www.e ``` QR Code Generator +### Mandelbrot Set Visualizer + +```bash +gptdeploy create --description "Visualize the Mandelbrot set with custom parameters" --test "center=-0+1i, zoom=1.0, size=800x800, iterations=1000" +``` +Mandelbrot Set Visualizer + [//]: # (## TO BE TESTED) @@ -344,13 +351,6 @@ gptdeploy create --description "Generate QR code from URL" --test "https://www.e [//]: # () [//]: # () -[//]: # (### Mandelbrot Set Visualizer) - -[//]: # (```bash) - -[//]: # (gptdeploy create --description "Visualize the Mandelbrot set with custom parameters" --test "center=-0.5+0i, zoom=1.0, size=800x800, iterations=1000") - -[//]: # (```) [//]: # (### Sound Visualizer) @@ -440,3 +440,6 @@ Make sure it is only printed twice in case it changed. - [ ] section for microservices built by the community - [ ] test feedback for playground generation (could be part of the debugging) - [ ] should we send everything via json in the text attribute for simplicity? + +Proposal: +- [ ] just generate the non-jina related code and insert it into an executor template diff --git a/res/mandelbrot_example.png b/res/mandelbrot_example.png new file mode 100644 index 0000000..92074a0 Binary files /dev/null and b/res/mandelbrot_example.png differ diff --git a/src/jina_cloud.py b/src/jina_cloud.py index 169323b..58e3db7 100644 --- a/src/jina_cloud.py +++ b/src/jina_cloud.py @@ -10,6 +10,8 @@ import hubble from hubble.executor.helper import upload_file, archive_package, get_request_header from jcloud.flow import CloudFlow +from src.utils.io import suppress_stdout + def redirect_callback(href): print( @@ -41,7 +43,9 @@ def push_executor(dir_path): 'verbose': 'True', 'md5sum': md5_digest, } - req_header = get_request_header() + with suppress_stdout(): + req_header = get_request_header() + resp = upload_file( 'https://api.hubble.jina.ai/v2/rpc/executor.push', 'filename', diff --git a/src/prompt_system.py b/src/prompt_system.py index ed9959b..a50df41 100644 --- a/src/prompt_system.py +++ b/src/prompt_system.py @@ -66,7 +66,7 @@ d1 = Document(text='hello') url = 'https://...' response = requests.get(url) obj_data = response.content -d2 = Document(blob=obj_data) # blob is bytes like b'\\x89PNG\\r\\n\\x1a\\n\ +d2 = Document(blob=obj_data) # blob is bytes like b'\\x89PNG\\r\\n\\x1a\\n...' d3 = Document(tensor=numpy.array([1, 2, 3]), chunks=[Document(uri=/local/path/to/file)] d4 = Document( diff --git a/src/prompt_tasks.py b/src/prompt_tasks.py index 7e96a5c..5f3d7dd 100644 --- a/src/prompt_tasks.py +++ b/src/prompt_tasks.py @@ -135,4 +135,5 @@ The executor must not load data from the local file system unless it was created The executor must not use a pre-trained model unless it is explicitly mentioned in the description. The executor must not train a model. The executor must not use Document.tags. +The executor must only use Document.uri, Document.blob and Document.text. ''' \ No newline at end of file diff --git a/src/utils/io.py b/src/utils/io.py index 510a75f..9e53475 100644 --- a/src/utils/io.py +++ b/src/utils/io.py @@ -3,6 +3,8 @@ import shutil import concurrent.futures import concurrent.futures from typing import Generator +import sys +from contextlib import contextmanager def recreate_folder(folder_path): if os.path.exists(folder_path) and os.path.isdir(folder_path): @@ -34,4 +36,14 @@ def timeout_generator_wrapper(generator, timeout): except concurrent.futures.TimeoutError: raise GenerationTimeoutError(f"Generation took longer than {timeout} seconds") - return wrapper() \ No newline at end of file + return wrapper() + +@contextmanager +def suppress_stdout(): + original_stdout = sys.stdout + sys.stdout = open(os.devnull, 'w') + try: + yield + finally: + sys.stdout.close() + sys.stdout = original_stdout \ No newline at end of file