Skip to content

Commit

Permalink
Shows how to use validator without reaching into driver
Browse files Browse the repository at this point in the history
  • Loading branch information
skrawcz committed Jun 20, 2024
1 parent e451d28 commit 47b931c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
10 changes: 3 additions & 7 deletions examples/schema/dataflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ def df_with_renamed_cols(df_with_new_cols: pd.DataFrame) -> pd.DataFrame:
from hamilton import driver
from hamilton.plugins import h_schema

dr = (
driver.Builder()
.with_modules(__main__)
.with_adapters(h_schema.SchemaValidator("./schemas"))
.build()
)
validator_adapter = h_schema.SchemaValidator("./schemas")
dr = driver.Builder().with_modules(__main__).with_adapters(validator_adapter).build()
res = dr.execute(["df_with_renamed_cols"])
print(json.dumps(dr.adapter.adapters[0].json_schemas, indent=2))
print(json.dumps(validator_adapter.json_schemas, indent=2))
10 changes: 5 additions & 5 deletions examples/schema/multi_dataflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,18 @@ def pandas_new_col__v4(ibis_rename: ir.Table) -> pd.DataFrame:
"--no-check", action="store_false", help="Disable `check` to update the stored schemas."
)
args = parser.parse_args()

validator_adapter = h_schema.SchemaValidator(
"./multi_schemas", check=args.no_check, importance="warn"
)
dr = (
driver.Builder()
.with_modules(__main__)
.with_config(dict(version=args.version))
.with_adapters(
h_schema.SchemaValidator("./multi_schemas", check=args.no_check, importance="warn")
)
.with_adapters(validator_adapter)
.build()
)
res = dr.execute(["pandas_new_col"])
print(res["pandas_new_col"].head())
print()

print(json.dumps(dr.adapter.adapters[0].json_schemas, indent=2))
print(json.dumps(validator_adapter.json_schemas, indent=2))

0 comments on commit 47b931c

Please sign in to comment.