Skip to content

Commit

Permalink
Get spicepy ready for 1.0 (#49)
Browse files Browse the repository at this point in the history
* ready for 1.0

* lint

* Update version.yml

* remove ::set-output

* standardise versions

* missed one

* make pip install depend on current commit
  • Loading branch information
Jeadie authored Oct 1, 2023
1 parent 1c591ad commit 00fee63
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.10', '3.11']
python-version: ['3.8', '3.9', '3.10', '3.11']
name: Build on ${{ matrix.os }} with ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v3
Expand Down
29 changes: 3 additions & 26 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
python-version: ['3.8', '3.9', '3.10', '3.11']
name: Lint with pylint ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v3
Expand All @@ -27,33 +27,10 @@ jobs:
cache: 'pip'
- name: Install requirements
run: |
pip install -r requirements.txt
- name: Install pylint
run: |
pip install pylint
pip install ".[test]"
- name: Analysing with pylint
run: |
pylint spicepy tests
lint-flake8:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10', '3.11']
name: Lint with flake8 ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install requirements
run: |
pip install -r requirements.txt
- name: Install flake8
run: |
pip install flake8
- name: Analysing with flake8
run: |
flake8 spicepy tests
flake8 spicepy tests
15 changes: 7 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,25 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10', '3.11']
python-version: ['3.8', '3.9', '3.10', '3.11']
name: Test with pip install ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: Run pip install git+https://github.com/spiceai/spicepy
- name: Run pip install
run: |
pip install git+https://github.com/spiceai/spicepy
pip install .
pytest:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.7', '3.8', '3.9', '3.10']
python-version: ['3.8', '3.9', '3.10', '3.11']
name: Test on ${{ matrix.os }} with pytest ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v3
Expand All @@ -43,10 +45,7 @@ jobs:
cache: 'pip'
- name: Install requirements
run: |
pip install -r requirements.txt
- name: Install pytest
run: |
pip install pytest
pip install ".[test]"
- name: Running tests
env:
API_KEY: ${{ secrets.API_KEY }}
Expand Down
66 changes: 66 additions & 0 deletions .github/workflows/version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Create Tag and Draft Release with Notes

on:
push:
branches:
- trunk
paths:
- 'setup.py'
workflow_dispatch:

jobs:
check-and-extract:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get-version.outputs.version }}
tag-exists: ${{ steps.check-tag.outputs.exists }}

steps:
- name: Check out code
uses: actions/checkout@v2

- name: Extract version from setup.py
id: get-version
run: |
VERSION=$(cat setup.py | grep -E '^ +version="[0-9.]+",' | cut -d'"' -f2)
echo "Extracted version is $VERSION"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Check if tag exists
id: check-tag
run: |
if git tag | grep -q "${{ steps.get-version.outputs.version }}"; then
echo "Tag exists"
echo "exists=1" >> "$GITHUB_OUTPUT"
else
echo "Tag does not exist"
echo "exists=0" >> "$GITHUB_OUTPUT"
fi
create-tag-and-release:
needs: check-and-extract
if: needs.check-and-extract.outputs.tag-exists == '0'
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v2

- name: Create and push tag
run: |
git config --global user.name "GitHub Action"
git config --global user.email "action@github.com"
git tag ${{ needs.check-and-extract.outputs.version }}
git push origin ${{ needs.check-and-extract.outputs.version }}
- name: Install GitHub CLI
run: |
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key C99B11DEB97541F0
sudo apt-add-repository https://cli.github.com/packages
sudo apt update
sudo apt install gh
- name: Draft a new release with autogenerated notes
run: |
gh auth login --with-token <<< "${{ secrets.GITHUB_TOKEN }}"
gh release create ${{ needs.check-and-extract.outputs.version }} --title "Release ${{ needs.check-and-extract.outputs.version }}" --generate-notes --draft
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pyarrow>=12.0.1
pandas>=1.3.5
certifi==2022.12.07
pyarrow==13.0.0
pandas==2.0.3
certifi==2023.7.22
requests==2.31.0
33 changes: 31 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,50 @@

from setuptools import setup, find_packages

def parse_requirements(filename: str) -> str:
"""Load requirements from a pip requirements file."""
with open(filename, 'r') as f:
requirements = f.read().splitlines()

# Filter out comments or empty lines
requirements = [req.strip() for req in requirements if req.strip() and not req.startswith('#')]
return requirements

def parse_markdown(path: str) -> str:
with open(path, "r", encoding="utf8") as fh:
return fh.read()

def setup_package():
setup(
name="spicepy",
version="0.3.0",
version="1.0.0",
maintainer="Spice AI, Inc.",
maintainer_email="webmaster@spice.ai",
author="Spice AI, Inc.",
author_email="webmaster@spice.ai",
url="https://github.com/spiceai/spicepy",
description="Spice.xyz client library - data and AI infrastructure for web3.",
license="Apache 2.0",
classifiers=[
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Software Development :: Libraries",
],
keywords="spice, AI, web3, data, ML",
long_description=parse_markdown("README.md"),
long_description_content_type="text/markdown",
packages=["spicepy"],
install_requires=["pyarrow", "pandas", "web3>=6.0.0b2"],
install_requires=parse_requirements('requirements.txt'),
extras_require={
'test': parse_requirements('test.requirements.txt')
},
python_requires=">=3.8",
platforms=["Any"],
)


Expand Down
11 changes: 3 additions & 8 deletions spicepy/_http.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
import datetime
import json
from typing import Any, Callable, Dict, NewType, Optional, Union
from typing import Any, Callable, Dict, Literal, Optional, Union
from requests import Response, Session
from requests.adapters import HTTPAdapter, Retry

from .error import SpiceAIError

# Literal not supported in python 3.7
POST = NewType("POST", str)
GET = NewType("GET", str)
PUT = NewType("PUT", str)
HEAD = NewType("HEAD", str)
DELETE = NewType("DELETE", str)
HttpMethod = Union[POST, GET, PUT, HEAD, DELETE]

HttpMethod = Literal['POST', 'GET', 'PUT', 'HEAD', 'POST']


class HttpRequests:
Expand Down
3 changes: 3 additions & 0 deletions test.requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pylint==2.17.6
flake8==6.1.0
pytest==7.4.2

0 comments on commit 00fee63

Please sign in to comment.