Skip to content

Commit 0b898d2

Browse files
authored
Remove core schema validation (#1715)
1 parent 0ef2eb1 commit 0b898d2

32 files changed

+62
-720
lines changed

.github/actions/build-pgo-wheel/action.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ outputs:
1414
runs:
1515
using: "composite"
1616
steps:
17-
- name: prepare self schema
18-
shell: bash
19-
# generate up front so that we don't have to do this inside the docker container
20-
run: uv run python generate_self_schema.py
21-
2217
- name: prepare profiling directory
2318
shell: bash
2419
# making this ahead of the compile ensures that the local user can write to this

.github/workflows/ci.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -478,9 +478,6 @@ jobs:
478478

479479
- run: pip install -U twine 'ruff==0.5.0' typing_extensions
480480

481-
# generate self-schema now, so we don't have to do so inside docker in maturin build
482-
- run: python generate_self_schema.py
483-
484481
- name: build wheels
485482
uses: PyO3/maturin-action@v1
486483
with:

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ node_modules/
3434
/*.profraw
3535
/foobar.py
3636
/python/pydantic_core/*.so
37-
/src/self_schema.py
3837

3938
# samply
4039
/profile.json

Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ include = [
1212
"/LICENSE",
1313
"/Makefile",
1414
"/build.rs",
15-
"/generate_self_schema.py",
1615
"/rust-toolchain",
1716
"/src",
18-
"!/src/self_schema.py",
1917
"/python/pydantic_core",
2018
"/tests",
2119
"/.cargo",

Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.DEFAULT_GOAL := all
2-
sources = python/pydantic_core tests generate_self_schema.py wasm-preview/run_tests.py
2+
sources = python/pydantic_core tests wasm-preview/run_tests.py
33

44
mypy-stubtest = uv run python -m mypy.stubtest pydantic_core._pydantic_core --allowlist .mypy-stubtest-allowlist
55

@@ -124,7 +124,6 @@ clean:
124124
rm -f `find . -type f -name '*.py[co]' `
125125
rm -f `find . -type f -name '*~' `
126126
rm -f `find . -type f -name '.*~' `
127-
rm -rf src/self_schema.py
128127
rm -rf .cache
129128
rm -rf htmlcov
130129
rm -rf .pytest_cache

benches/main.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@ use test::{black_box, Bencher};
88
use pyo3::prelude::*;
99
use pyo3::types::{PyDict, PyString};
1010

11-
use _pydantic_core::{validate_core_schema, SchemaValidator};
11+
use _pydantic_core::SchemaValidator;
1212

1313
fn build_schema_validator_with_globals(
1414
py: Python,
1515
code: &CStr,
1616
globals: Option<&Bound<'_, PyDict>>,
1717
) -> SchemaValidator {
18-
let mut schema = py.eval(code, globals, None).unwrap().extract().unwrap();
19-
schema = validate_core_schema(&schema, None).unwrap().extract().unwrap();
18+
let schema = py.eval(code, globals, None).unwrap().extract().unwrap();
2019
SchemaValidator::py_new(py, &schema, None).unwrap()
2120
}
2221

@@ -510,8 +509,7 @@ fn complete_model(bench: &mut Bencher) {
510509
sys_path.call_method1("append", ("./tests/benchmarks/",)).unwrap();
511510

512511
let complete_schema = py.import("complete_schema").unwrap();
513-
let mut schema = complete_schema.call_method0("schema").unwrap();
514-
schema = validate_core_schema(&schema, None).unwrap().extract().unwrap();
512+
let schema = complete_schema.call_method0("schema").unwrap();
515513
let validator = SchemaValidator::py_new(py, &schema, None).unwrap();
516514

517515
let input = complete_schema.call_method0("input_data_lax").unwrap();
@@ -534,8 +532,7 @@ fn nested_model_using_definitions(bench: &mut Bencher) {
534532
sys_path.call_method1("append", ("./tests/benchmarks/",)).unwrap();
535533

536534
let complete_schema = py.import("nested_schema").unwrap();
537-
let mut schema = complete_schema.call_method0("schema_using_defs").unwrap();
538-
schema = validate_core_schema(&schema, None).unwrap().extract().unwrap();
535+
let schema = complete_schema.call_method0("schema_using_defs").unwrap();
539536
let validator = SchemaValidator::py_new(py, &schema, None).unwrap();
540537

541538
let input = complete_schema.call_method0("input_data_valid").unwrap();
@@ -562,8 +559,7 @@ fn nested_model_inlined(bench: &mut Bencher) {
562559
sys_path.call_method1("append", ("./tests/benchmarks/",)).unwrap();
563560

564561
let complete_schema = py.import("nested_schema").unwrap();
565-
let mut schema = complete_schema.call_method0("inlined_schema").unwrap();
566-
schema = validate_core_schema(&schema, None).unwrap().extract().unwrap();
562+
let schema = complete_schema.call_method0("inlined_schema").unwrap();
567563
let validator = SchemaValidator::py_new(py, &schema, None).unwrap();
568564

569565
let input = complete_schema.call_method0("input_data_valid").unwrap();

build.rs

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,3 @@
1-
use std::env;
2-
use std::path::Path;
3-
use std::process::Command;
4-
use std::str::from_utf8;
5-
6-
fn generate_self_schema() {
7-
println!("cargo:rerun-if-changed=python/pydantic_core/core_schema.py");
8-
println!("cargo:rerun-if-changed=generate_self_schema.py");
9-
if Path::new("./src/self_schema.py").exists() && option_env!("CI") == Some("true") {
10-
// self_schema.py already exists and CI indicates we're running on a github actions build,
11-
// don't bother generating again
12-
return;
13-
}
14-
15-
let output = Command::new(
16-
env::var("PYTHON")
17-
.ok()
18-
.or_else(|| pyo3_build_config::get().executable.clone())
19-
.unwrap_or_else(|| "python3".to_owned()),
20-
)
21-
.arg("generate_self_schema.py")
22-
.output()
23-
.expect("failed to execute process");
24-
25-
if !output.status.success() {
26-
let stdout = from_utf8(&output.stdout).unwrap();
27-
let stderr = from_utf8(&output.stderr).unwrap();
28-
eprint!("{stdout}{stderr}");
29-
panic!("generate_self_schema.py failed with {}", output.status);
30-
}
31-
}
32-
331
fn main() {
342
pyo3_build_config::use_pyo3_cfgs();
353
if let Some(true) = version_check::supports_feature("coverage_attribute") {
@@ -44,7 +12,5 @@ fn main() {
4412
println!("cargo:rustc-cfg=specified_profile_use");
4513
}
4614
println!("cargo:rustc-check-cfg=cfg(specified_profile_use)");
47-
48-
generate_self_schema();
4915
println!("cargo:rustc-env=PROFILE={}", std::env::var("PROFILE").unwrap());
5016
}

generate_self_schema.py

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

0 commit comments

Comments
 (0)