Skip to content

Commit

Permalink
Merge branch 'main' into chore/user-agent/runtime-info
Browse files Browse the repository at this point in the history
  • Loading branch information
Filip1x9 authored Oct 31, 2024
2 parents e796ad8 + 7e62088 commit 201d472
Show file tree
Hide file tree
Showing 7 changed files with 136 additions and 66 deletions.
64 changes: 63 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ jobs:
name: Deploy to package index
runs-on: ubuntu-20.04
env:
PYTHON_VERSION: 3.9
REPOSITORY_USERNAME: ${{ secrets.PYPI_USERNAME }}
REPOSITORY_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
REPOSITORY_URL: ${{ secrets.PYPI_PUBLISH_URL }}
ANACONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
CONDA_ENV_NAME: conda-env

steps:
- name: Checkout repository
Expand All @@ -20,7 +23,14 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
python-version: ${{ env.PYTHON_VERSION }}

- name: Setup Conda
uses: conda-incubator/setup-miniconda@v3
with:
miniconda-version: "latest"
activate-environment: ${{ env.CONDA_ENV_NAME }}
python-version: ${{ env.PYTHON_VERSION }}

- name: Install Poetry
uses: snok/install-poetry@v1
Expand All @@ -37,3 +47,55 @@ jobs:
- name: Publish
run: |
poetry publish -r publish
- name: Publish to Anaconda
shell: bash -el {0}
run: |
conda install grayskull conda-build anaconda-client
conda info
conda list
grayskull --version
anaconda --version
count=0
max_retries=5
tag=${{ github.event.release.tag_name }}
version=${tag#v}
while [ $count -lt $max_retries ]; do
# Create meta.yaml recipe for the package pulled from PyPi
grayskull pypi fds.sdk.utils==${version}
if [ -f ./fds.sdk.utils/meta.yaml ]; then
echo "Version ${version} of fds.sdk.utils is available on PyPI."
# Modify the meta.yaml recipe-maintainers property to include all maintainers of this repo
sed -i "/recipe-maintainers:/,/extra:/ s/- .*/- gdulafactset/" fds.sdk.utils/meta.yaml
echo " - mima0815" >> fds.sdk.utils/meta.yaml
echo " - eschmidtfds" >> fds.sdk.utils/meta.yaml
echo " - Filip1x9" >> fds.sdk.utils/meta.yaml
echo " - dgawande12" >> fds.sdk.utils/meta.yaml
# Modify meta.yaml to include description and dev_url
sed -i "/about:/a \\
dev_url: \"https://github.com/factset/enterprise-sdk-utils-python\"\\
description: \"This repository contains a collection of utilities that supports FactSet's SDK in Python and facilitate usage of FactSet APIs.\"
" "fds.sdk.utils/meta.yaml"
# Build conda package
conda config --set anaconda_upload no
package_file=$(conda build fds.sdk.utils --output)
conda build -c conda-forge fds.sdk.utils
anaconda -t $ANACONDA_TOKEN upload -u factset -l main ${package_file}
break
else
echo "Version ${version} not found, rechecking in $((2 ** count)) seconds..."
sleep $((2 ** count))
count=$((count + 1))
fi
done
if [ $count -eq $max_retries ]; then
echo "Maximum retries reached, package with that version was not found, publish failed."
exit 1
fi
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# FactSet SDK Utilities for Python

[![PyPi](https://img.shields.io/pypi/v/fds.sdk.utils)](https://pypi.org/project/fds.sdk.utils/)
[![Anaconda-Server Badge](https://anaconda.org/factset/fds.sdk.utils/badges/version.svg)](https://anaconda.org/factset/fds.sdk.utils)
[![Apache-2 license](https://img.shields.io/badge/license-Apache2-brightgreen.svg)](https://www.apache.org/licenses/LICENSE-2.0)

This repository contains a collection of utilities that supports FactSet's SDK in Python and facilitate usage of FactSet
Expand All @@ -22,6 +23,12 @@ poetry add fds.sdk.utils
pip install fds.sdk.utils
```

### Conda

```sh
conda install factset::fds.sdk.utils
```

## Usage

This library contains multiple modules, sample usage of each module is below.
Expand Down
116 changes: 58 additions & 58 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ python = "^3.8.0"
requests-oauthlib = "^2.0.0"
requests = "^2.28.2"
oauthlib = "^3.2.2"
joserfc = ">=0.9,<0.11"
joserfc = ">=0.9,<0.12"

[tool.poetry.dev-dependencies]
pytest = "^8.2.0"
pytest = "^8.2.2"
black = "^24.4.2"
pytest-cov = "^5.0.0"
pytest-mock = "^3.11.1"
tox = "^4.8.0"
tox = "^4.20.0"
tox-gh-actions = "^3.2.0"

[tool.black]
Expand Down
2 changes: 1 addition & 1 deletion src/fds/sdk/utils/authentication/confidential.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def _is_cached_token_valid(self) -> bool:
if not self._cached_token:
log.debug("Access Token cache is empty")
return False
if time.time() < self._cached_token[CONSTS.TOKEN_EXPIRES_AT]:
if time.time() < self._cached_token[CONSTS.TOKEN_EXPIRES_AT] - CONSTS.TOKEN_EXPIRY_OFFSET_SECS:
return True
else:
log.debug("Cached access token has expired at %s", self._cached_token[CONSTS.TOKEN_EXPIRES_AT])
Expand Down
Loading

0 comments on commit 201d472

Please sign in to comment.