Skip to content

Commit e51bdce

Browse files
author
Jens Kürten
committed
initial
0 parents  commit e51bdce

17 files changed

+1319
-0
lines changed

.github/workflows/Push.yaml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Push
2+
3+
on:
4+
push:
5+
branches:
6+
- "*"
7+
tags-ignore:
8+
- "**"
9+
10+
jobs:
11+
# ---- Quality Checks ----
12+
pre-commit:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v3
17+
- uses: actions/setup-python@v4
18+
- uses: pre-commit/[email protected]
19+
20+
unittest:
21+
runs-on: ubuntu-latest
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
python-version: ["3.10", "3.11"]
26+
27+
steps:
28+
- uses: actions/checkout@v3
29+
- name: Set up Python ${{ matrix.python-version }}
30+
uses: actions/setup-python@v3
31+
with:
32+
python-version: ${{ matrix.python-version }}
33+
- name: Install poetry
34+
run: |
35+
pip install --upgrade pip
36+
pip install poetry
37+
- name: Setup a local virtual environment (if no poetry.toml file)
38+
run: |
39+
poetry config virtualenvs.create true --local
40+
poetry config virtualenvs.in-project true --local
41+
- name: Define a cache for the virtual environment based on the dependencies lock file
42+
uses: actions/cache@v3
43+
with:
44+
path: ./.venv
45+
key: venv-${{ hashFiles('poetry.lock') }}
46+
- name: Set up Python environment
47+
run: |
48+
poetry install --with test
49+
- name: Run Tests
50+
run: poetry run pytest --junit-xml=testresults/test-client.xml
51+
52+
test-build:
53+
# run a build, to make sure the build doesn't fail
54+
runs-on: ubuntu-latest
55+
steps:
56+
- name: Checkout Repository
57+
uses: actions/checkout@v4
58+
59+
- name: Set up Python
60+
uses: actions/setup-python@v5
61+
with:
62+
python-version: 3.11
63+
64+
- name: Install dependencies
65+
run: |
66+
python -m pip install --upgrade pip
67+
pip install poetry
68+
69+
- name: Build Package
70+
run: |
71+
poetry build

.github/workflows/Tag.yaml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Tag
2+
3+
on:
4+
push:
5+
tags:
6+
- "*"
7+
8+
jobs:
9+
# ---- Quality Checks ----
10+
pre-commit:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v3
15+
- uses: actions/setup-python@v4
16+
- uses: pre-commit/[email protected]
17+
18+
unittest:
19+
runs-on: ubuntu-latest
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
python-version: ["3.10", "3.11"]
24+
25+
steps:
26+
- uses: actions/checkout@v3
27+
- name: Set up Python ${{ matrix.python-version }}
28+
uses: actions/setup-python@v3
29+
with:
30+
python-version: ${{ matrix.python-version }}
31+
- name: Install poetry
32+
run: |
33+
pip install --upgrade pip
34+
pip install poetry
35+
- name: Setup a local virtual environment (if no poetry.toml file)
36+
run: |
37+
poetry config virtualenvs.create true --local
38+
poetry config virtualenvs.in-project true --local
39+
- name: Define a cache for the virtual environment based on the dependencies lock file
40+
uses: actions/cache@v3
41+
with:
42+
path: ./.venv
43+
key: venv-${{ hashFiles('poetry.lock') }}
44+
- name: Set up Python environment
45+
run: |
46+
poetry install --with test
47+
- name: Run Tests
48+
run: poetry run pytest --junit-xml=testresults/test-client.xml
49+
50+
# ---- Publish ----
51+
build-and-publish:
52+
runs-on: ubuntu-latest
53+
needs: ["unittest", "pre-commit"]
54+
55+
steps:
56+
- name: Checkout Repository
57+
uses: actions/checkout@v4
58+
59+
- name: Set up Python
60+
uses: actions/setup-python@v5
61+
with:
62+
python-version: 3.11
63+
64+
- name: Install dependencies
65+
run: |
66+
python -m pip install --upgrade pip
67+
pip install poetry
68+
69+
- name: Build Package
70+
run: |
71+
poetry build

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
*.log
2+
*.py[co]
3+
.coverage
4+
.coverage.*
5+
.idea/
6+
.vscode/
7+
.devcontainer/
8+
venv/
9+
dist/
10+
.pytest_cache
11+
site/

