Skip to content
This repository has been archived by the owner on Feb 25, 2024. It is now read-only.

docs: improve doc string and add issue and PR template #113

Merged
merged 4 commits into from
Apr 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
name: Bug Report
about: Create a report to help us improve
title: ''
labels: 'bug'
assignees: ''

---

**Describe the bug**
<!--- A clear and concise description of what the bug is. -->


**To Reproduce**
<!--
Steps to reproduce the issue:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
-->

**Expected behavior**
<!--- A clear and concise description of what you expected to happen. -->

**Screenshots/Logs**
<!---
If applicable, add screenshots, logs or error outputs to help explain your problem.

To give us more information for diagnosing the issue, make sure to enable debug logging for both bentoctl and BentoML:

Enable via environment variable, e.g.:
```
$ git clone git@github.com:bentoml/BentoML.git && cd bentoml
$ BENTOCTL_DEBUG=True BENTOML_DEBUG=TRUE python guides/quick-start/main.py
```

Or set debug logging in your Python code:
```python
from bentoml.configuration import set_debug_mode
set_debug_mode(True)
```

For bentoctl CLI commands, simply add the `--verbose` flag, e.g.:
```bash
bentoctl init --verbose
```

-->


**Environment:**
- OS: [e.g. MacOS 10.14.3]
- Python Version [e.g. Python 3.7.1]
- BentoML Version [e.g. BentoML-0.8.6]
- Bentoctl Version [e.g. bentoctl-0.1]


**Additional context**
<!-- Add any other context about the problem here. e.g. links to related discussion. -->
10 changes: 10 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
contact_links:
- name: Bentoctl Discussions
url: https://github.com/bentoml/bentoctl/discussions
about: Please ask general questions here.
- name: BentoML/bentoctl Slack Community
url: https://join.slack.bentoml.org
about: For connecting with others in the community
- name: BentoML/bentoctl Enterprise Support
url: contact@bentoml.ai
about: Contact the BentoML team and learn more
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature Request
about: Suggest a new feature for bentoctl
title: ''
labels: 'new feature'
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->

**Describe the solution you'd like**
<!-- A clear and concise description of what you want to happen. -->

**Describe alternatives you've considered**
<!-- A clear and concise description of any alternative solutions or features you've considered. -->

**Additional context**
<!-- Add any other context or screenshots about the feature request here. -->
43 changes: 43 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!--- Thanks for sending a pull request!

Please make sure to read the contribution guidelines, then fill out the blanks below before requesting a code review.

Name your Pull Request with one of the following prefixes, e.g. "feat: add support for PyTorch", to indicate the type of changes proposed. This is based on the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/#summary).

- feat: (new feature for the user, not a new feature for build script)
- fix: (bug fix for the user, not a fix to a build script)
- docs: (changes to the documentation)
- style: (formatting, missing semicolons, etc; no production code change)
- refactor: (refactoring production code, eg. renaming a variable)
- perf: (code changes that improve performance)
- test: (adding missing tests, refactoring tests; no production code change)
- chore: (updating grunt tasks etc; no production code change)
- build: (changes that affect the build system or external dependencies)
- ci: (changes to configuration files and scripts)
- revert: (reverts a previous commit)
-->

## Description
<!--- Describe your changes in detail -->
<!--- Attach screenshots here if appropriate. -->

## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here. -->
<!--- If it is based on a conversation in slack channel, pls quote related messages here -->

## How Has This Been Tested?
<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, and the tests you ran to -->
<!--- see how your change affects other areas of the code, etc. -->

## Checklist:
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
<!--- If you plan to update documentation or tests in follow-up, please note -->
- [ ] My code follows the bentoctl code style, both `make format` and
`make lint` script have passed
- [ ] My change reduces project test coverage and requires unit tests to be added
- [ ] I have added unit tests covering my code change
- [ ] My change requires a change to the documentation
- [ ] I have updated the documentation accordingly
3 changes: 1 addition & 2 deletions bentoctl/deployment_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def generate(self, destination_dir=os.curdir, values_only=False):

return generated_files

def create_deployable(self, overwrite_deployable=True, destination_dir=os.curdir):
def create_deployable(self, destination_dir=os.curdir):
"""
Creates the deployable in the destination_dir and returns the docker args
for building
Expand All @@ -207,7 +207,6 @@ def create_deployable(self, overwrite_deployable=True, destination_dir=os.curdir
bento_path=self.bento.path,
destination_dir=destination_dir,
bento_metadata=bento_metadata,
overwrite_deployable=overwrite_deployable,
)

return dockerfile_path, docker_context_path, build_args
Expand Down
89 changes: 81 additions & 8 deletions bentoctl/operator/operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import subprocess
import sys
from pathlib import Path
from typing import List, Tuple

from bentoctl.exceptions import (
OperatorConfigNotFound,
Expand Down Expand Up @@ -51,21 +52,93 @@ def available_templates(self):
else:
return [self.operator_config.OPERATOR_DEFAULT_TEMPLATE]

def generate(self, name, spec, template_type, destination_dir, values_only=True):
def generate(
self,
name: str,
spec: dict,
template_type: str,
destination_dir: str,
values_only: bool = True,
) -> List[str]:
"""
generates the template corresponding to the template_type.

Parameters
----------
name : str
deployment name to be used by the template. This name will be used
to create the resource names.
spec : dict
The properties of the deployment (specifications) passed from the
deployment_config's `spec` section.
template_type: str
The type of template that is to be generated by the operator. The
available ones are [terraform, cloudformation]
destination_dir: str
The directory into which the files are generated.
values_only: bool
Generate only the values files.

Returns
-------
generated_path : str
The path for the generated template.
"""
operator = self._load_operator_module()
return operator.generate(
name, spec, template_type, destination_dir, values_only
)

def create_deployable(
self, bento_path, destination_dir, bento_metadata, overwrite_deployable
):
self, bento_path: str, destination_dir: str, bento_metadata: dict
) -> Tuple[str, str, dict]:
"""
The deployable is the bento along with all the modifications (if any)
requried to deploy to the cloud service.

Parameters
----------
bento_path: str
Path to the bento from the bento store.
destination_dir: str
directory to create the deployable into.
bento_metadata: dict
metadata about the bento.

Returns
-------
dockerfile_path : str
path to the dockerfile.
docker_context_path : str
path to the docker context.
additional_build_args : dict
Any addition build arguments that need to be passed to the
docker build command
"""
operator = self._load_operator_module()
return operator.create_deployable(
bento_path, destination_dir, bento_metadata, overwrite_deployable
)

def get_registry_info(self, deployment_name, operator_spec):
return operator.create_deployable(bento_path, destination_dir, bento_metadata)

def get_registry_info(
self, deployment_name: str, operator_spec: str
) -> Tuple[str, str, str]:
"""
Get registry information from operator.

Parameters
----------
deployment_name: str
operator_spec: str
Operator specifications

Returns
-------
repository_url: str
The url of the repository that is created by the operator.
username: str
Username for docker push authentication
password: str
Password for docker push authentication
"""
operator = self._load_operator_module()
return operator.get_registry_info(deployment_name, operator_spec)

Expand Down