Skip to content

Commit

Permalink
pg.from_json to support auto_import flag.
Browse files Browse the repository at this point in the history
This allows automatic import of classes when they are not registered.
This CL also replaces `force_dict` with `auto_dict`.

PiperOrigin-RevId: 676880474
  • Loading branch information
daiyip authored and langfun authors committed Sep 20, 2024
1 parent 241eb2e commit c95ebde
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 10 deletions.
2 changes: 1 addition & 1 deletion langfun/core/eval/base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def test_run(self):
s.root_dir, base.Evaluation.SUMMARY_HTML.replace('.html', '.json')
)
self.assertTrue(os.path.exists(summary_json))
summary = pg.load(summary_json, force_dict=True)
summary = pg.load(summary_json, auto_dict=True)
self.assertIn('Evaluation', summary)
self.assertEqual(len(summary['Evaluation']), 1)
self.assertIsNotNone(summary['Evaluation'][0].experiment)
Expand Down
6 changes: 0 additions & 6 deletions langfun/core/eval/matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,6 @@ def save(
for input, output, _ in self.matches
],
os.path.join(self.dir, Matching.MATCHES_JSON),
# We force the input and output to be dict so it does not depend on
# the downstream to serialize.
force_dict=True,
)

# Save mismatches.
Expand All @@ -198,9 +195,6 @@ def save(
for input, output, _ in self.mismatches
],
os.path.join(self.dir, Matching.MISMATCHES_JSON),
# We force the input and output to be dict so it does not depend on
# the downstream to serialize.
force_dict=True,
)

if report:
Expand Down
3 changes: 0 additions & 3 deletions langfun/core/eval/scoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,6 @@ def save(
for input, output, score, _ in self.scored
],
os.path.join(self.dir, Scoring.SCORED_JSON),
# We force the input and output to be dict so it does not depend on
# the downstream to serialize.
force_dict=True,
)

if report:
Expand Down

0 comments on commit c95ebde

Please sign in to comment.