Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilrybacki committed Jul 14, 2024
1 parent bb736e3 commit 272d4bd
Showing 1 changed file with 3 additions and 38 deletions.
41 changes: 3 additions & 38 deletions src/content/_jupyter/phaistos/pydantic.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,9 @@
" )\n",
")\n",
"\n",
"# We will confirm that the model is created successfully,\n",
"# and nested model is also created successfully as one of the fields\n",
"logging.info(\n",
" json.dumps( # This method is just for indentation only\n",
" Nested.model_json_schema(), # This is a V2 version of the schema dump\n",
" indent=2\n",
" )\n",
")"
" Root.schema_json(indent=2)\n",
") # This is a V1 version of the schema dump\n"
]
},
{
Expand All @@ -273,24 +268,6 @@
"contains only information about the **contraints** applied to the fields, but no mention is found of the **validators**."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Let's see what information is available in the JSON dump of our model\n",
"logging.info(\n",
" json.dumps( # This method is just for indentation only\n",
" Root.model_json_schema(), # This is a V2 version of the schema dump\n",
" indent=2\n",
" )\n",
")\n",
"logging.info(\n",
" Root.schema_json(indent=2)\n",
") # This is a V1 version of the schema dump\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -519,19 +496,7 @@
"# Let's pickle the model\n",
"try:\n",
" pickled_model = pickle.dumps(filtered_person_dump)\n",
"except TypeError as e:\n",
" logging.error(f'Failed to pickle the model: {e}')\n",
"\n",
"# Maybe the pickling of the whole model will work?\n",
"try:\n",
" pickled_model = pickle.dumps(Person)\n",
" logging.info('Model pickled successfully!')\n",
"except TypeError as e:\n",
" logging.error(f'Failed to pickle the model: {e}')\n",
"# Let's pickle the model\n",
"try:\n",
" pickled_model = pickle.dumps(filtered_person_dump)\n",
"except TypeError as e:\n",
"except pickle.PicklingError as e:\n",
" logging.error(f'Failed to pickle the model: {e}')\n",
"\n",
"# Maybe the pickling of the whole model will work?\n",
Expand Down

0 comments on commit 272d4bd

Please sign in to comment.