poetry-ycf-plugin


Namepoetry-ycf-plugin JSON
Version 0.2.0 PyPI version JSON
download
home_pageNone
SummaryPoetry plugin for working with Yandex Cloud Functions
upload_time2024-12-19 18:03:17
maintainerNone
docs_urlNone
authorNone
requires_python>=3.12
licenseMIT
keywords rocshers poetry git
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Poetry Yandex Cloud Functions Plugin

Poetry plugin to set package version based on git tag.

[![PyPI](https://img.shields.io/pypi/v/poetry-ycf-plugin)](https://pypi.org/project/poetry-ycf-plugin/)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/poetry-ycf-plugin)](https://pypi.org/project/poetry-ycf-plugin/)
[![GitLab last commit](https://img.shields.io/gitlab/last-commit/rocshers/python/poetry-ycf-plugin)](https://gitlab.com/rocshers/python/poetry-ycf-plugin)
[![Docs](https://img.shields.io/badge/docs-exist-blue)](https://projects.rocshers.com/open-source/poetry-ycf-plugin)

[![Test coverage](https://codecov.io/gitlab/rocshers:python/poetry-ycf-plugin/graph/badge.svg?token=3C6SLDPHUC)](https://codecov.io/gitlab/rocshers:python/poetry-ycf-plugin)
[![Downloads](https://static.pepy.tech/badge/poetry-ycf-plugin)](https://pepy.tech/project/poetry-ycf-plugin)
[![GitLab stars](https://img.shields.io/gitlab/stars/rocshers/python/poetry-ycf-plugin)](https://gitlab.com/rocshers/python/poetry-ycf-plugin)

## Functionality

- One-command deploy.
- Configure target files and dependency groups via pyproject
- Using only [`authorized_key.json`](https://yandex.cloud/docs/iam/concepts/authorization/key) for authentication.
- Deploy via ZIP and S3. [Details](https://yandex.cloud/ru/docs/functions/concepts/function).
- Setting up an `entrypoint` and `memory`

## Quick start

Install `poetry` and get [`authorized_key.json`](https://yandex.cloud/docs/iam/concepts/authorization/key)

```bash
poetry self add poetry-ycf-plugin
poetry ycf-deploy
```

## Permissions

You need to create a `service account` and give it the following roles on the `cloud` / `folder` / target `resources`.

- `functions.admin`
- `iam.serviceAccounts.accessKeyAdmin`
- `iam.serviceAccounts.user`
- `storage.admin`

## Configs

List of variables and brief description.

Supported configuration sources: `.env` files (prefixed with YCF_), `environment variables` (prefixed with YCF_), and `pyproject.toml` (under the [tool.poetry-ycf-plugin] section).

```bash
export YCF_ENTRYPOINT='test_project.entrypoint.index_entrypoint' 
# same as
echo "YCF_ENTRYPOINT=test_project.entrypoint.index_entrypoint" >> .env
# same as
[tool.poetry-ycf-plugin]
entrypoint = 'test_project.entrypoint.index_entrypoint'
```

### YCF Authorized Key

`tool.poetry-ycf-plugin.authorized_key` or `YCF_AUTHORIZED_KEY`

**Required.** String. Default: `Path('./authorized_key.json')`

The path to the [`authorized_key.json`](https://yandex.cloud/docs/iam/concepts/authorization/key) file.

### YCF Service Account ID

`tool.poetry-ycf-plugin.service_account_id` or `YCF_SERVICE_ACCOUNT_ID`

**Required.** String.

The ID of the service account used to perform operations in the cloud. The account must have access to the S3 bucket `YCF s3_bucket_name` and permissions to modify function versions `YCF id`.

### YCF Build Dependencies Groups

`tool.poetry-ycf-plugin.build_dependencies_groups` or `YCF_BUILD_DEPENDENCIES_GROUPS`

**Optional.** List of strings.

Specifies which Poetry dependency groups from `pyproject.toml`, in addition to the main group, are required for the function. All selected dependencies will be converted into `requirements.txt` and included in the build.

### YCF Build Include

`tool.poetry-ycf-plugin.build_include` or `YCF_BUILD_INCLUDE`

**Optional.** List of strings. Default: `['\*.py', '\*\*/\*.py', 'assess/\*']`

Specifies the file patterns that should be included in the build.

### YCF Build Exclude

`tool.poetry-ycf-plugin.build_exclude` or `YCF_BUILD_EXCLUDE`

**Optional.** List of strings. Default: `['\*\*/\_\_pycache\_\_/\*\*', 'tests/\*']`

Specifies the file patterns that should be excluded from `build_include` and therefore not included in the build.

For example, if `build_include` contains the pattern `*.py` and `build_exclude` contains the pattern `.*`, the file `.old_realization.py` **will not** be included in the build.

### YCF S3 Bucket Name

`tool.poetry-ycf-plugin.s3_bucket_name` or `YCF_S3_BUCKET_NAME`

**Required.** String.

The name of the S3 bucket where releases will be saved as `.zip` archives.

### YCF S3 Bucket Path

`tool.poetry-ycf-plugin.s3_bucket_path` or `YCF_S3_BUCKET_PATH`

**Optional.** String. Default: `ycf-releases`

The directory in the S3 bucket where releases will be saved as `.zip` archives.

### YCF ID

`tool.poetry-ycf-plugin.id` or `YCF_ID`

**Required.** String.

The identifier of the target function.

### YCF Entrypoint

`tool.poetry-ycf-plugin.entrypoint` or `YCF_ENTRYPOINT`

**Optional.** String. Default: `main.handler`

The entry point for the Yandex Cloud function. This variable should contain a string reference to the function that will receive the input data.

### YCF Memory

`tool.poetry-ycf-plugin.memory` or `YCF_MEMORY`

**Optional.** Number. Default: `134217728`

Specifies the amount of memory that Yandex Cloud should allocate for the function.

### YCF Runtime

`tool.poetry-ycf-plugin.runtime` or `YCF_RUNTIME`

**Optional.** String. Default: `python312`

Specifies the runtime environment.

### YCF Environment

`tool.poetry-ycf-plugin.environment` or `YCF_ENVIRONMENT`

**Optional.** `Dict[str, str]`. Default: `{}`

An array of environment variables that will be accessible from the function.

## Commands

### poetry ycf-deploy

The deployment command initiates the deployment process, which is divided into several stages. Progress updates are displayed in the console.

```bash
$ poetry ycf-deploy
poetry-ycf-plugin: Launched deploying YCF "d4e0jp3jpnbrct06fogq": new release "poetry-ycf-plugin 0.0.0"
poetry-ycf-plugin: Authorization
poetry-ycf-plugin: Building
poetry-ycf-plugin: Uploading
poetry-ycf-plugin: Releasing
poetry-ycf-plugin: Cleaning
```

VERBOSE

```bash
$ poetry ycf-deploy
poetry-ycf-plugin: Launched deploying YCF "d4e0jp3jpnbrct06fogq": new release "poetry-ycf-plugin 0.0.0"
poetry-ycf-plugin: Authorization
poetry-ycf-plugin: Authorization | Created temporary AWSAccessKey: ajero9nn021apdpgn452
poetry-ycf-plugin: Building
poetry-ycf-plugin: Building | File added: poetry_ycf_plugin/deploy_manager.py
poetry-ycf-plugin: Building | File added: poetry_ycf_plugin/responses.py
poetry-ycf-plugin: Building | File added: poetry_ycf_plugin/plugins.py
poetry-ycf-plugin: Building | File added: poetry_ycf_plugin/commands.py
poetry-ycf-plugin: Building | File added: poetry_ycf_plugin/utils.py
poetry-ycf-plugin: Building | File added: poetry_ycf_plugin/__init__.py
poetry-ycf-plugin: Building | File added: poetry_ycf_plugin/config.py
poetry-ycf-plugin: Building | File added: poetry_ycf_plugin/exceptions.py
poetry-ycf-plugin: Building | File added: temporary requirements.txt
poetry-ycf-plugin: Building | Builded zip for uploading: /{full_path}}/dist/YC/ycf-releases/d4e0jp3jpnbrct06fogq-poetry-ycf-plugin-0-0-0.zip
poetry-ycf-plugin: Uploading
poetry-ycf-plugin: Uploading | Release uploaded to S3: releases-ycf -> ycf-releases/d4e0jp3jpnbrct06fogq-poetry-ycf-plugin-0-0-0.zip
poetry-ycf-plugin: Releasing
poetry-ycf-plugin: Cleaning
poetry-ycf-plugin: Cleaning | Deleted temporary AWSAccessKey: ajero9nn021apdpgn452
```

## Use cases

### Deploying a Python Yandex Cloud Function with GitLab CI/CD

In the CI/CD settings of your repository, create a variable named `YCF_AUTHORIZED_KEY` with the type set to `File`. You can obtain this file from the service account settings in Yandex Cloud: <https://yandex.cloud/docs/iam/concepts/authorization/key>.

.gitlab-ci.yml:

```yaml
pypi:
  stage: publishing
  image: rocshers/python-poetry:3.12.4-slim-1.8.3
  tags:
    - docker
  script:
    - poetry self add poetry-ycf-plugin
    - poetry ycf-deploy
  rules:
    - if: $CI_COMMIT_TAG
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
```

## Contribute

Issue Tracker: <https://gitlab.com/rocshers/python/poetry-ycf-plugin/-/issues>  
Source Code: <https://gitlab.com/rocshers/python/poetry-ycf-plugin>

Before adding changes:

```bash
make install-dev
```

After changes:

```bash
make format test
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "poetry-ycf-plugin",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.12",
    "maintainer_email": null,
    "keywords": "rocshers, poetry, git",
    "author": null,
    "author_email": "Aleksei Marusich <aleksei.marusich@rocshers.com>",
    "download_url": "https://files.pythonhosted.org/packages/5e/d4/3aba84dfd593d1ec5e40895f0e712394575d6c8b671be54831caebea059e/poetry_ycf_plugin-0.2.0.tar.gz",
    "platform": null,
    "description": "# Poetry Yandex Cloud Functions Plugin\n\nPoetry plugin to set package version based on git tag.\n\n[![PyPI](https://img.shields.io/pypi/v/poetry-ycf-plugin)](https://pypi.org/project/poetry-ycf-plugin/)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/poetry-ycf-plugin)](https://pypi.org/project/poetry-ycf-plugin/)\n[![GitLab last commit](https://img.shields.io/gitlab/last-commit/rocshers/python/poetry-ycf-plugin)](https://gitlab.com/rocshers/python/poetry-ycf-plugin)\n[![Docs](https://img.shields.io/badge/docs-exist-blue)](https://projects.rocshers.com/open-source/poetry-ycf-plugin)\n\n[![Test coverage](https://codecov.io/gitlab/rocshers:python/poetry-ycf-plugin/graph/badge.svg?token=3C6SLDPHUC)](https://codecov.io/gitlab/rocshers:python/poetry-ycf-plugin)\n[![Downloads](https://static.pepy.tech/badge/poetry-ycf-plugin)](https://pepy.tech/project/poetry-ycf-plugin)\n[![GitLab stars](https://img.shields.io/gitlab/stars/rocshers/python/poetry-ycf-plugin)](https://gitlab.com/rocshers/python/poetry-ycf-plugin)\n\n## Functionality\n\n- One-command deploy.\n- Configure target files and dependency groups via pyproject\n- Using only [`authorized_key.json`](https://yandex.cloud/docs/iam/concepts/authorization/key) for authentication.\n- Deploy via ZIP and S3. [Details](https://yandex.cloud/ru/docs/functions/concepts/function).\n- Setting up an `entrypoint` and `memory`\n\n## Quick start\n\nInstall `poetry` and get [`authorized_key.json`](https://yandex.cloud/docs/iam/concepts/authorization/key)\n\n```bash\npoetry self add poetry-ycf-plugin\npoetry ycf-deploy\n```\n\n## Permissions\n\nYou need to create a `service account` and give it the following roles on the `cloud` / `folder` / target `resources`.\n\n- `functions.admin`\n- `iam.serviceAccounts.accessKeyAdmin`\n- `iam.serviceAccounts.user`\n- `storage.admin`\n\n## Configs\n\nList of variables and brief description.\n\nSupported configuration sources: `.env` files (prefixed with YCF_), `environment variables` (prefixed with YCF_), and `pyproject.toml` (under the [tool.poetry-ycf-plugin] section).\n\n```bash\nexport YCF_ENTRYPOINT='test_project.entrypoint.index_entrypoint' \n# same as\necho \"YCF_ENTRYPOINT=test_project.entrypoint.index_entrypoint\" >> .env\n# same as\n[tool.poetry-ycf-plugin]\nentrypoint = 'test_project.entrypoint.index_entrypoint'\n```\n\n### YCF Authorized Key\n\n`tool.poetry-ycf-plugin.authorized_key` or `YCF_AUTHORIZED_KEY`\n\n**Required.** String. Default: `Path('./authorized_key.json')`\n\nThe path to the [`authorized_key.json`](https://yandex.cloud/docs/iam/concepts/authorization/key) file.\n\n### YCF Service Account ID\n\n`tool.poetry-ycf-plugin.service_account_id` or `YCF_SERVICE_ACCOUNT_ID`\n\n**Required.** String.\n\nThe ID of the service account used to perform operations in the cloud. The account must have access to the S3 bucket `YCF s3_bucket_name` and permissions to modify function versions `YCF id`.\n\n### YCF Build Dependencies Groups\n\n`tool.poetry-ycf-plugin.build_dependencies_groups` or `YCF_BUILD_DEPENDENCIES_GROUPS`\n\n**Optional.** List of strings.\n\nSpecifies which Poetry dependency groups from `pyproject.toml`, in addition to the main group, are required for the function. All selected dependencies will be converted into `requirements.txt` and included in the build.\n\n### YCF Build Include\n\n`tool.poetry-ycf-plugin.build_include` or `YCF_BUILD_INCLUDE`\n\n**Optional.** List of strings. Default: `['\\*.py', '\\*\\*/\\*.py', 'assess/\\*']`\n\nSpecifies the file patterns that should be included in the build.\n\n### YCF Build Exclude\n\n`tool.poetry-ycf-plugin.build_exclude` or `YCF_BUILD_EXCLUDE`\n\n**Optional.** List of strings. Default: `['\\*\\*/\\_\\_pycache\\_\\_/\\*\\*', 'tests/\\*']`\n\nSpecifies the file patterns that should be excluded from `build_include` and therefore not included in the build.\n\nFor example, if `build_include` contains the pattern `*.py` and `build_exclude` contains the pattern `.*`, the file `.old_realization.py` **will not** be included in the build.\n\n### YCF S3 Bucket Name\n\n`tool.poetry-ycf-plugin.s3_bucket_name` or `YCF_S3_BUCKET_NAME`\n\n**Required.** String.\n\nThe name of the S3 bucket where releases will be saved as `.zip` archives.\n\n### YCF S3 Bucket Path\n\n`tool.poetry-ycf-plugin.s3_bucket_path` or `YCF_S3_BUCKET_PATH`\n\n**Optional.** String. Default: `ycf-releases`\n\nThe directory in the S3 bucket where releases will be saved as `.zip` archives.\n\n### YCF ID\n\n`tool.poetry-ycf-plugin.id` or `YCF_ID`\n\n**Required.** String.\n\nThe identifier of the target function.\n\n### YCF Entrypoint\n\n`tool.poetry-ycf-plugin.entrypoint` or `YCF_ENTRYPOINT`\n\n**Optional.** String. Default: `main.handler`\n\nThe entry point for the Yandex Cloud function. This variable should contain a string reference to the function that will receive the input data.\n\n### YCF Memory\n\n`tool.poetry-ycf-plugin.memory` or `YCF_MEMORY`\n\n**Optional.** Number. Default: `134217728`\n\nSpecifies the amount of memory that Yandex Cloud should allocate for the function.\n\n### YCF Runtime\n\n`tool.poetry-ycf-plugin.runtime` or `YCF_RUNTIME`\n\n**Optional.** String. Default: `python312`\n\nSpecifies the runtime environment.\n\n### YCF Environment\n\n`tool.poetry-ycf-plugin.environment` or `YCF_ENVIRONMENT`\n\n**Optional.** `Dict[str, str]`. Default: `{}`\n\nAn array of environment variables that will be accessible from the function.\n\n## Commands\n\n### poetry ycf-deploy\n\nThe deployment command initiates the deployment process, which is divided into several stages. Progress updates are displayed in the console.\n\n```bash\n$ poetry ycf-deploy\npoetry-ycf-plugin: Launched deploying YCF \"d4e0jp3jpnbrct06fogq\": new release \"poetry-ycf-plugin 0.0.0\"\npoetry-ycf-plugin: Authorization\npoetry-ycf-plugin: Building\npoetry-ycf-plugin: Uploading\npoetry-ycf-plugin: Releasing\npoetry-ycf-plugin: Cleaning\n```\n\nVERBOSE\n\n```bash\n$ poetry ycf-deploy\npoetry-ycf-plugin: Launched deploying YCF \"d4e0jp3jpnbrct06fogq\": new release \"poetry-ycf-plugin 0.0.0\"\npoetry-ycf-plugin: Authorization\npoetry-ycf-plugin: Authorization | Created temporary AWSAccessKey: ajero9nn021apdpgn452\npoetry-ycf-plugin: Building\npoetry-ycf-plugin: Building | File added: poetry_ycf_plugin/deploy_manager.py\npoetry-ycf-plugin: Building | File added: poetry_ycf_plugin/responses.py\npoetry-ycf-plugin: Building | File added: poetry_ycf_plugin/plugins.py\npoetry-ycf-plugin: Building | File added: poetry_ycf_plugin/commands.py\npoetry-ycf-plugin: Building | File added: poetry_ycf_plugin/utils.py\npoetry-ycf-plugin: Building | File added: poetry_ycf_plugin/__init__.py\npoetry-ycf-plugin: Building | File added: poetry_ycf_plugin/config.py\npoetry-ycf-plugin: Building | File added: poetry_ycf_plugin/exceptions.py\npoetry-ycf-plugin: Building | File added: temporary requirements.txt\npoetry-ycf-plugin: Building | Builded zip for uploading: /{full_path}}/dist/YC/ycf-releases/d4e0jp3jpnbrct06fogq-poetry-ycf-plugin-0-0-0.zip\npoetry-ycf-plugin: Uploading\npoetry-ycf-plugin: Uploading | Release uploaded to S3: releases-ycf -> ycf-releases/d4e0jp3jpnbrct06fogq-poetry-ycf-plugin-0-0-0.zip\npoetry-ycf-plugin: Releasing\npoetry-ycf-plugin: Cleaning\npoetry-ycf-plugin: Cleaning | Deleted temporary AWSAccessKey: ajero9nn021apdpgn452\n```\n\n## Use cases\n\n### Deploying a Python Yandex Cloud Function with GitLab CI/CD\n\nIn the CI/CD settings of your repository, create a variable named `YCF_AUTHORIZED_KEY` with the type set to `File`. You can obtain this file from the service account settings in Yandex Cloud: <https://yandex.cloud/docs/iam/concepts/authorization/key>.\n\n.gitlab-ci.yml:\n\n```yaml\npypi:\n  stage: publishing\n  image: rocshers/python-poetry:3.12.4-slim-1.8.3\n  tags:\n    - docker\n  script:\n    - poetry self add poetry-ycf-plugin\n    - poetry ycf-deploy\n  rules:\n    - if: $CI_COMMIT_TAG\n    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH\n```\n\n## Contribute\n\nIssue Tracker: <https://gitlab.com/rocshers/python/poetry-ycf-plugin/-/issues>  \nSource Code: <https://gitlab.com/rocshers/python/poetry-ycf-plugin>\n\nBefore adding changes:\n\n```bash\nmake install-dev\n```\n\nAfter changes:\n\n```bash\nmake format test\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Poetry plugin for working with Yandex Cloud Functions",
    "version": "0.2.0",
    "project_urls": {
        "Homepage": "https://projects.rocshers.com/open-source/poetry-ycf-plugin",
        "Repository": "https://gitlab.com/rocshers/python/poetry-ycf-plugin"
    },
    "split_keywords": [
        "rocshers",
        " poetry",
        " git"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "0cb96be9c9c80a22d8d72e3c32af849ef1ba1fa6e85dc546f2fb7f98d591ccb9",
                "md5": "a1ea90e33bfd7924a4d32ea50862898f",
                "sha256": "526bead4cf59fb35280b23a3ac624e5f4cfa54c7ecbba5afd26298bde4f8ced3"
            },
            "downloads": -1,
            "filename": "poetry_ycf_plugin-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a1ea90e33bfd7924a4d32ea50862898f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.12",
            "size": 10225,
            "upload_time": "2024-12-19T18:03:14",
            "upload_time_iso_8601": "2024-12-19T18:03:14.562446Z",
            "url": "https://files.pythonhosted.org/packages/0c/b9/6be9c9c80a22d8d72e3c32af849ef1ba1fa6e85dc546f2fb7f98d591ccb9/poetry_ycf_plugin-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "5ed43aba84dfd593d1ec5e40895f0e712394575d6c8b671be54831caebea059e",
                "md5": "11f4c506281cd478ef0beb541411c1b6",
                "sha256": "0ed4ee3578d5eae7556de15550eecf67175927c047b68a3f67823fa405500ce4"
            },
            "downloads": -1,
            "filename": "poetry_ycf_plugin-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "11f4c506281cd478ef0beb541411c1b6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.12",
            "size": 11811,
            "upload_time": "2024-12-19T18:03:17",
            "upload_time_iso_8601": "2024-12-19T18:03:17.338084Z",
            "url": "https://files.pythonhosted.org/packages/5e/d4/3aba84dfd593d1ec5e40895f0e712394575d6c8b671be54831caebea059e/poetry_ycf_plugin-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-19 18:03:17",
    "github": false,
    "gitlab": true,
    "bitbucket": false,
    "codeberg": false,
    "gitlab_user": "rocshers",
    "gitlab_project": "python",
    "lcname": "poetry-ycf-plugin"
}
        
Elapsed time: 0.47692s