-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from aitomatic/feat/init_cli_code
Create some basic files for CLI project
- Loading branch information
Showing
11 changed files
with
199 additions
and
2 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,3 +127,5 @@ dmypy.json | |
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
.DS_Store |
Validating CODEOWNERS rules …
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,5 @@ | ||
# These owners will be the default owners for everything in | ||
# the repo. Unless a later match takes precedence, | ||
# following users will be requested for | ||
# review when someone opens a pull request. | ||
* @phamhoangtuan @phanhongan |
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,89 @@ | ||
# Guide to contribute to this repository | ||
|
||
## Prerequisite | ||
|
||
1. python3 | ||
2. pip | ||
3. virtualenv | ||
```shell | ||
pip install virtualenv | ||
``` | ||
|
||
## Steps to setup dev environment | ||
|
||
1. Create a python3 virtual environment | ||
```shell | ||
virtualenv .venv -p python3 | ||
``` | ||
2. Activate the virtual environment created in step 1 | ||
```shell | ||
source .venv/bin/activate | ||
``` | ||
3. Install `setuptools` to package code and `black` to format python code | ||
```shell | ||
pip install setuptools black | ||
``` | ||
4. Install libraries in file requirements.txt | ||
```shell | ||
pip install -r requirements.txt | ||
``` | ||
|
||
## Steps to test code in local | ||
|
||
1. Run `black` command to format code | ||
```shell | ||
black -S . | ||
``` | ||
2. Run command to test script | ||
```shell | ||
python src/aitomatic.py | ||
``` | ||
|
||
## Steps to install the CLI to virtual environment and test it | ||
|
||
1. Run command to install CLI | ||
```shell | ||
pip install -e . | ||
``` | ||
2. Verify the CLI | ||
```shell | ||
which aitomatic | ||
``` | ||
3. Run `aitomatic` command | ||
```shell | ||
aitomatic | ||
``` | ||
|
||
## Steps to package and distribute CLI to TestPyPI | ||
|
||
1. Install `build` to generate distribution packages and `twine` to distribute package to PyPI | ||
```shell | ||
pip install build twine | ||
``` | ||
2. Run `build` command as the root folder, where file `pyproject.toml` is located | ||
```shell | ||
python -m build | ||
``` | ||
After that command, we will have `tar.gz` and `.whl` files in `dist` folder | ||
|
||
3. Register an account in TestPyPI and create an API token with `Entire account` scope | ||
4. Using twine to upload the distribution packages created in step 2 to TestPyPI | ||
```shell | ||
twine upload --repository testpypi --skip-existing dist/* | ||
``` | ||
`--repository` used to choose upload to PyPI or TestPyPI, `--skip-existing` if we want to distribute further versions of the cli. | ||
|
||
You will be prompted for a username and password. For the username, use __token__. For the password, use the token value, including the pypi- prefix. | ||
5. Using another virtual environment and install the `aitomatic-cli` using pip to verify that it works | ||
```shell | ||
deactivate | ||
virtualenv .venv-test -p python3 | ||
source .venv-test/bin/activate | ||
pip install -i https://test.pypi.org/simple/ aitomatic-cli | ||
``` | ||
|
||
## Steps to package and distribute CLI to PyPI | ||
|
||
Similar to steps to distribute to TestPyPI, except: | ||
- Don't need to specify `--repository` when running twine command | ||
- Don't need to specify `-i` when running pip install command |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Aitomatic | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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 @@ | ||
include LICENSE |
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 |
---|---|---|
@@ -1,2 +1,24 @@ | ||
# cli | ||
Aitomatic CLI | ||
# Aitomatic CLI | ||
|
||
The Command Line Interface (CLI) to create a project, build an image or deploy apps to Aitomatic cloud. | ||
|
||
## Prerequisite | ||
|
||
1. python3 | ||
2. pip | ||
|
||
## Installing | ||
|
||
To install this CLI tool you can run the below command | ||
```shell | ||
pip3 install aitomatic-cli | ||
``` | ||
Alternatively, you clone this repo and then run this command from within the repository folder | ||
```shell | ||
pip3 install . | ||
``` | ||
Both the above commands would install the package globally and `aitomatic` will be available on your system. | ||
|
||
## How to use | ||
|
||
## Feedback |
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,3 @@ | ||
[build-system] | ||
requires = ["setuptools>=60"] | ||
build-backend = "setuptools.build_meta" |
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 @@ | ||
click >= 8.0.4 # library to create CLI |
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,27 @@ | ||
[metadata] | ||
name = aitomatic-cli | ||
version = 0.1.1 | ||
author = Pham Hoang Tuan | ||
author_email = [email protected] | ||
description = aitomatic CLI to manage projects and apps | ||
long_description = file: README.md | ||
long_description_content_type = text/markdown | ||
url = https://github.com/aitomatic/aitomatic-cli | ||
project_urls = | ||
Bug Tracker = https://github.com/aitomatic/aitomatic-cli/issues | ||
classifiers = | ||
Programming Language :: Python :: 3.8 | ||
License :: OSI Approved :: MIT License | ||
Operating System :: OS Independent | ||
|
||
[options] | ||
packages = | ||
src | ||
src.app | ||
install_requires = | ||
click >= 8.0.4 | ||
python_requires = >=3.7 | ||
|
||
[options.entry_points] | ||
console_scripts = | ||
aitomatic = src.aitomatic:aitomatic_cli |
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,21 @@ | ||
import click | ||
from src.app.deploy import deploy | ||
|
||
|
||
@click.group(help=''' | ||
Aitomatic CLI tool to help manage aitomatic projects and apps | ||
''') | ||
def aitomatic_cli(): | ||
pass | ||
|
||
|
||
@aitomatic_cli.group(help=''' | ||
CLI sub-command to help manage aitomatic apps | ||
''') | ||
def app(): | ||
pass | ||
|
||
app.add_command(deploy) | ||
|
||
if __name__ == '__main__': | ||
aitomatic_cli() |
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,5 @@ | ||
import click | ||
|
||
@click.command() | ||
def deploy(): | ||
click.echo('Deploy app to Aitomatic') |