Skip to content

Commit

Permalink
added initial poetry files
Browse files Browse the repository at this point in the history
linked docs/development.md as README.md, required for build/realease

moved yapf to dev dependencies (from production), added toml for yapf to parse pyproject.toml

removed requirements.txt

modified run_tests.sh to use poetry

required tools from non-slim docker image

use bash to utilize alias commands
  • Loading branch information
dashdanw committed Dec 10, 2022
1 parent bc36f9c commit b292d49
Show file tree
Hide file tree
Showing 6 changed files with 501 additions and 17 deletions.
1 change: 1 addition & 0 deletions README.md
4 changes: 2 additions & 2 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
steps:
- id: api_python
name: python:3.7-slim
entrypoint: /bin/sh
name: python:3.7
entrypoint: /bin/bash
args:
- -c
- "./run_tests.sh -p"
463 changes: 463 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[tool.poetry]
name = "datacommons"
version = "1.4.3"
description = "Python client library to access Data Commons"
authors = ["Prashanth R <pradh@dev>"]
license = "Apache-2.0"
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.7.1"
requests = "^2.28.1"
typing-extensions = "^4.4.0"
pandas = "^1.2.2"

[tool.poetry.group.dev.dependencies]
mock = "^4.0.3"
pytest = "^7.2.0"
toml = "^0.10.2"
yapf = "^0.32.0"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
6 changes: 0 additions & 6 deletions requirements.txt

This file was deleted.

21 changes: 12 additions & 9 deletions run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.

function setup_python {
python3 -m venv .env
source .env/bin/activate
pip install --upgrade pip
pip3 install -r requirements.txt -q
function setup_poetry {
export PATH="$HOME/.local/bin:$PATH"
alias pyrun='poetry run python3 -m'

if ! which poetry; then
curl -sSL https://install.python-poetry.org | python
fi
poetry install
}

function run_py_test {
setup_python
python3 -m pytest -vv
setup_poetry
pyrun pytest -vv
echo -e "#### Checking Python style"
if ! yapf --recursive --diff --style='{based_on_style: google, indent_width: 2}' -p datacommons/ datacommons_pandas/; then
if ! pyrun yapf --recursive --diff --style='{based_on_style: google, indent_width: 2}' -p datacommons/ datacommons_pandas/; then
echo "Fix lint errors by running: ./run_test.sh -f"
exit 1
fi
Expand Down Expand Up @@ -67,4 +70,4 @@ done
if [ $OPTIND -eq 1 ]
then
help
fi
fi

0 comments on commit b292d49

Please sign in to comment.