Skip to content

Commit

Permalink
implement run command
Browse files Browse the repository at this point in the history
  • Loading branch information
javierluraschi committed May 10, 2024
1 parent c4aa17a commit 38e05b5
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion python/hal9/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def run(path):
PATH: The path to the project. Required argument.
"""
print(f'Running {path}')
api_run(path)

@click.command()
@click.argument('path')
Expand Down
20 changes: 14 additions & 6 deletions python/hal9/run.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import requests
import time
import tempfile
import sys
import runpy
import subprocess
from pathlib import Path

def run(path :str) -> str:
"""Run an application
Expand All @@ -13,4 +10,15 @@ def run(path :str) -> str:
Path to the application.
"""

print(f'Running...')
app_path = Path(path) / 'app.py'

if not app_path.is_file():
print(f"Failed to run {app_path}")
return

try:
command = ['python', str(app_path)]
with subprocess.Popen(command) as proc:
proc.wait()
except Exception as e:
print(f"An error occurred while running app.py: {e}")
5 changes: 4 additions & 1 deletion python/hal9/templates/openai/app.py
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
print('Hello from OpenAI')
import sys

name = input("What's your name? ")
print(f"Hello {name}")
2 changes: 1 addition & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "hal9"
version = "2.0.3"
version = "2.0.4"
description = ""
authors = ["Javier Luraschi <[email protected]>"]
readme = "README.md"
Expand Down
3 changes: 3 additions & 0 deletions python/test/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

name = input("What's your name? ")
print(f"Hello {name}")

0 comments on commit 38e05b5

Please sign in to comment.