.pre-commit-config.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
exclude: ^.*migrations/versions
4+
repos:
5+
- repo: https://github.com/timothycrosley/isort
6+
rev: 5.12.0
7+
hooks:
8+
- id: isort
9+
exclude: ^.*migrations/versions
10+
args: [
11+
"--line-length=120","--profile=black"
12+
]
13+
- repo: https://github.com/ambv/black
14+
rev: 23.7.0
15+
hooks:
16+
- id: black
17+
18+
19+
- repo: https://github.com/PyCQA/flake8
20+
rev: 6.1.0
21+
hooks:
22+
- id: flake8
23+
args: [ "--max-line-length=120", "--per-file-ignores=*/__init__.py: F401"]
24+
25+
- repo: https://github.com/pre-commit/pre-commit-hooks
26+
rev: v4.4.0
27+
hooks:
28+
- id: check-added-large-files
29+
- id: check-ast
30+
- id: check-case-conflict
31+
- id: check-docstring-first
32+
- id: check-executables-have-shebangs
33+
- id: check-merge-conflict
34+
- id: debug-statements
35+
- id: detect-aws-credentials
36+
args: [ "--allow-missing-credentials" ]
37+
- id: detect-private-key
38+
- id: fix-byte-order-marker
39+
- id: end-of-file-fixer
40+
- id: mixed-line-ending
41+
- id: trailing-whitespace
42+
- repo: https://github.com/pycqa/pylint
43+
rev: v2.15.7
44+
hooks:
45+
- id: pylint
46+
args: ["--output-format", "parseable", "-d", "W0511", "-j", "4"]
47+
48+
- repo: https://github.com/PyCQA/bandit
49+
rev: 1.7.5
50+
hooks:
51+
- id: bandit

.pylintrc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[MASTER]
2+
persistent=no
3+
extension-pkg-whitelist=pydantic
4+
5+
[FORMAT]
6+
good-names = i, j, k, ex, Run, _, pk, x, y, e, db, f, dt, id
7+
8+
[MESSAGES CONTROL]
9+
10+
disable=missing-module-docstring,
11+
line-too-long,
12+
missing-function-docstring,
13+
missing-class-docstring,
14+
no-else-return,
15+
duplicate-code,
16+
import-error,
17+
too-few-public-methods,
18+
too-many-arguments,
19+
no-name-in-module

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 CONTACT Software GmbH
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<h1><a href="https://github.com/cslab/functions-sdk"><img src="https://www.contact-software.com/design/img/logo-icon.svg" width="50" alt="CONTACT Logo"></a> Functions-Client</h1>
2+
3+
This CLI tool is used for uploading and managing Functions in CIM Database Cloud.
4+
5+
Information on how build Functions can be found in the Functions-SDK documentation: https://cslab.github.io/functions-sdk-python/
6+
7+
## Requirements
8+
9+
Python 3.10+
10+
11+
## Installation
12+
13+
```console
14+
$ pip install contactsoftware-functions-client
15+
```
16+
17+
## Login
18+
Before you can create environments or deploy Functions you need to login using your client-id and secret. Obtain your client credentials via the CONTACT Portal.
19+
20+
```console
21+
$ cfc login --client-id <client_id> --client-secret <client_secret>
22+
```
23+
24+
The credentials will be stored in a configuration file. The storage location of the configuration file depends on the OS:
25+
26+
- Windows: `C:\Users\<username>\AppData\Local\Contact\cfc\config.ini`
27+
- Linux: `~/.config/cfc/config.ini`
28+
29+
30+
## Features
31+
### Manage Function environments
32+
Functions are grouped into **environments**, which are the (Docker) container the code runs in. An environment contains a runtime for its specific programming language, the Function code and a configuration file describing the environment.
33+
34+
Create a new environment:
35+
36+
```console
37+
$ cfc env create <environment_name>
38+
```
39+
40+
Display a list of all environments:
41+
42+
```console
43+
$ cfc env list
44+
```
45+
46+
Display the details of an environment:
47+
48+
```console
49+
$ cfc env describe <environment_name>
50+
```
51+
52+
53+
### Deploy Function code into an environment
54+
To deploy Function code into an existing environment run:
55+
56+
```
57+
$ cfc env deploy <environment_name>
58+
```
59+
60+
Make sure you run the command from within the directory that contains the `environment.yaml` configuration file.
61+
62+
Information on how to build Function code can be found in the documentation of the Functions-SDK: https://cslab.github.io/functions-sdk-python/

cfc/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from .app import app
2+
3+
4+
def main():
5+
app()
6+
7+
8+
if __name__ == "__main__":
9+
main()

0 commit comments

Comments
 (0)