Skip to content

Commit

Permalink
update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
mmoskal committed Oct 21, 2024
1 parent f3a4d43 commit 255f7c3
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
8 changes: 4 additions & 4 deletions parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ edition = "2021"
[dependencies]
toktrie = { git = "https://github.com/microsoft/toktrie", rev = "5e7013ad05081e918809d4ecebb33db7c4aabc69" }
derivre = { git = "https://github.com/microsoft/derivre", rev = "02ee497e6e404a0b402b4f68a9abf599d22ed2ed" }
serde = { version = "1.0.192", features = ["derive"] }
serde_json = { version = "1.0.108", features = ["preserve_order"] }
anyhow = "1.0.75"
serde = { version = "1.0.210", features = ["derive"] }
serde_json = { version = "1.0.132", features = ["preserve_order"] }
anyhow = "1.0.90"
rustc-hash = "2.0.0"
instant = "0.1.13"
jsonschema = { version = "0.18.2", default-features = false }
jsonschema = { version = "0.24.0", default-features = false }
url = "2.5.2"
lazy_static = "1.5.0"

Expand Down
27 changes: 13 additions & 14 deletions parser/src/json.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use anyhow::{anyhow, bail, Result};
use jsonschema::JSONSchema;
use jsonschema::Validator;
use lazy_static::lazy_static;
use serde_json::{json, Value};
use std::{collections::HashMap, sync::Arc, vec};
use std::{collections::HashMap, vec};

use crate::{
api::{GrammarWithLexer, RegexSpec, TopLevelGrammar},
Expand Down Expand Up @@ -203,23 +203,21 @@ impl OptionalField for Value {
}

struct DummyResolver {}
impl jsonschema::SchemaResolver for DummyResolver {
fn resolve(
impl jsonschema::Retrieve for DummyResolver {
fn retrieve(
&self,
_root_schema: &Value,
url: &url::Url,
_original_reference: &str,
) -> Result<Arc<Value>> {
Err(anyhow!("external resolver disabled (url: {})", url).into())
uri: &jsonschema::Uri<&str>,
) -> std::result::Result<Value, Box<dyn std::error::Error + Send + Sync>> {
Err(anyhow!("external resolver disabled (url: {})", uri).into())
}
}

lazy_static! {
static ref SCHEMA_VALIDATOR: JSONSchema = {
jsonschema::JSONSchema::options()
static ref SCHEMA_VALIDATOR: Validator = {
Validator::options()
.with_draft(jsonschema::Draft::Draft7)
.with_resolver(DummyResolver {})
.compile(&json!({
.with_retriever(DummyResolver {})
.build(&json!({
"$ref": "http://json-schema.org/draft-07/schema"
}))
.unwrap()
Expand All @@ -240,7 +238,8 @@ impl Compiler {

pub fn run(&mut self, schema: &Value) -> Result<()> {
if self.options.validate {
SCHEMA_VALIDATOR.validate(schema)
SCHEMA_VALIDATOR
.validate(schema)
.map_err(|mut e| anyhow!("Invalid schema: {}", e.next().unwrap()))?;
}

Expand Down
6 changes: 3 additions & 3 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ edition = "2021"

[dependencies]
llguidance_parser = { path = "../parser" }
bytemuck = "1.16.0"
bytemuck = "1.19.0"
pyo3 = {version = "0.21.2", features = ["extension-module", "abi3-py39"]}
serde = { version = "1.0.192", features = ["derive"] }
serde_json = "1.0.108"
serde = { version = "1.0.210", features = ["derive"] }
serde_json = "1.0.132"

[lib]
# See https://github.com/PyO3/pyo3 for details
Expand Down
3 changes: 2 additions & 1 deletion sample_parser/run.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/sh

cargo run data/blog.schema.ll.json data/blog.sample.json
# cargo run data/blog.schema.ll.json data/blog.sample.json
cargo run data/blog.schema.json data/blog.sample.json

0 comments on commit 255f7c3

Please sign in to comment.