Skip to content

Commit

Permalink
Revert "Revert "depr: deprecate strict in from_native / to_native
Browse files Browse the repository at this point in the history
…in favour of `pass_through` (#1312)
  • Loading branch information
MarcoGorelli authored Nov 3, 2024
1 parent 9465ae3 commit 24e20b5
Show file tree
Hide file tree
Showing 10 changed files with 567 additions and 146 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
23 changes: 21 additions & 2 deletions docs/backcompat.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,27 @@ before making any change.

### After `stable.v1`

- `Datetime` and `Duration` dtypes hash using both `time_unit` and `time_zone`.
The effect of this can be seen when doing `dtype in {...}` checks:
- 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
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 24e20b5

Please sign in to comment.