Skip to content

Commit 57f2d96

Browse files
authored
V3 (#615)
* switch back to devenv Seems to work better for interactive development Might have problems with the makefile in CI, we'll see * remove api class Only really useful for persistence and I'm going to remove that * remove dependencies Should have broken up dev and hdfs oh well * remove hdfs Remove functionality and related tests Coverage still looks good * remove code coverage badge Apparently I've let that lapse * update docs No more reference to API class, just link to modules * Bump major version I'm removing a ton of stuff, that's definitely a breaking change * update lock file * remove hdfs stuff Could have sworn I did this before * remove api class Only really made sense with hdfs and other state management * add extra field the api now returns * convert to uv2nix
1 parent 491181c commit 57f2d96

19 files changed

Lines changed: 1628 additions & 4243 deletions

.envrc

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

.github/workflows/pypi.yml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,12 @@ on:
88
- 'pyproject.toml'
99
jobs:
1010
pypi:
11+
permissions:
12+
id-token: write
1113
runs-on: ubuntu-latest
1214
steps:
13-
- uses: actions/checkout@v4
14-
- uses: actions/setup-python@v5
15-
with:
16-
python-version: '3.11'
17-
architecture: x64
18-
- run: pip install poetry==1.8.3
19-
- run: poetry build
20-
- uses: pypa/gh-action-pypi-publish@release/v1
21-
with:
22-
user: __token__
23-
password: ${{ secrets.PYPI_TOKEN }}
15+
- uses: actions/checkout@v4
16+
- name: Install uv
17+
uses: astral-sh/setup-uv@v6
18+
- run: uv build
19+
- run: uv publish

.github/workflows/test-pypi.yml

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,16 @@ on:
44
paths:
55
- 'src/**'
66
- 'pyproject.toml'
7-
87
jobs:
98
test_pypi:
9+
permissions:
10+
id-token: write
1011
runs-on: ubuntu-latest
1112
steps:
12-
- uses: actions/checkout@v4
13-
- uses: actions/setup-python@v5
14-
with:
15-
python-version: '3.11'
16-
architecture: x64
17-
- run: pip install poetry==1.8.3
18-
- run: >-
19-
poetry version patch &&
20-
version=$(poetry version | awk '{print $2}') &&
21-
poetry version $version.dev.$(date +%s)
22-
- run: poetry build
23-
- uses: pypa/gh-action-pypi-publish@v1.0.0a0
24-
with:
25-
user: __token__
26-
password: ${{ secrets.TEST_PYPI_TOKEN }}
27-
repository_url: https://test.pypi.org/legacy/
13+
- uses: actions/checkout@v4
14+
- name: Install uv
15+
uses: astral-sh/setup-uv@v6
16+
- run: >-
17+
uv version --bump patch && version=$(uv version | awk '{print $2}') && uv version $version.dev.$(date +%s)
18+
- run: uv build
19+
- run: uv publish --index testpypi

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,4 @@ dmypy.json
125125

126126
#devenv
127127
.devenv
128+
.direnv

Makefile

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
.PHONY: docs
22
test:
3-
nix develop --impure . -c ./.venv/bin/pre-commit run --all-files --show-diff-on-failure
4-
nix develop --impure .#python39 -c ./.venv/bin/coverage run -m pytest
5-
nix develop --impure .#python310 -c ./.venv/bin/coverage run -m pytest
6-
nix develop --impure .#python311 -c ./.venv/bin/coverage run -m pytest
7-
nix develop --impure .#python312 -c ./.venv/bin/coverage run -m pytest
8-
nix develop --impure . -c ./.venv/bin/coverage report
3+
nix develop --impure . -c pre-commit run --all-files --show-diff-on-failure
4+
nix develop --impure . -c ruff check .
5+
nix develop --impure .#python310 -c coverage run -m pytest
6+
nix develop --impure .#python311 -c coverage run -m pytest
7+
nix develop --impure .#python312 -c coverage run -m pytest
8+
nix develop --impure .#python313 -c coverage run -m pytest
9+
nix develop --impure . -c coverage report
910
safety:
10-
nix develop --impure . -c ./.venv/bin/safety check --file=poetry.lock --full-report
11+
nix develop --impure . -c safety check --file=uv.lock --full-report
1112
docs:
12-
nix develop --impure . -c ./.venv/bin/sphinx-build docs/source docs/_build
13+
nix develop --impure . -c sphinx-build docs/source docs/_build

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
[![Tests](https://github.com/ianepreston/stats_can/workflows/Tests/badge.svg)](https://github.com/ianepreston/stats_can/actions?workflow=Tests)
44
[![Documentation Status](https://readthedocs.org/projects/stats-can/badge/?version=latest)](https://stats-can.readthedocs.io/en/latest/?badge=latest)
5-
[![codecov](https://codecov.io/gh/ianepreston/stats_can/branch/master/graph/badge.svg)](https://codecov.io/gh/ianepreston/stats_can)
65
[![PyPI version](https://badge.fury.io/py/stats-can.svg)](https://badge.fury.io/py/stats-can)
76
[![Anaconda-Server Badge](https://anaconda.org/conda-forge/stats_can/badges/version.svg)](https://anaconda.org/conda-forge/stats_can)
87

activate_env.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.

docs/source/index.rst

Lines changed: 7 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -49,88 +49,25 @@ v3 branch in the project repo.
4949

5050
Quickstart
5151
==========
52-
After installing the stats_can package, all of the core functionality
53-
is available by instantiating a StatsCan object:
5452

55-
::
56-
57-
from stats_can import StatsCan
58-
sc = StatsCan()
59-
60-
Without any arguments the StatsCan object will look for a file in the current
61-
working directory named "stats_can.h5". If it doesn't exist it will create one
62-
when it is first asked to load a table. You can also pass in a path in order
63-
to specify the location of the file. This is useful if you or a team want persistent
64-
access to certain tables.
65-
66-
For example:
67-
::
68-
69-
sc = StatsCan(data_folder="~/stats_can_data")
70-
71-
The most common use case for stats_can is simply to read in a table
72-
from Statistics Canada to a Pandas DataFrame. For example, table 271-000-22-01
73-
is "Personnel engaged in research and development by performing sector and occupational category"
74-
to read in that table (downloading it first if it's the first time accessing it) run:
75-
76-
::
77-
78-
df = sc.table_to_df("271-000-22-01")
79-
80-
If there are only a couple specific series of interest you can also
81-
read them into a dataframe (whether they're in different source tables or not) as follows:
82-
83-
::
84-
85-
df = sc.vectors_to_df(["v74804", "v41692457"])
86-
87-
The above command takes an optional start_date argument which will return
88-
a dataframe beginning with a reference date no earlier than the provided start date.
89-
By default it will return all available history for the V#s provided.
53+
Refer to the module index below for a list of the modules and the methods they contain.
9054

91-
You can check which tables you have stored locally by running
92-
93-
::
94-
95-
sc.downloaded_tables
96-
97-
Which will return a list of table numbers.
98-
99-
If a table is locally stored, it will not automatically update if
100-
Statistics Canada releases an update. To update locally stored tables
101-
run:
102-
103-
::
104-
105-
sc.update_tables()
106-
107-
You can optionally pass in a list of tables if you only want a subset of the
108-
locally stored tables to be updated.
109-
110-
Finally, if you want to delete any tables you've loaded you can run:
111-
112-
::
113-
114-
sc.delete_tables("271-000-22-01")
115-
116-
StatsCan class documentation
117-
============================
118-
Core functions outlined in the Quickstart along with some extra
119-
functionality are described here:
55+
* :ref:`modindex`
12056

121-
.. autoclass:: stats_can.api_class.StatsCan
122-
:members:
57+
Generally if you want to call any of the endpoints of the service you can find a corresponding function
58+
in the scwds module, and higher level functions to read tables or vectors into a DataFrame are in the sc module
12359

12460
Contributing
12561
============
12662

12763
Contributions to this project are welcome. Fork the repository from
12864
`github <https://github.com/ianepreston/stats_can>`_,
12965

130-
You'll need a python environment with poetry and nox installed. A good guide for setting
66+
You'll need a python environment with poetry installed. A good guide for setting
13167
up an environment and project (that I used for this library) is `hypermodern python <https://cjolowicz.github.io/posts/hypermodern-python-01-setup/>`_.
13268

133-
After making any changes you can run nox to make sure testing and linting went ok, and then you should be good to submit a PR.
69+
I've configured the project to use nix for environment creation. If you use nix then the makefile in the root of the project will let you create
70+
development environments and run tests. However you like to configure a poetry project should work though.
13471

13572
I'd also welcome contributions to the docs, or anything else that would make this tool better for you or others.
13673

docs/source/stats_can.rst

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,6 @@ stats\_can package
44
Submodules
55
----------
66

7-
stats\_can.api_class module
8-
---------------------------
9-
10-
.. automodule:: stats_can.api_class
11-
:members:
12-
:undoc-members:
13-
:show-inheritance:
14-
15-
stats\_can.helpers module
16-
-------------------------
17-
18-
.. automodule:: stats_can.helpers
19-
:members:
20-
:undoc-members:
21-
:show-inheritance:
227

238
stats\_can.sc module
249
--------------------
@@ -37,6 +22,14 @@ stats\_can.scwds module
3722
:show-inheritance:
3823

3924

25+
stats\_can.helpers module
26+
-------------------------
27+
28+
.. automodule:: stats_can.helpers
29+
:members:
30+
:undoc-members:
31+
:show-inheritance:
32+
4033
Module contents
4134
---------------
4235

0 commit comments

Comments
 (0)