-
Notifications
You must be signed in to change notification settings - Fork 183
Deploy command #173
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
Draft
bboynton97
wants to merge
58
commits into
main
Choose a base branch
from
deploy-command
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Deploy command #173
Changes from 4 commits
Commits
Show all changes
58 commits
Select commit
Hold shift + click to select a range
d8e7afa
serve
bboynton97 7a60fc0
fix serve file and dockerfile
bboynton97 7f88cc0
serve from inside source
bboynton97 b067837
load dotenv
bboynton97 606fd44
load dotenv from one up
bboynton97 a240d5d
health endpoint
bboynton97 b9d9942
env path
bboynton97 e25b51a
loadenv before import
bboynton97 8c13295
Merge branch 'main' into deploy
bboynton97 83fc0c7
Merge branch 'main' into deploy
bboynton97 77657f3
Merge branch 'main' into deploy
bboynton97 6ccbcda
Merge branch 'main' into deploy
bboynton97 2d80e52
Merge branch 'main' into deploy
bboynton97 f51de09
Merge branch 'main' into deploy
bboynton97 6896a22
create project on deploy
bboynton97 15d2cab
Merge branch 'main' into deploy-command
bboynton97 6190572
Merge branch 'main' into deploy-command
bboynton97 41b9b9a
zip code and upload
bboynton97 033711a
Merge branch 'main' into deploy
bboynton97 80a1932
Merge branch 'main' into deploy-command
bboynton97 dcacaca
fix deploy
bboynton97 de2d4aa
Merge branch 'refs/heads/main' into deploy
bboynton97 ef3a3fd
serve working
bboynton97 a1a26bd
Merge branch 'main' into deploy-command
bboynton97 140b80f
Merge branch 'main' into deploy-command
bboynton97 71f474f
build all but some folders
bboynton97 066fa2d
Merge branch 'main' into deploy-command
bboynton97 620f7fb
better upload
bboynton97 d8055bd
spinner tests
bboynton97 3fd8ef1
deploy tests
bboynton97 044e053
logging
bboynton97 d2590e0
use websockets
bboynton97 9ee0ecd
Merge branch 'deploy' into deploy-command
bboynton97 325d76e
use proper dockerfile
bboynton97 7883198
Merge branch 'main' into deploy-command
bboynton97 4da6cf7
Merge branch 'main' into deploy-command
bboynton97 4b31001
build, push, track, webhooks
bboynton97 6a30280
serve work
bboynton97 0ad98ea
dockerfile works and new run func
bboynton97 2b94a9f
import fix
bboynton97 023b3ce
run proj from serve.py
bboynton97 72161d3
if main at bottom
bboynton97 35d94a4
input handling
bboynton97 0a7eba7
log import
bboynton97 cf49ff8
log import fix
bboynton97 bf7fd6e
todos
bboynton97 4b5a178
update serve
bboynton97 dc3cbf4
Merge branch 'main' into deploy-command
bboynton97 8c7ea35
use gunincorn
bboynton97 f578b00
fix name
bboynton97 3cdb963
return before processing
bboynton97 5378071
return result
bboynton97 abd383b
return session_id
bboynton97 318c4b8
guid to string
bboynton97 e4991eb
use waitress
bboynton97 94ee47f
use hosted
bboynton97 9c96e45
remove waitress import
bboynton97 f8e69e4
end deploy logs on finish deploy
bboynton97 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 hidden or 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 hidden or 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,94 @@ | ||
| import os | ||
| import tempfile | ||
| import tomllib | ||
| import webbrowser | ||
| import zipfile | ||
| from pathlib import Path | ||
|
|
||
| from agentstack.auth import get_stored_token, login | ||
| from agentstack.conf import ConfigFile | ||
| from agentstack.utils import term_color | ||
| import requests | ||
|
|
||
|
|
||
| def deploy(): | ||
| bearer_token = get_stored_token() | ||
| if not bearer_token: | ||
| success = login() | ||
| if success: | ||
| bearer_token = get_stored_token() | ||
| else: | ||
| print(term_color("Failed to authenticate with AgentStack.sh", "red")) | ||
| return | ||
|
|
||
| project_id = get_project_id() | ||
| pyproject = load_pyproject() | ||
| files = list(Path('.').rglob('*.py')) | ||
|
|
||
| with tempfile.NamedTemporaryFile(suffix='.zip') as tmp: | ||
| with zipfile.ZipFile(tmp.name, 'w') as zf: | ||
|
||
| for file in files: | ||
| zf.write(file) | ||
| if pyproject: | ||
| zf.write("pyproject.toml") | ||
|
|
||
| response = requests.post( | ||
| 'http://localhost:3000/deploy/build', | ||
| files={'code': ('code.zip', open(tmp.name, 'rb'))}, | ||
| params={'projectId': project_id}, | ||
| headers={'Authorization': bearer_token} | ||
| ) | ||
|
|
||
| if response.status_code != 200: | ||
| print(term_color("Failed to deploy with AgentStack.sh", "red")) | ||
| print(response.text) | ||
| return | ||
|
|
||
| webbrowser.open(f"http://localhost:5173/project/{project_id}") | ||
|
|
||
|
|
||
| def load_pyproject(): | ||
| if os.path.exists("pyproject.toml"): | ||
| with open("pyproject.toml", "rb") as f: | ||
| return tomllib.load(f) | ||
| return None | ||
|
|
||
| def get_project_id(): | ||
| project_config = ConfigFile() | ||
| project_id = project_config.hosted_project_id | ||
|
|
||
| if project_id: | ||
| return project_id | ||
|
|
||
| bearer_token = get_stored_token() | ||
|
|
||
| # if not in config, create project and store it | ||
| print(term_color("🚧 Creating AgentStack.sh Project", "green")) | ||
| headers = { | ||
| 'Authorization': f'Bearer {bearer_token}', | ||
| 'Content-Type': 'application/json' | ||
| } | ||
|
|
||
| payload = { | ||
| 'name': project_config.project_name | ||
| } | ||
|
|
||
| try: | ||
| response = requests.post( | ||
| url="http://localhost:3000/projects", | ||
| # url="https://api.agentstack.sh/projects", | ||
| headers=headers, | ||
| json=payload | ||
| ) | ||
|
|
||
| response.raise_for_status() | ||
| res_data = response.json() | ||
| project_id = res_data['id'] | ||
| project_config.hosted_project_id = project_id | ||
| project_config.write() | ||
| return project_id | ||
|
|
||
| except requests.exceptions.RequestException as e: | ||
| print(f"Error making request: {e}") | ||
| return None | ||
|
|
||
This file contains hidden or 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
1 change: 1 addition & 0 deletions
1
agentstack/templates/crewai/{{cookiecutter.project_metadata.project_slug}}/agentstack.json
This file contains hidden or 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
Oops, something went wrong.
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.
add a deploy stub to /cli that manages the CLI interaction and logging, then use the deploy function from this file