Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into ewm
Browse files Browse the repository at this point in the history
  • Loading branch information
DeaMariaLeon committed Nov 3, 2024
2 parents 6f738cd + f0cf973 commit 0cdb0c3
Show file tree
Hide file tree
Showing 15 changed files with 624 additions and 180 deletions.
109 changes: 55 additions & 54 deletions .github/workflows/downstream_tests.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: Test Downstream Libraries

on:
workflow_call:
workflow_dispatch:
pull_request:
push:
branches: [main]

jobs:
altair:
Expand Down Expand Up @@ -230,59 +231,59 @@ jobs:
cd tubular
pytest tests --config-file=pyproject.toml
vegafusion:
env:
UV_SYSTEM_PYTHON: true
# vegafusion:
# env:
# UV_SYSTEM_PYTHON: true

strategy:
matrix:
python-version: ["3.11"]
os: [ubuntu-latest]
# strategy:
# matrix:
# python-version: ["3.11"]
# os: [ubuntu-latest]

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: "true"
cache-suffix: ${{ matrix.python-version }}
cache-dependency-glob: "**requirements*.txt"
- name: clone-vegafusion
run: |
git clone --single-branch -b v2 https://github.com/vega/vegafusion.git
cd vegafusion
git log
- name: Cache rust dependencies
uses: Swatinem/rust-cache@v2
with:
workspaces: vegafusion
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
command: build
manylinux: 2014
rust-toolchain: stable
args: --release -m vegafusion/vegafusion-python/Cargo.toml --features=protobuf-src --strip
- name: Install wheels
working-directory: vegafusion/target/wheels/
run: |
ls -la
python -m pip install vegafusion-*manylinux*.whl
# runs-on: ${{ matrix.os }}
# steps:
# - uses: actions/checkout@v4
# - uses: actions/setup-python@v5
# with:
# python-version: ${{ matrix.python-version }}
# - name: Install uv
# uses: astral-sh/setup-uv@v3
# with:
# enable-cache: "true"
# cache-suffix: ${{ matrix.python-version }}
# cache-dependency-glob: "**requirements*.txt"
# - name: clone-vegafusion
# run: |
# git clone --single-branch -b v2 https://github.com/vega/vegafusion.git
# cd vegafusion
# git log
# - name: Cache rust dependencies
# uses: Swatinem/rust-cache@v2
# with:
# workspaces: vegafusion
# - name: Build wheels
# uses: PyO3/maturin-action@v1
# with:
# command: build
# manylinux: 2014
# rust-toolchain: stable
# args: --release -m vegafusion/vegafusion-python/Cargo.toml --features=protobuf-src --strip
# - name: Install wheels
# working-directory: vegafusion/target/wheels/
# run: |
# ls -la
# python -m pip install vegafusion-*manylinux*.whl

# Optional dependencies
python -m pip install pyarrow pandas polars-lts-cpu "duckdb>=1.0" "vl-convert-python>=1.0.1rc1" scikit-image "pandas>=2.2" jupytext voila anywidget ipywidgets chromedriver-binary-auto
# # Optional dependencies
# python -m pip install pyarrow pandas polars-lts-cpu "duckdb>=1.0" "vl-convert-python>=1.0.1rc1" scikit-image "pandas>=2.2" jupytext voila anywidget ipywidgets chromedriver-binary-auto

# Test dependencies
python -m pip install pytest altair vega-datasets scikit-image jupytext voila ipykernel anywidget ipywidgets selenium flaky tenacity chromedriver-binary-auto
- name: Test lazy imports
working-directory: vegafusion/vegafusion-python/
run: python checks/check_lazy_imports.py
- name: Test vegafusion
working-directory: vegafusion/vegafusion-python/
env:
VEGAFUSION_TEST_HEADLESS: 1
run: pytest
# # Test dependencies
# python -m pip install pytest altair vega-datasets scikit-image jupytext voila ipykernel anywidget ipywidgets selenium flaky tenacity chromedriver-binary-auto
# - name: Test lazy imports
# working-directory: vegafusion/vegafusion-python/
# run: python checks/check_lazy_imports.py
# - name: Test vegafusion
# working-directory: vegafusion/vegafusion-python/
# env:
# VEGAFUSION_TEST_HEADLESS: 1
# run: pytest
9 changes: 1 addition & 8 deletions .github/workflows/publish_to_pypi.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI

