diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..118ea4b --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @heiruwu diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000..58566c1 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,121 @@ +# Contributing Guidelines + +We appreciate your contribution to this amazing project! Any form of engagement is welcome, including but not limiting to + +- feature request +- documentation wording +- bug report +- roadmap suggestion +- ...and so on! + +Please refer to the [community contributing section](https://github.com/instill-ai/community#contributing) for more details. + +## Development and codebase contribution + +Before delving into the details to come up with your first PR, please familiarise yourself with the project structure of [Instill Core](https://github.com/instill-ai/community#instill-core). + +### Setup + +#### Requirements + +- Make: + - macOS: `$ xcode-select --install` + - Linux: [https://www.gnu.org](https://www.gnu.org/software/make) +- Python: + - `$ conda create -n sdk python=3.X` [https://docs.conda.io/projects/miniconda/en/latest/](https://docs.conda.io/projects/miniconda/en/latest/miniconda-install.html) +- Poetry: [https://python-poetry.org](https://python-poetry.org/docs/#installation) + +To confirm these system dependencies are configured correctly: + +```text +$ make doctor +``` + +#### Installation + +Install project dependencies into a virtual environment: + +```text +$ make install +``` + +### Development Tasks + +#### Manual + +Run the tests: + +```text +$ make test +``` + +Run static analysis: + +```text +$ make check +``` + +Build the documentation: + +```text +$ make docs +``` + +#### Automatic + +Keep all of the above tasks running on change: + +```text +$ make dev +``` + +> In order to have OS X notifications, `brew install terminal-notifier`. + +#### Continuous Integration + +The CI server will report overall build status: + +```text +$ make all +``` + +### Demo Tasks + +Run the program: + +```text +$ make run +``` + +Launch an IPython session: + +```text +$ make shell +``` + +### Release Tasks + +Release to PyPI: + +```text +$ make upload +``` + +### Sending PRs + +Please take these general guidelines into consideration when you are sending a PR: + +1. **Fork the Repository:** Begin by forking the repository to your GitHub account. +2. **Create a New Branch:** Create a new branch to house your work. Use a clear and descriptive name, like `/`. +3. **Make and Commit Changes:** Implement your changes and commit them. We encourage you to follow these best practices for commits to ensure an efficient review process: + - Adhere to the [conventional commits guidelines](https://www.conventionalcommits.org/) for meaningful commit messages. + - Follow the [7 rules of commit messages](https://chris.beams.io/posts/git-commit/) for well-structured and informative commits. + - Rearrange commits to squash trivial changes together, if possible. Utilize [git rebase](http://gitready.com/advanced/2009/03/20/reorder-commits-with-rebase.html) for this purpose. +4. **Push to Your Branch:** Push your branch to your GitHub repository: `git push origin feat/`. +5. **Open a Pull Request:** Initiate a pull request to our repository. Our team will review your changes and collaborate with you on any necessary refinements. + +When you are ready to send a PR, we recommend you to first open a `draft` one. This will trigger a bunch of `integration-test` [workflows](https://github.com/instill-ai/model/tree/main/.github/workflows) running a thorough test suite on multiple platforms. After the tests are done and passed, you can now mark the PR `open` to notify the codebase owners to review. We appreciate your endeavour to pass the integration test for your PR to make sure the sanity with respect to the entire scope of **Instill Core**. + +## Last words + +Your contributions make a difference. Let's build something amazing together! diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 0000000..b709aec --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,2 @@ +🗿 instill-base: + - "**" diff --git a/.github/workflows/add-label-to-pr.yml b/.github/workflows/add-label-to-pr.yml new file mode 100644 index 0000000..5c09272 --- /dev/null +++ b/.github/workflows/add-label-to-pr.yml @@ -0,0 +1,13 @@ +name: Add Label to PR + +on: + pull_request_target: + types: + - opened + - synchronize + +jobs: + triage: + uses: instill-ai/.github/.github/workflows/add-label-to-pr.yml@main + secrets: + botGitHubToken: ${{ secrets.botGitHubToken }} diff --git a/.github/workflows/add-pr-to-prj.yml b/.github/workflows/add-pr-to-prj.yml new file mode 100644 index 0000000..ff338ef --- /dev/null +++ b/.github/workflows/add-pr-to-prj.yml @@ -0,0 +1,14 @@ +name: Add PR to Project + +on: + pull_request_target: + types: + - opened + +jobs: + track_pr: + uses: instill-ai/.github/.github/workflows/add-to-prj.yml@main + with: + project_number: 5 + secrets: + botGitHubToken: ${{ secrets.botGitHubToken }} diff --git a/.tool-versions b/.tool-versions deleted file mode 100644 index b540e10..0000000 --- a/.tool-versions +++ /dev/null @@ -1,2 +0,0 @@ -python 3.11.3 -poetry 1.5.1 diff --git a/.verchew.ini b/.verchew.ini index 8b55ea7..c01f7c3 100644 --- a/.verchew.ini +++ b/.verchew.ini @@ -12,11 +12,3 @@ version = 3 cli = poetry version = 1 - -[Graphviz] - -cli = dot -cli_version_arg = -V -version = 7 || 8 -optional = true -message = This is only needed to generate UML diagrams for documentation. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index dbf0236..0000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,93 +0,0 @@ -# Contributor Guide - -## Setup - -### Requirements - -* Make: - - macOS: `$ xcode-select --install` - - Linux: [https://www.gnu.org](https://www.gnu.org/software/make) - - Windows: `$ choco install make` [https://chocolatey.org](https://chocolatey.org/install) -* Python: `$ asdf install` (https://asdf-vm.com)[https://asdf-vm.com/guide/getting-started.html] -* Poetry: [https://python-poetry.org](https://python-poetry.org/docs/#installation) -* Graphviz: - * macOS: `$ brew install graphviz` - * Linux: [https://graphviz.org/download](https://graphviz.org/download/) - * Windows: [https://graphviz.org/download](https://graphviz.org/download/) - -To confirm these system dependencies are configured correctly: - -```text -$ make bootstrap -$ make doctor -``` - -### Installation - -Install project dependencies into a virtual environment: - -```text -$ make install -``` - -## Development Tasks - -### Manual - -Run the tests: - -```text -$ make test -``` - -Run static analysis: - -```text -$ make check -``` - -Build the documentation: - -```text -$ make docs -``` - -### Automatic - -Keep all of the above tasks running on change: - -```text -$ make dev -``` - -> In order to have OS X notifications, `brew install terminal-notifier`. - -### Continuous Integration - -The CI server will report overall build status: - -```text -$ make all -``` - -## Demo Tasks - -Run the program: - -```text -$ make run -``` - -Launch an IPython session: - -```text -$ make shell -``` - -## Release Tasks - -Release to PyPI: - -```text -$ make upload -``` diff --git a/Makefile b/Makefile index eea8881..fdda0cf 100644 --- a/Makefile +++ b/Makefile @@ -13,12 +13,6 @@ dev: install .clean-test ## Continuously run CI tasks when files chanage # SYSTEM DEPENDENCIES ######################################################### -.PHONY: bootstrap -bootstrap: ## Attempt to install system dependencies - asdf plugin add python || asdf plugin update python - asdf plugin add poetry || asdf plugin update poetry - asdf install - .PHONY: doctor doctor: ## Confirm system dependencies are available bin/verchew @@ -117,7 +111,7 @@ endif MKDOCS_INDEX := site/index.html .PHONY: docs -docs: mkdocs uml ## Generate documentation and UML +docs: mkdocs ## Generate documentation ifndef CI @ eval "sleep 3; open http://127.0.0.1:8000" & poetry run mkdocs serve @@ -129,7 +123,7 @@ $(MKDOCS_INDEX): docs/requirements.txt mkdocs.yml docs/*.md @ mkdir -p docs/about @ cd docs && ln -sf ../README.md index.md @ cd docs/about && ln -sf ../../CHANGELOG.md changelog.md - @ cd docs/about && ln -sf ../../CONTRIBUTING.md contributing.md + @ cd docs/about && ln -sf ../../.github/CONTRIBUTING.md contributing.md @ cd docs/about && ln -sf ../../LICENSE.md license.md poetry run mkdocs build --clean --strict @@ -138,13 +132,6 @@ docs/requirements.txt: poetry.lock @ poetry export --with dev --without-hashes | grep pygments >> $@ @ poetry export --with dev --without-hashes | grep jinja2 >> $@ -.PHONY: uml -uml: install docs/*.png -docs/*.png: $(MODULES) - poetry run pyreverse $(PACKAGE) -p $(PACKAGE) -a 1 -f ALL -o png --ignore tests - - mv -f classes_$(PACKAGE).png docs/classes.png - - mv -f packages_$(PACKAGE).png docs/packages.png - # DEMO ######################################################################## .PHONY: run diff --git a/README.md b/README.md index cccaa40..6ec2088 100644 --- a/README.md +++ b/README.md @@ -8,24 +8,28 @@ python sdk for Instill AI products [![PyPI Version](https://img.shields.io/pypi/v/instill-python-sdk.svg)](https://pypi.org/project/instill-python-sdk) [![PyPI Downloads](https://img.shields.io/pypi/dm/instill-python-sdk.svg?color=orange)](https://pypistats.org/packages/instill-python-sdk) +> :exclamation: **This SDK tool is under heavy development!!** +> Currently there is no official wheel on `pypi`, and documentation on how to setup and tutorials will be available soon.Stay tuned! +> For now, you can refer to the `Contributing Guidelines` to setup a development environment + ## Setup ### Requirements -* Python 3.8+ +- Python 3.8+ ### Installation Install it directly into an activated virtual environment: ```text -$ pip install instill-python-sdk +$ pip install instill-sdk ``` or add it to your [Poetry](https://poetry.eustace.io/) project: ```text -$ poetry add instill-python-sdk +$ poetry add instill-sdk ``` ## Usage @@ -37,4 +41,9 @@ $ python >>> import instill_sdk >>> instill_sdk.__version__ ``` + ### You can find a [_notebook example_](notebooks/model_usage.ipynb) here + +## Contributing + +Please refer to the [Contributing Guidelines](./.github/CONTRIBUTING.md) for more details. diff --git a/docs/about/contributing.md b/docs/about/contributing.md index f939e75..9518123 120000 --- a/docs/about/contributing.md +++ b/docs/about/contributing.md @@ -1 +1 @@ -../../CONTRIBUTING.md \ No newline at end of file +../../.github/CONTRIBUTING.md \ No newline at end of file diff --git a/instill_sdk/tests/test_client.py b/instill_sdk/tests/test_client.py index c821ff6..aca3236 100644 --- a/instill_sdk/tests/test_client.py +++ b/instill_sdk/tests/test_client.py @@ -1,14 +1,59 @@ -"""Sample unit test module using pytest-describe and expecter.""" -# pylint: disable=no-name-in-module,unused-variable,expression-not-assigned -from instill_sdk.clients import MgmtClient +# pylint: disable=redefined-outer-name,unused-variable,expression-not-assigned,no-name-in-module +from collections import defaultdict -def set_and_get_instance_to_client(): - def when_set(expect): - test_client = MgmtClient() - test_client.instance = "test" - expect(test_client.instance) == "test" +from instill_sdk.clients import ConnectorClient, MgmtClient, ModelClient, PipelineClient - def when_not_set(expect): - test_client = MgmtClient() - expect(test_client.instance) == "default" + +def describe_client(): + def describe_instance(): + def when_not_set(expect): + mgmt_client = MgmtClient() + expect(mgmt_client.instance) == "default" + model_client = ModelClient(namespace="") + expect(model_client.instance) == "default" + pipeline_client = PipelineClient(namespace="") + expect(pipeline_client.instance) == "default" + connector_client = ConnectorClient(namespace="") + expect(connector_client.instance) == "default" + + def when_set_correct_type(expect): + mgmt_client = MgmtClient() + mgmt_client.instance = "staging" + expect(mgmt_client.instance) == "staging" + model_client = ModelClient(namespace="") + model_client.instance = "staging" + expect(model_client.instance) == "staging" + pipeline_client = PipelineClient(namespace="") + pipeline_client.instance = "staging" + expect(pipeline_client.instance) == "staging" + connector_client = ConnectorClient(namespace="") + connector_client.instance = "staging" + expect(connector_client.instance) == "staging" + + def describe_host(): + def when_not_set(expect): + mgmt_client = MgmtClient() + expect(mgmt_client.hosts) is None + model_client = ModelClient(namespace="") + expect(model_client.hosts) is None + pipeline_client = PipelineClient(namespace="") + expect(pipeline_client.hosts) is None + connector_client = ConnectorClient(namespace="") + expect(connector_client.hosts) is None + + def when_set_correct_type(expect): + mgmt_client = MgmtClient() + d = defaultdict(dict) # type: ignore + d["test_instance"] = dict({"url": "test_url"}) + mgmt_client.hosts = d + expect(mgmt_client.hosts["test_instance"]["url"]) == "test_url" + model_client = ModelClient(namespace="") + model_client.hosts = d + expect(model_client.hosts["test_instance"]["url"]) == "test_url" + pipeline_client = PipelineClient(namespace="") + pipeline_client.hosts = d + expect(pipeline_client.hosts["test_instance"]["url"]) == "test_url" + connector_client = ConnectorClient(namespace="") + connector_client.hosts = d + expect(connector_client.hosts["test_instance"]["url"]) == "test_url" diff --git a/pyproject.toml b/pyproject.toml index 1b7d314..e356c36 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,14 +14,13 @@ homepage = "https://pypi.org/project/instill-sdk" documentation = "https://instill-sdk.readthedocs.io" repository = "https://github.com/instill-ai/python-sdk" -keywords = [ -] +keywords = [] classifiers = [ - "Development Status :: 1 - Planning", - "Natural Language :: English", - "Operating System :: OS Independent", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", + "Development Status :: 1 - Planning", + "Natural Language :: English", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", ] [tool.poetry.dependencies] @@ -41,14 +40,14 @@ types-pyyaml = "^6.0.12.11" # Formatters black = "^22.1" -tomli = "*" # missing 'black' dependency +tomli = "*" # missing 'black' dependency isort = "^5.10" # Linters mypy = "^1.0" pydocstyle = "^6.1" pylint = "~2.15" -wrapt = "*" # missing 'pylint' dependency +wrapt = "*" # missing 'pylint' dependency # Testing pytest = "^7.3" @@ -117,6 +116,11 @@ cache_dir = ".cache/mypy/" [tool.pytest.ini_options] +filterwarnings = [ + "ignore:::.*google", + "ignore:::.*pkg_resources*", +] + addopts = """ --strict-markers