Skip to content

Commit

Permalink
a few misc tweaks (#315)
Browse files Browse the repository at this point in the history
* a few misc tweaks

* test cases for str float to in
  • Loading branch information
samuelcolvin committed Nov 1, 2022
1 parent bd721b5 commit cf4a5cd
Show file tree
Hide file tree
Showing 6 changed files with 162 additions and 174 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,9 @@ jobs:
- run: pip install -r tests/requirements.txt
if: steps.cache-py.outputs.cache-hit != 'true'

- name: install rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
- run: rm rust-toolchain
- name: install rust nightly
uses: dtolnay/rust-toolchain@nightly

- name: cache rust
uses: Swatinem/rust-cache@v1
Expand Down
228 changes: 109 additions & 119 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,146 +35,136 @@ jobs:
PYTHON: ${{ matrix.python-version }}

steps:
- uses: actions/checkout@v3

- name: install rust nightly
if: matrix.rust-toolchain == 'nightly'
uses: actions-rs/toolchain@v1
with:
# use the default version from the "rust-toolchain" file in case rust is pinned there
profile: minimal

- name: install rust stable
if: matrix.rust-toolchain != 'nightly'
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust-toolchain }}
override: true

- id: cache-rust
name: cache rust
uses: Swatinem/rust-cache@v2
with:
key: v3

- run: cargo install rustfilt coverage-prepare
if: steps.cache-rust.outputs.cache-hit != 'true'

- run: rustup component add llvm-tools-preview

- name: set up python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- id: cache-py
name: cache python
uses: actions/cache@v2
with:
path: ${{ env.pythonLocation }}
key: >
py
${{ runner.os }}
${{ env.pythonLocation }}
${{ hashFiles('tests/requirements.txt') }}
${{ hashFiles('pyproject.toml') }}
- run: pip install -r tests/requirements.txt
if: steps.cache-py.outputs.cache-hit != 'true'

- run: pip install -e .
env:
RUST_BACKTRACE: 1
RUSTFLAGS: '-C instrument-coverage'

- run: pip freeze

- run: make test
env:
BENCHMARK_VS_PYDANTIC: 1

- run: ls -lha
- run: coverage xml