on:
push:
branches: [main]
tags:
- "v[0-9]+.[0-9]+.[0-9]+*"
on: push


jobs:
downstream-tests:
uses: ./.github/workflows/downstream_tests.yml

build:
name: Build distribution 📦
runs-on: ubuntu-latest
Expand Down
51 changes: 51 additions & 0 deletions docs/backcompat.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,54 @@ Here are exceptions to our backwards compatibility policy:
expressions, or pandas were to remove support for categorical data. At that point, we might
need to rethink Narwhals. However, we expect such radical changes to be exceedingly unlikely.
- we may consider making some type hints more precise.

In general, decision are driven by use-cases, and we conduct a search of public GitHub repositories
before making any change.

## Breaking changes carried out so far

### After `stable.v1`

- Since Narwhals 1.13.0, the `strict` parameter in `from_native`, `to_native`, and `narwhalify`
has been deprecated in favour of `pass_through`. This is because several users expressed
confusion/surprise over what `strict=False` did.
```python
# v1 syntax:
nw.from_native(df, strict=False)

# main namespace (and, when we get there, v2) syntax:
nw.from_native(df, pass_through=True)
```
If you are using Narwhals>=1.13.0, then we recommend using `pass_through`, as that
works consistently across namespaces.

In the future:

- in the main Narwhals namespace, `strict` will be removed in favour of `pass_through`
- in `stable.v1`, we will keep both `strict` and `pass_through`

- Since Narwhals 1.9.0, `Datetime` and `Duration` dtypes hash using both `time_unit` and
`time_zone`.
The effect of this can be seen when placing these dtypes in sets:

```python exec="1" source="above" session="backcompat"
import narwhals.stable.v1 as nw_v1
import narwhals as nw

# v1 behaviour:
assert nw_v1.Datetime("us") in {nw_v1.Datetime}

# main namespace (and, when we get there, v2) behaviour:
assert nw.Datetime("us") not in {nw.Datetime}
assert nw.Datetime("us") in {nw.Datetime("us")}
```

To check if a dtype is a datetime (regardless of `time_unit` or `time_zone`)
we recommend using `==` instead, as that works consistenty
across namespaces:

```python exec="1" source="above" session="backcompat"
# Recommended
assert nw.Datetime("us") == nw.Datetime
assert nw_v1.Datetime("us") == nw_v1.Datetime
```
2 changes: 1 addition & 1 deletion docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ To verify the installation, start the Python REPL and execute:
```python
>>> import narwhals
>>> narwhals.__version__
'1.12.1'
'1.13.1'
```
If you see the version number, then the installation was successful!

Expand Down
2 changes: 1 addition & 1 deletion narwhals/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
from narwhals.utils import maybe_reset_index
from narwhals.utils import maybe_set_index

__version__ = "1.12.1"
__version__ = "1.13.1"

__all__ = [
"dependencies",
Expand Down
2 changes: 1 addition & 1 deletion narwhals/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -2874,7 +2874,7 @@ def to_native(self) -> FrameT:
└─────┴─────┴─────┘
"""

return to_native(narwhals_object=self, strict=True)
return to_native(narwhals_object=self, pass_through=False)

# inherited
def pipe(self, function: Callable[[Any], Self], *args: Any, **kwargs: Any) -> Self:
Expand Down
2 changes: 1 addition & 1 deletion narwhals/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ def _from_dict_impl(
else:
msg = "Calling `from_dict` without `native_namespace` is only supported if all input values are already Narwhals Series"
raise TypeError(msg)
data = {key: to_native(value, strict=False) for key, value in data.items()}
data = {key: to_native(value, pass_through=True) for key, value in data.items()}
implementation = Implementation.from_native_namespace(native_namespace)

if implementation is Implementation.POLARS:
Expand Down
Loading

0 comments on commit 0cdb0c3

Please sign in to comment.