Skip to content

Commit

Permalink
deploy supports --access
Browse files Browse the repository at this point in the history
  • Loading branch information
javierluraschi committed Aug 9, 2024
1 parent 8d29c0f commit 4655e19
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.6.4

- `deploy` supports `--access` to share private, public or unlisted

## 2.6.2

- `save()` now stores data under `/storage` to isolate files
Expand Down
5 changes: 3 additions & 2 deletions python/hal9/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ def run(path :str):
@click.option('--name', default=None, help='Deployment name')
@click.option('--type', '-f', 'typename', default='ability', help='Deployment content')
@click.option('--data', '-d', 'data', default=None, help='Deployment data path')
def deploy(path :str, target :str, url :str, name :str, typename :str, data :str):
@click.option('--access', '-a', 'access', default="private", help='Deployment access level')
def deploy(path :str, target :str, url :str, name :str, typename :str, data :str, access :str):
"""
Deploy Project
Expand All @@ -60,7 +61,7 @@ def deploy(path :str, target :str, url :str, name :str, typename :str, data :str
if (name is None):
name = f'{os.path.basename(path)}-{int(datetime.datetime.now().timestamp() * 1000)}'

api_deploy(path, target, url, name, typename, data)
api_deploy(path, target, url, name, typename, data, access)

cli.add_command(create)
cli.add_command(run)
Expand Down
6 changes: 4 additions & 2 deletions python/hal9/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
'hal9': deploy_hal9,
}

def deploy(path :str, target :str, url :str, name :str, typename :str, data :str) -> str:
def deploy(path :str, target :str, url :str, name :str, typename :str, data :str, access :str) -> str:
"""Deploy an application
Parameters
Expand All @@ -21,9 +21,11 @@ def deploy(path :str, target :str, url :str, name :str, typename :str, data :str
The deployment type, defaults to (chatbot) ability.
data : str
The data schema to use, defaults to empty.
access : str
The access level, defaults to 'private'.
"""

if target in targets:
targets[target](path, url, name, typename, data)
targets[target](path, url, name, typename, data, access)
else:
raise Exception(f"Deployment target '{target}' is unsupported.")
2 changes: 1 addition & 1 deletion python/hal9/targets/docker.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import shutil
from pathlib import Path

def deploy(path :str, url :str, name :str, typename :str) -> str:
def deploy(path :str, url :str, name :str, typename :str, access :str) -> str:
package_dir = Path(__file__).parent.parent
source_path = package_dir / 'templates' / 'docker' / 'Dockerfile'
destination_path = Path(path) / 'Dockerfile'
Expand Down
7 changes: 4 additions & 3 deletions python/hal9/targets/hal9.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def read_files(path):

return files_dict

def request_deploy(path :str, url :str, name :str, typename :str, data :str) -> str:
def request_deploy(path :str, url :str, name :str, typename :str, data :str, access :str) -> str:
project_name = project_from_path(path)
zip_path = create_deployment(path)

Expand All @@ -58,6 +58,7 @@ def request_deploy(path :str, url :str, name :str, typename :str, data :str) ->
'format': 'b64',
'files': read_files(path),
'schemapath': data,
'access': access
}

headers = {
Expand All @@ -72,12 +73,12 @@ def request_deploy(path :str, url :str, name :str, typename :str, data :str) ->
response_data = response.json()
print(response_data['url'])

def deploy(path :str, url :str, name :str, typename :str, data :str) -> str:
def deploy(path :str, url :str, name :str, typename :str, data :str, access :str) -> str:
if 'HAL9_TOKEN' in os.environ:
hal9_token = os.environ['HAL9_TOKEN']
else:
exit(f'HAL9_TOKEN environment variable missing, see https://hal9.com/deploy')
# hal9_token = browser_login()

request_deploy(path, url, name, typename, data)
request_deploy(path, url, name, typename, data, access)

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.6.3"
version = "2.6.4"
description = ""
authors = ["Javier Luraschi <javier@hal9.ai>"]
readme = "README.md"
Expand Down

0 comments on commit 4655e19

Please sign in to comment.