- run: coverage-prepare lcov pydantic_core/*.so

- uses: codecov/codecov-action@v3
if: matrix.rust-toolchain == 'nightly'
with:
env_vars: PYTHON
- uses: actions/checkout@v3

- run: rm rust-toolchain

- name: install rust ${{ matrix.rust-toolchain }}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust-toolchain }}

- id: cache-rust
name: cache rust
uses: Swatinem/rust-cache@v2
with:
key: v3

- run: cargo install rustfilt coverage-prepare
if: steps.cache-rust.outputs.cache-hit != 'true'

- run: rustup component add llvm-tools-preview

- name: set up python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- id: cache-py
name: cache python
uses: actions/cache@v2
with:
path: ${{ env.pythonLocation }}
key: >
py
${{ runner.os }}
${{ env.pythonLocation }}
${{ hashFiles('tests/requirements.txt') }}
${{ hashFiles('pyproject.toml') }}
- run: pip install -r tests/requirements.txt
if: steps.cache-py.outputs.cache-hit != 'true'

- run: pip install -e .
env:
RUST_BACKTRACE: 1
RUSTFLAGS: '-C instrument-coverage'

- run: pip freeze

- run: make test
env:
BENCHMARK_VS_PYDANTIC: 1

- run: ls -lha
- run: coverage xml

- run: coverage-prepare lcov pydantic_core/*.so

- uses: codecov/codecov-action@v3
if: matrix.rust-toolchain == 'nightly'
with:
env_vars: PYTHON

lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3

- name: install rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
override: true
components: rustfmt, clippy
- run: rm rust-toolchain
- name: install rust stable
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy

- name: cache rust
uses: Swatinem/rust-cache@v1
- name: cache rust
uses: Swatinem/rust-cache@v2

- uses: actions/setup-python@v4
with:
python-version: '3.10'
- uses: actions/setup-python@v4
with:
python-version: '3.10'

# used to lint js code
- uses: actions/setup-node@v3
with:
node-version: '18'
# used to lint js code
- uses: actions/setup-node@v3
with:
node-version: '18'

- uses: actions/cache@v2
id: cache-py
name: cache python
with:
path: ${{ env.pythonLocation }}
key: >
py
${{ env.pythonLocation }}
${{ hashFiles('tests/requirements-linting.txt') }}
${{ hashFiles('pyproject.toml') }}
- uses: actions/cache@v2
id: cache-py
name: cache python
with:
path: ${{ env.pythonLocation }}
key: >
py
${{ env.pythonLocation }}
${{ hashFiles('tests/requirements-linting.txt') }}
${{ hashFiles('pyproject.toml') }}
- run: pip install -r tests/requirements-linting.txt
if: steps.cache-py.outputs.cache-hit != 'true'
- run: pip install -r tests/requirements-linting.txt
if: steps.cache-py.outputs.cache-hit != 'true'

- run: pip install .
if: steps.cache-py.outputs.cache-hit != 'true'
- run: pip install .
if: steps.cache-py.outputs.cache-hit != 'true'

- run: pip freeze
- run: pip freeze

- run: make lint
- run: make pyright
- run: make lint
- run: make pyright

- run: npm install
- run: npm run lint
- run: npm install
- run: npm run lint

bench:
# run the rust benchmarks
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3

- name: install rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
- run: rm rust-toolchain
- name: install rust nightly
uses: dtolnay/rust-toolchain@nightly

- name: cache rust
uses: Swatinem/rust-cache@v1
- name: cache rust
uses: Swatinem/rust-cache@v2

- uses: actions/setup-python@v4
with:
python-version: '3.10'
- uses: actions/setup-python@v4
with:
python-version: '3.10'

- run: pip install typing_extensions
- run: make rust-benchmark
- run: pip install typing_extensions
- run: make rust-benchmark

build-wasm-emscripten:
runs-on: ubuntu-latest
Expand All @@ -187,14 +177,14 @@ jobs:
with:
python-version: '3.10'

- uses: actions-rs/toolchain@v1
- name: install rust nightly
uses: dtolnay/rust-toolchain@nightly
with:
profile: minimal
components: rust-src
target: wasm32-unknown-emscripten
targets: wasm32-unknown-emscripten

- name: cache rust
uses: Swatinem/rust-cache@v1
uses: Swatinem/rust-cache@v2

- uses: mymindstorm/setup-emsdk@v11
with:
Expand Down
90 changes: 45 additions & 45 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,64 +1,64 @@
[package]
name = 'pydantic-core'
version = '0.6.0'
edition = '2021'
license = 'MIT'
homepage = 'https://github.com/pydantic/pydantic-core'
repository = 'https://github.com/pydantic/pydantic-core.git'
readme = 'README.md'
name = "pydantic-core"
version = "0.6.0"
edition = "2021"
license = "MIT"
homepage = "https://github.com/pydantic/pydantic-core"
repository = "https://github.com/pydantic/pydantic-core.git"
readme = "README.md"
include = [
'/pyproject.toml',
'/README.md',
'/LICENSE',
'/Makefile',
'/build.rs',
'/generate_self_schema.py',
'/rust-toolchain',
'/src',
'!/src/self_schema.py',
'/pydantic_core',
'/tests',
'/.cargo',
'!__pycache__',
'!tests/.hypothesis',
'!tests/.pytest_cache',
'!*.so',
"/pyproject.toml",
"/README.md",
"/LICENSE",
"/Makefile",
"/build.rs",
"/generate_self_schema.py",
"/rust-toolchain",
"/src",
"!/src/self_schema.py",
"/pydantic_core",
"/tests",
"/.cargo",
"!__pycache__",
"!tests/.hypothesis",
"!tests/.pytest_cache",
"!*.so",
]

[dependencies]
pyo3 = '0.17.2'
regex = '1.6.0'
strum = { version = '0.24.1', features = ['derive'] }
strum_macros = '0.24.3'
serde_json = {version = '1.0.87', features = ['preserve_order']}
enum_dispatch = '0.3.8'
serde = '1.0.147'
indexmap = '1.9.1'
mimalloc = { version = '0.1.30', default-features = false, optional = true }
speedate = '0.7.0'
ahash = '0.8.0'
nohash-hasher = '0.2.0'
pyo3 = "0.17.2"
regex = "1.6.0"
strum = { version = "0.24.1", features = ["derive"] }
strum_macros = "0.24.3"
serde_json = {version = "1.0.87", features = ["preserve_order"]}
enum_dispatch = "0.3.8"
serde = "1.0.147"
indexmap = "1.9.1"
mimalloc = { version = "0.1.30", default-features = false, optional = true }
speedate = "0.7.0"
ahash = "0.8.0"
nohash-hasher = "0.2.0"

[lib]
name = '_pydantic_core'
crate-type = ['cdylib', 'rlib']
name = "_pydantic_core"
crate-type = ["cdylib", "rlib"]

[features]
# must be disabled for cargo bench
extension-module = ['pyo3/extension-module']
extension-module = ["pyo3/extension-module"]
# required for cargo bench
auto-initialize = ['pyo3/auto-initialize']
default = ['mimalloc', 'extension-module']
auto-initialize = ["pyo3/auto-initialize"]
default = ["mimalloc", "extension-module"]

[package.metadata.maturin]
name = 'pydantic_core._pydantic_core'
name = "pydantic_core._pydantic_core"

[profile.release]
lto = 'fat'
lto = "fat"
codegen-units = 1
panic = 'abort'
panic = "abort"

[build-dependencies]
version_check = '0.9.4'
version_check = "0.9.4"
# used where logic has to be version/distrobution specific, e.g. pypy
pyo3-build-config = '0.17.2'
pyo3-build-config = "0.17.2"

0 comments on commit cf4a5cd

Please sign in to comment.