Skip to content

Commit

Permalink
implement create command
Browse files Browse the repository at this point in the history
  • Loading branch information
javierluraschi committed May 10, 2024
1 parent 0a0e43f commit c4aa17a
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 30 deletions.
4 changes: 3 additions & 1 deletion python/hal9/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from hal9.api import *
from hal9.create import create
from hal9.run import run
from hal9.deploy import deploy
6 changes: 4 additions & 2 deletions python/hal9/cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import click
from collections import OrderedDict
from hal9.api import *
from hal9.create import create as api_create
from hal9.run import run as api_run
from hal9.deploy import deploy as api_deploy

@click.group()
def cli():
Expand All @@ -20,7 +22,7 @@ def create(path):
PATH: The path for the new project. Required argument.
"""
print(f'Creating: {path}')
api_create(path, "openai")

@click.command()
@click.argument('path')
Expand Down
28 changes: 28 additions & 0 deletions python/hal9/create.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import os
import shutil
from pathlib import Path

def create(path :str, template :str) -> str:
"""Create an application
Parameters
----------
path : str
Path to the application.
template : str
The template to use.
"""

current_dir = Path(__file__).parent
template_path = current_dir / "templates" / template

os.makedirs(path, exist_ok=True)

for item in template_path.iterdir():
dest = Path(path) / item.name
if item.is_dir():
shutil.copytree(item, dest)
else:
shutil.copy2(item, dest)

print(f'Project created!')
24 changes: 0 additions & 24 deletions python/hal9/api.py → python/hal9/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,6 @@
import sys
import runpy

def create(path :str, template :str) -> str:
"""Create an application
Parameters
----------
path : str
Path to the application.
template : str
The template to use.
"""

print(f'Project created! {name}')

def run(path :str) -> str:
"""Run an application
Parameters
----------
path : str
Path to the application.
"""

print(f'Project created! {name}')

def deploy(path :str, target :str) -> str:
"""Deploy an application
Expand Down
16 changes: 16 additions & 0 deletions python/hal9/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import requests
import time
import tempfile
import sys
import runpy

def run(path :str) -> str:
"""Run an application
Parameters
----------
path : str
Path to the application.
"""

print(f'Running...')
1 change: 1 addition & 0 deletions python/hal9/templates/openai/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print('Hello from OpenAI')
3 changes: 2 additions & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[tool.poetry]
name = "hal9"
version = "2.0.2"
version = "2.0.3"
description = ""
authors = ["Javier Luraschi <[email protected]>"]
readme = "README.md"
include = ["templates/openai/app.py"]

[tool.poetry.dependencies]
python = ">=3.8,<3.9.7 || >3.9.7,<4.0"
Expand Down
2 changes: 0 additions & 2 deletions python/tests/tests.py

This file was deleted.

0 comments on commit c4aa17a

Please sign in to comment.