Skip to content

Commit

Permalink
Bugfix: Data race during xf diff (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
drew authored Dec 9, 2020
1 parent 2659bdb commit 64d9db8
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions gretel/gc-nlp_text_analysis/blueprint.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
"metadata": {},
"outputs": [],
"source": [
"project = client.get_project(create=True)"
"project = client.get_project(display_name=\"Blueprint: NLP Text Analysis\", create=True)"
]
},
{
Expand Down Expand Up @@ -217,13 +217,13 @@
"metadata": {},
"outputs": [],
"source": [
"orig_records = [record for record in project.iter_records(direction=\"backward\")]\n",
"\n",
"xf_records = [\n",
" pipeline.transform_record(record)[\"record\"]\n",
" pipeline.transform_record(record)\n",
" for record in \n",
" project.iter_records(direction=\"backward\")\n",
"]\n",
"\n",
"xf_df = pd.DataFrame(xf_records)"
" orig_records\n",
"]\n"
]
},
{
Expand All @@ -242,17 +242,14 @@
"from gretel_client.demo_helpers import show_record_diff\n",
"\n",
"\n",
"# Lookup the comparison email by subject line.\n",
"c_key = \"subject_line\"\n",
"c_value = \"Confidentiality Agreement-Human Code\"\n",
"\n",
"# The comparison email contains multiple lines. For this\n",
"# demonstration we only want to examine the first line \n",
"# so we strip any extraneous newlines.\n",
"orig = source_df[source_df[c_key] == c_value][TEXT_FIELD].iloc[0].split(\"\\n\")[0]\n",
"xf = xf_df[xf_df[c_key] == c_value][TEXT_FIELD].iloc[0].split(\"\\n\")[0]\n",
"\n",
"show_record_diff({\"\": orig}, {\"\": xf})"
"for orig, xf in zip(orig_records, xf_records):\n",
" # Take the first line of text from each record\n",
" orig_line = orig[\"record\"][TEXT_FIELD].split(\"\\n\")[0]\n",
" xf_line = xf[\"record\"][TEXT_FIELD].split(\"\\n\")[0]\n",
" \n",
" if orig_line != xf_line:\n",
" show_record_diff({\"\": orig_line}, {\"\": xf_line})\n",
" input(\"\\nPress [enter] to compare the next record\")\n"
]
},
{
Expand Down

0 comments on commit 64d9db8

Please sign in to comment.