Skip to content

Commit 95aab3e

Browse files
authored
Switch to uv (#62)
* updated to uv, removed poetry * test actions
1 parent 848b1b8 commit 95aab3e

File tree

12 files changed

+1079
-3628
lines changed

12 files changed

+1079
-3628
lines changed

.github/workflows/test-package.yaml

Lines changed: 56 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -18,47 +18,62 @@ jobs:
1818
matrix:
1919
python-version: ["3.12"]
2020
os: [ubuntu-latest, macOS-latest]
21-
env:
22-
POETRY_VIRTUALENVS_IN_PROJECT: true
23-
steps:
24-
- uses: actions/checkout@v3
25-
- uses: actions/setup-python@v5
26-
with:
27-
python-version: ${{ matrix.python-version }}
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v2
26+
27+
- name: Set up Python
28+
run: uv python install
29+
30+
- name: Install the project
31+
run: uv sync --all-extras --dev
32+
33+
- name: Run tests
34+
# For example, using `pytest`
35+
run: uv run pytest tests
36+
# env:
37+
# POETRY_VIRTUALENVS_IN_PROJECT: true
38+
# steps:
39+
# - uses: actions/checkout@v3
40+
# - uses: actions/setup-python@v5
41+
# with:
42+
# python-version: ${{ matrix.python-version }}
2843

29-
# Cache the installation of Poetry itself, e.g. the next step. This prevents the workflow
30-
# from installing Poetry every time, which can be slow. Note the use of the Poetry version
31-
# number in the cache key, and the "-0" suffix: this allows you to invalidate the cache
32-
# manually if/when you want to upgrade Poetry, or if something goes wrong.
33-
- name: cache poetry install
34-
uses: actions/cache@v4
35-
with:
36-
path: ~/.local
37-
key: poetry-cache-${{ runner.os }}-${{ matrix.python-version }}-${{ env.POETRY_VERSION }}
44+
# # Cache the installation of Poetry itself, e.g. the next step. This prevents the workflow
45+
# # from installing Poetry every time, which can be slow. Note the use of the Poetry version
46+
# # number in the cache key, and the "-0" suffix: this allows you to invalidate the cache
47+
# # manually if/when you want to upgrade Poetry, or if something goes wrong.
48+
# - name: cache poetry install
49+
# uses: actions/cache@v4
50+
# with:
51+
# path: ~/.local
52+
# key: poetry-cache-${{ runner.os }}-${{ matrix.python-version }}-${{ env.POETRY_VERSION }}
3853

39-
# Install Poetry. You could do this manually, or there are several actions that do this.
40-
# `snok/install-poetry` seems to be minimal yet complete, and really just calls out to
41-
# Poetry's default install script, which feels correct. I pin the Poetry version here
42-
# because Poetry does occasionally change APIs between versions and I don't want my
43-
# actions to break if it does.
44-
#
45-
# The key configuration value here is `virtualenvs-in-project: true`: this creates the
46-
# venv as a `.venv` in your testing directory, which allows the next step to easily
47-
# cache it.
48-
- uses: snok/install-poetry@v1
49-
with:
50-
version: 1.8.3
51-
virtualenvs-create: true
52-
virtualenvs-in-project: true
54+
# # Install Poetry. You could do this manually, or there are several actions that do this.
55+
# # `snok/install-poetry` seems to be minimal yet complete, and really just calls out to
56+
# # Poetry's default install script, which feels correct. I pin the Poetry version here
57+
# # because Poetry does occasionally change APIs between versions and I don't want my
58+
# # actions to break if it does.
59+
# #
60+
# # The key configuration value here is `virtualenvs-in-project: true`: this creates the
61+
# # venv as a `.venv` in your testing directory, which allows the next step to easily
62+
# # cache it.
63+
# - uses: snok/install-poetry@v1
64+
# with:
65+
# version: 1.8.3
66+
# virtualenvs-create: true
67+
# virtualenvs-in-project: true
5368

54-
# Cache your dependencies (i.e. all the stuff in your `pyproject.toml`)
55-
- name: cache venv
56-
uses: actions/cache@v4
57-
with:
58-
path: .venv
59-
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
60-
- run: poetry install --no-interaction --no-root
61-
if: steps.cache-deps.outputs.cache-hit != 'true'
62-
- run: poetry install --no-interaction
63-
- run: poetry run ruff check --fix
64-
- run: poetry run pytest
69+
# # Cache your dependencies (i.e. all the stuff in your `pyproject.toml`)
70+
# - name: cache venv
71+
# uses: actions/cache@v4
72+
# with:
73+
# path: .venv
74+
# key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
75+
# - run: poetry install --no-interaction --no-root
76+
# if: steps.cache-deps.outputs.cache-hit != 'true'
77+
# - run: poetry install --no-interaction
78+
# - run: poetry run ruff check --fix
79+
# - run: poetry run pytest

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
33
# Ruff version.
4-
rev: v0.4.8
4+
rev: v0.6.8
55
hooks:
66
# Run the linter.
77
- id: ruff

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.12

docs/source/notebooks/usage.ipynb

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
"from py_alpaca_api import PyAlpacaAPI\n",
3535
"\n",
3636
"# Load environment variables\n",
37-
"api_key = os.environ.get('ALPACA_API_KEY')\n",
38-
"api_secret = os.environ.get('ALPACA_SECRET_KEY')\n",
37+
"api_key = os.environ.get(\"ALPACA_API_KEY\")\n",
38+
"api_secret = os.environ.get(\"ALPACA_SECRET_KEY\")\n",
3939
"\n",
4040
"# Create an instance of PyAlpacaAPI\n",
4141
"api = PyAlpacaAPI(api_key=api_key, api_secret=api_secret, api_paper=True)"
@@ -90,7 +90,7 @@
9090
}
9191
],
9292
"source": [
93-
"asset = stock.assets.get('AAPL')\n",
93+
"asset = stock.assets.get(\"AAPL\")\n",
9494
"pprint(asset)"
9595
]
9696
},
@@ -127,7 +127,9 @@
127127
}
128128
],
129129
"source": [
130-
"asset_history = stock.history.get_stock_data(symbol=asset.symbol, start='2024-06-01', end='2024-06-07', timeframe='1d')\n",
130+
"asset_history = stock.history.get_stock_data(\n",
131+
" symbol=asset.symbol, start=\"2024-06-01\", end=\"2024-06-07\", timeframe=\"1d\"\n",
132+
")\n",
131133
"pprint(asset_history)"
132134
]
133135
},
@@ -241,8 +243,12 @@
241243
"# then uses Meta Prophet to predict future prices. Then it calculates the\n",
242244
"# percentage gain and returns a list of symbols that are predicted to gain.\n",
243245
"future_gainers = stock.predictor.get_losers_to_gainers(losers_to_scan=100)\n",
244-
"print(\"This function uses Meta Prophet to predict future gainers. There is no guarantee that these stocks will gain.\")\n",
245-
"print(f\"Out of 100 previous loser stocks, there are {len(future_gainers)} predicted to gain 10% in the next 14 days:\")\n",
246+
"print(\n",
247+
" \"This function uses Meta Prophet to predict future gainers. There is no guarantee that these stocks will gain.\"\n",
248+
")\n",
249+
"print(\n",
250+
" f\"Out of 100 previous loser stocks, there are {len(future_gainers)} predicted to gain 10% in the next 14 days:\"\n",
251+
")\n",
246252
"print(future_gainers)"
247253
]
248254
}

0 commit comments

Comments
 (0)