-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bee-hive in kubernetes #163
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9f55daa
Add API for bee-hive
akihikokuroda 37816b0
add deployment and service yaml
akihikokuroda 1130df5
update docker deploy steps
akihikokuroda 39a1da3
update bee-hive.sh for kubernetes
akihikokuroda 590f274
update README
akihikokuroda b39ee2f
remove envs from deployment.yaml file
akihikokuroda 7100ae3
update README
akihikokuroda 8cb5876
update README
akihikokuroda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Assisted by watsonx Code Assistant | ||
from flask import Flask, request, jsonify | ||
import os | ||
import json | ||
import sys | ||
import io | ||
|
||
import yaml | ||
from bee_hive.workflow import Workflow | ||
|
||
app = Flask(__name__) | ||
|
||
def parse_yaml(file_path): | ||
with open(file_path, "r") as file: | ||
yaml_data = list(yaml.safe_load_all(file)) | ||
return yaml_data | ||
|
||
@app.route('/', methods=['POST']) | ||
def process_workflow(): | ||
if request.method == 'POST': | ||
# Check if a file was uploaded | ||
if 'agents' not in request.files: | ||
return 'No agent definition' | ||
|
||
agents = request.files['agents'] | ||
|
||
# Check if the file has a filename | ||
if agents.filename == '': | ||
return 'No agents file name' | ||
|
||
# Save the file to the server | ||
agents.save("agents") | ||
|
||
if 'workflow' not in request.files: | ||
return 'No agent definition' | ||
|
||
workflow = request.files['workflow'] | ||
|
||
# Check if the file has a filename | ||
if workflow.filename == '': | ||
return 'No workflow file name' | ||
|
||
# Save the file to the server | ||
workflow.save("workflow") | ||
|
||
agents_yaml = parse_yaml("agents") | ||
workflow_yaml = parse_yaml("workflow") | ||
try: | ||
workflow_instance = Workflow(agents_yaml, workflow_yaml[0]) | ||
except Exception as excep: | ||
raise RuntimeError("Unable to create agents") from excep | ||
|
||
output = io.StringIO() | ||
sys.stdout = output | ||
workflow_instance.run() | ||
sys.stdout = sys.__stdout__ | ||
|
||
response = { | ||
'workflow': workflow.filename, | ||
'agents': agents.filename, | ||
'output': output.getvalue() | ||
} | ||
|
||
return jsonify(response) | ||
|
||
return render_template('upload.html') | ||
if __name__ == '__main__': | ||
app.run(host='0.0.0.0') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: bee-hive | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: bee-hive | ||
template: | ||
metadata: | ||
labels: | ||
app: bee-hive | ||
spec: | ||
containers: | ||
- name: bee-hive | ||
image: bee-hive:latest | ||
imagePullPolicy: Never | ||
ports: | ||
- containerPort: 5000 | ||
env: | ||
- name: DUMMY | ||
value: dummyvalue | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: bee-hive | ||
spec: | ||
selector: | ||
app: bee-hive | ||
ports: | ||
- protocol: TCP | ||
port: 80 | ||
targetPort: 5000 | ||
type: NodePort |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
|
||
python3.11 api.py | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: let's make two sections for the deploy, one for docker and one for kubernetes. that would also allow for including some kubernetes-specific instructions:
since both of those will differ depending on the k8s used (rancher, kind, etc.), I don't think we need to include specific instructions, but we should mention that the steps are needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@psschwei Thanks! I'll create another PR for the readme update!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
feel free to merge when you're ready (or if you want to wait to see if anyone has comments that's cool too)