From 51fd3c695eb865c54c65c79733facc5a5ca606e8 Mon Sep 17 00:00:00 2001 From: gautamomento Date: Mon, 25 Oct 2021 14:26:48 -0700 Subject: [PATCH 1/8] feat: Initial checkin that allows basic setup --- .gitignore | 11 +++++++++++ README.md | 4 ++++ prepare_env.sh | 3 +++ pyproject.toml | 6 ++++++ requirements.txt | 10 ++++++++++ setup.cfg | 15 +++++++++++++++ setup.py | 13 +++++++++++++ src/momento_sdk/__init__.py | 0 src/momento_sdk/momento.py | 13 +++++++++++++ 9 files changed, 75 insertions(+) create mode 100644 .gitignore create mode 100755 prepare_env.sh create mode 100644 pyproject.toml create mode 100644 requirements.txt create mode 100644 setup.cfg create mode 100644 setup.py create mode 100644 src/momento_sdk/__init__.py create mode 100644 src/momento_sdk/momento.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..d93d06ff --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +# Compiled python modules. +src/*.pyc + +# Setuptools distribution folder. +/dist/ + +# Python egg metadata, regenerated from source files by setuptools. +src/*.egg-info + +# Don't checkin the virtual environemnt +client_sdk_python_env diff --git a/README.md b/README.md index 577fd9db..e921226c 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,6 @@ # client-sdk-python Python SDK for Momento + +# Requirements +* Python 3 +* Virual environment setup [https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/#installing-virtualenv] diff --git a/prepare_env.sh b/prepare_env.sh new file mode 100755 index 00000000..59987a72 --- /dev/null +++ b/prepare_env.sh @@ -0,0 +1,3 @@ +python3 -m venv client_sdk_python_env +source client_sdk_python_env/bin/activate +pip install -e . --extra-index-url https://momento.jfrog.io/artifactory/api/pypi/pypi-public/simple diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..374b58cb --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,6 @@ +[build-system] +requires = [ + "setuptools>=42", + "wheel" +] +build-backend = "setuptools.build_meta" diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..23a49f6c --- /dev/null +++ b/requirements.txt @@ -0,0 +1,10 @@ +# requirements.txt is required to debug/run sdk locally. Pip needs requirements +# that must be installed to proceed. +# +# Since, SDK will be distributed via PyPi it is needed to provide installation +# requirements in setup.cfg. +# +# Instead of maintaining two different requirements, use setup.cfg as the +# primary source. Hence a '.' is provided here which signals pip to use +# dependencies from setup.cfg +. \ No newline at end of file diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 00000000..b0d073bd --- /dev/null +++ b/setup.cfg @@ -0,0 +1,15 @@ +[metadata] +name = momento-sdk + +[options] +package_dir = + = src +packages = find: +python_requires = >=3.6 +install_requires = + momento-wire-types==0.3.0 + build + setuptools + +[options.packages.find] +where = src diff --git a/setup.py b/setup.py new file mode 100644 index 00000000..2a836a9c --- /dev/null +++ b/setup.py @@ -0,0 +1,13 @@ +import setuptools +import os +import time + +version = os.getenv("PYPI_MOMENTO_WIRE_TYPE_VERSION") + +if [version == None]: + version = '0.0.dev' + +# version is the only dynamic configuration +setuptools.setup( + version=version, +) diff --git a/src/momento_sdk/__init__.py b/src/momento_sdk/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/momento_sdk/momento.py b/src/momento_sdk/momento.py new file mode 100644 index 00000000..77e0e162 --- /dev/null +++ b/src/momento_sdk/momento.py @@ -0,0 +1,13 @@ +import momento_wire_types.controlclient_pb2 as control_client + +class Momento: + def __init__(self, auth_token, endpoint_override=None): + self.__auth_token__ = auth_token + self.__endpoint_override = endpoint_override + + def create_cache(self, cache_name): + print("hello") + + +def init(auth_token): + return Momento(auth_token=auth_token) \ No newline at end of file From 046739c87786c5d74658a49f3af021bf8c09e3cc Mon Sep 17 00:00:00 2001 From: gautamomento Date: Mon, 25 Oct 2021 14:31:37 -0700 Subject: [PATCH 2/8] Update README --- README.md | 11 ++++++++++- prepare_env.sh => prepare_local_env.sh | 0 2 files changed, 10 insertions(+), 1 deletion(-) rename prepare_env.sh => prepare_local_env.sh (100%) diff --git a/README.md b/README.md index e921226c..d57223fe 100644 --- a/README.md +++ b/README.md @@ -3,4 +3,13 @@ Python SDK for Momento # Requirements * Python 3 -* Virual environment setup [https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/#installing-virtualenv] +* [Virual environment setup](https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/#installing-virtualenv) + +# Setup pre-requisites +`./prepare_env.sh` +The script creates a python virtual environment and install dependencies + +## Setting up IDE +### Visual Studio Code +Use `Cmd` + `Shift` + `P` to search for `Python: Interpreter` and select: +`./client_sdk_python_env/bin/python` \ No newline at end of file diff --git a/prepare_env.sh b/prepare_local_env.sh similarity index 100% rename from prepare_env.sh rename to prepare_local_env.sh From f993167b48e9af5991b958bf9dc4db181f2c9e4d Mon Sep 17 00:00:00 2001 From: gautamomento Date: Mon, 25 Oct 2021 14:35:13 -0700 Subject: [PATCH 3/8] add pull request workflow --- .github/workflows/pull_request.yml | 36 ++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/pull_request.yml diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml new file mode 100644 index 00000000..7caf33e8 --- /dev/null +++ b/.github/workflows/pull_request.yml @@ -0,0 +1,36 @@ +name: On pull request + +on: + pull_request: + branches: [ main ] + +jobs: + build_python: + runs-on: ubuntu-latest + + steps: + - name: Get current time + uses: gerred/actions/current-time@master + id: current-time + + - uses: actions/checkout@v2 + + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Install python dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel build + + - name: Build package + run: | + set -e + set -x + export PYPI_MOMENTO_WIRE_TYPE_VERSION=0.0.devBuild + pushd python + python -m build + popd + shell: bash From 405d72242b301639f473eb6a10a50fc9d992df3d Mon Sep 17 00:00:00 2001 From: gautamomento Date: Mon, 25 Oct 2021 14:37:20 -0700 Subject: [PATCH 4/8] fix syntax error --- .github/workflows/pull_request.yml | 46 +++++++++++++++--------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 7caf33e8..bc90bd20 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -6,31 +6,31 @@ on: jobs: build_python: - runs-on: ubuntu-latest + runs-on: ubuntu-latest - steps: - - name: Get current time - uses: gerred/actions/current-time@master - id: current-time + steps: + - name: Get current time + uses: gerred/actions/current-time@master + id: current-time - - uses: actions/checkout@v2 + - uses: actions/checkout@v2 - - name: Setup Python - uses: actions/setup-python@v2 - with: - python-version: '3.x' + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' - - name: Install python dependencies - run: | - python -m pip install --upgrade pip - pip install setuptools wheel build + - name: Install python dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel build - - name: Build package - run: | - set -e - set -x - export PYPI_MOMENTO_WIRE_TYPE_VERSION=0.0.devBuild - pushd python - python -m build - popd - shell: bash + - name: Build package + run: | + set -e + set -x + export PYPI_MOMENTO_WIRE_TYPE_VERSION=0.0.devBuild + pushd python + python -m build + popd + shell: bash From 793122c3168d32484da7856f29060e0321a33279 Mon Sep 17 00:00:00 2001 From: gautamomento Date: Mon, 25 Oct 2021 14:39:05 -0700 Subject: [PATCH 5/8] fix build --- .github/workflows/pull_request.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index bc90bd20..9be2a5fc 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -30,7 +30,5 @@ jobs: set -e set -x export PYPI_MOMENTO_WIRE_TYPE_VERSION=0.0.devBuild - pushd python - python -m build - popd + python -m build shell: bash From 6db04c89eac53371c6e724aa2a75b9925055120c Mon Sep 17 00:00:00 2001 From: gautamomento Date: Mon, 25 Oct 2021 14:44:16 -0700 Subject: [PATCH 6/8] formatting --- src/momento_sdk/momento.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/momento_sdk/momento.py b/src/momento_sdk/momento.py index 77e0e162..7cb70554 100644 --- a/src/momento_sdk/momento.py +++ b/src/momento_sdk/momento.py @@ -10,4 +10,4 @@ def create_cache(self, cache_name): def init(auth_token): - return Momento(auth_token=auth_token) \ No newline at end of file + return Momento(auth_token=auth_token) From 9d16325f0bbc0aa9dfdeb5909958c13a8c966cab Mon Sep 17 00:00:00 2001 From: gautamomento Date: Mon, 25 Oct 2021 15:03:10 -0700 Subject: [PATCH 7/8] update private variable names --- src/momento_sdk/momento.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/momento_sdk/momento.py b/src/momento_sdk/momento.py index 7cb70554..a4b91ba0 100644 --- a/src/momento_sdk/momento.py +++ b/src/momento_sdk/momento.py @@ -2,8 +2,8 @@ class Momento: def __init__(self, auth_token, endpoint_override=None): - self.__auth_token__ = auth_token - self.__endpoint_override = endpoint_override + self._auth_token__ = auth_token + self._endpoint_override = endpoint_override def create_cache(self, cache_name): print("hello") From ba1e5f38a1c3827653b08ef910fcddee496cf297 Mon Sep 17 00:00:00 2001 From: gautamomento Date: Tue, 26 Oct 2021 09:31:08 -0700 Subject: [PATCH 8/8] rename local to local_dev --- README.md | 4 ++-- prepare_local_env.sh => prepare_local_dev_env.sh | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename prepare_local_env.sh => prepare_local_dev_env.sh (100%) diff --git a/README.md b/README.md index d57223fe..1e3b9545 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,8 @@ Python SDK for Momento * [Virual environment setup](https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/#installing-virtualenv) # Setup pre-requisites -`./prepare_env.sh` -The script creates a python virtual environment and install dependencies +`./prepare_local_dev_env.sh` +The script creates a python virtual environment and installs dependencies ## Setting up IDE ### Visual Studio Code diff --git a/prepare_local_env.sh b/prepare_local_dev_env.sh similarity index 100% rename from prepare_local_env.sh rename to prepare_local_dev_env.sh