Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add client and operation level configurations. #63

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
21 changes: 21 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Workflows CI

on:
push:
branches: [ dev, staging, test, main, release-** ]
pull_request:
branches: [ dev, staging, test, main, release-** ]

jobs:
Unit_Tests:
name: Unit_Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup_Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Run_Unit_Tests
run: ./tests/run.sh
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
# Change Log
All notable changes to this project will be documented in this file.


## 1.7.1 - 2024-11-15
### Added
- Adding support for _x_tapis_tracking_id variable with validation. This sends the header when users call tapipy operations and specify the value in the call.

### Changed
- No change.

### Removed
- No change.


## 1.7.0 - 2024-09-13
### Added
- Poetry lock update

### Changed
- Updating specs for systems, pods, jobs, apps, notifications, globus-proxy.

### Removed
- No change.


## 1.6.3 - 2024-03-13
### Added
- Poetry lock update
Expand Down
10 changes: 5 additions & 5 deletions Dockerfile-jupyter
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
# optionally mount a directory for persistent data:
# docker run --rm -it -p 8888:8888 -v $(pwd)/notebook-data:/home/jovyan/data tapis/jupyter

from python:3.8
add requirements-jupyter.txt /requirements.txt
run pip install --upgrade pip
run pip install --upgrade setuptools
run pip install -r /requirements.txt
FROM python:3.8
ADD requirements-jupyter.txt /requirements.txt
RUN pip install --upgrade pip
RUN pip install --upgrade setuptools
RUN pip install -r /requirements.txt
ENTRYPOINT ["jupyter-notebook", "--ip", "0.0.0.0", "--allow-root"]
ENV JUPYTER_ENABLE_LAB yes
WORKDIR "/home"
Expand Down
6 changes: 4 additions & 2 deletions Dockerfile-tests
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
# docker run -it --rm -v $(pwd)/test/resource_examples:/home/tapis/resource_examples tapis/tapipy-tests bash
# docker run -it --rm --network tenants-api_tenants tapis/tapipy-tests bash

from python:3.7
FROM python:3.7

# Upgrade pip
RUN python -m pip install --upgrade pip

# Moving files
ADD tests/tapipy-tests.py /home/tapis/tapipy-tests.py
ADD tests /home/tapis/tests

# Add tapipy files and build with Poetry build.
ADD . /home/tapis/tapipy-install-dir
Expand All @@ -25,4 +26,5 @@ RUN pip install *.whl
WORKDIR /home/tapis

# Testing
ENTRYPOINT ["pytest", "--verbose", "/home/tapis/tapipy-tests.py"]
#ENTRYPOINT ["pytest", "--verbose", "/home/tapis/tapipy-tests.py"]
ENTRYPOINT [ "/home/tapis/tests/run.sh" ]
33 changes: 33 additions & 0 deletions pyproject-alpha3.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[tool.poetry]
name = "tapipy"
version = "1.6.4a3"
description = "Python lib for interacting with an instance of the Tapis API Framework"
license = "BSD-4-Clause"
authors = ["Joe Stubbs <[email protected]>"]
maintainers = ["Joe Stubbs <[email protected]>",
"Christian Garcia <[email protected]>"]
readme = "README.md"
repository = "https://github.com/tapis-project/tapipy"
include = ["tapipy/specs",
"tapipy/resources"]

[tool.poetry.dependencies]
python = "^3.8"
certifi = ">= 2020.11.8"
six = "^1.10"
python_dateutil = "^2.5.3"
setuptools = ">= 21.0.0"
urllib3 = "^1.26.5"
PyJWT = ">= 1.7.1"
openapi_core = "0.19.3"
requests = "^2.20.0"
atomicwrites = "^1.4.0"
cryptography = ">= 3.3.2"
# jsonschema from 4.0.0 -> 4.3.0 slows tapipy import to 8+ seconds.
jsonschema = "^4.18.0"
pyyaml = ">= 5.4"
cloudpickle = ">= 1.6.0"

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "tapipy"
version = "1.6.3"
version = "1.7.1"
description = "Python lib for interacting with an instance of the Tapis API Framework"
license = "BSD-4-Clause"
authors = ["Joe Stubbs <[email protected]>"]
Expand Down
2 changes: 1 addition & 1 deletion tapipy/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.6.3'
__version__ = '1.7.1'
58 changes: 58 additions & 0 deletions tapipy/configuration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
from typing import List, Union
from typing_extensions import Literal

from tapipy import errors


class Config:
def __init__(
self,
retries:int = 0,
retry_delay_sec:int = 0,
retry_on_exceptions: List[Exception] = [errors.InternalServerError],
retry_backoff_algo: str = "constant",
retry_backoff_exponent: int = 2
):
# Validate retries
if type(retries) != int or retries < 0:
raise ValueError("Configuration Error: 'retries' must be an integer >= 0")

# Set the number of permitted retries
self.retries = retries

# Validate retry_delay_sec
if type(retry_delay_sec) not in [int, float]:
raise TypeError("Configuration Error: 'retry_delay_sec' must be an integer or a float")

if retry_delay_sec < 0:
raise ValueError("Configuration Error: 'retry_delay_sec' must be >= 0")

# Set the retry delay (in seconds)
self.retry_delay_sec = retry_delay_sec

# Validate retry_on_exception. Must be a list of exception
if type(retry_on_exceptions) != list:
raise TypeError("Configuration Error: 'retry_on_execptions' must be a list of 'Execption' object")

self.retry_on_exceptions = []
i = 0
# Validate the type of each item and append to the list of exceptions
for e in retry_on_exceptions:
if not issubclass(e, Exception):
raise TypeError(f"Configuration Error: 'retry_on_execptions' must be a list of class that inherit from 'Execption'. Item at index {i} is of type '{type(e)}'")
self.retry_on_exceptions.append(e)
i += 1

# Validate the backoff algorithm. Must be in the list of valid values
backoff_algos = ["constant", "exponential"]
if retry_backoff_algo not in backoff_algos:
raise ValueError(f"Configuration Error: 'retry_backoff_algo' must be one of the following values: {backoff_algos}")

# Set the backoff algorithm to use for failed retries
self.retry_backoff_algo = retry_backoff_algo

# Validate retry_backoff_exponent
if type(retry_backoff_exponent) != int:
raise ValueError("Configuration Error: 'retry_backoff_exponent' must be an integer")

self.retry_backoff_exponent = retry_backoff_exponent
Loading
Loading