Skip to content

Commit

Permalink
first try oposite streaming, then deal with unverfied code, as the un…
Browse files Browse the repository at this point in the history
…verfied swallows the loading problem

Signed-off-by: dafnapension <[email protected]>
  • Loading branch information
dafnapension committed Feb 8, 2025
1 parent 6f1b886 commit e37b7e9
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 17 deletions.
4 changes: 2 additions & 2 deletions performance/compare_benchmark_performance_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@
"\n**Warning**: Performance degradation in Dataset Generation and/or Evaluation exceeds 5%!"
)
print(
"Explore branch performance via 'python performance/bluebench_profiler.py --output_file=<path to json file>',"
"followed by 'snakeviz <the performance.prof file specified in the output json file>'."
"Explore branch performance via 'python performance/bluebench_profiler.py --output_file=``path to json file``',"
"followed by 'snakeviz ``the performance.prof file specified in the output json file``'."
)
sys.exit(1)

Expand Down
32 changes: 20 additions & 12 deletions src/unitxt/loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,20 +312,28 @@ def load_dataset(
for k in dataset.keys():
next(iter(dataset[k]))
break
except ValueError as e:
if "trust_remote_code" in str(e):
raise ValueError(
f"{self.__class__.__name__} cannot run remote code from huggingface without setting unitxt.settings.allow_unverified_code=True or by setting environment variable: UNITXT_ALLOW_UNVERIFIED_CODE."
) from e

except:
current_streaming = kwargs["streaming"]
logger.info(
f"needed to swap streaming from {current_streaming} to {not current_streaming} for path {self.path}"
)
# try the opposite way of streaming
kwargs["streaming"] = not kwargs["streaming"]
dataset = hf_load_dataset(**kwargs)
try:
current_streaming = kwargs["streaming"]
logger.info(
f"needed to swap streaming from {current_streaming} to {not current_streaming} for path {self.path}"
)
# try the opposite way of streaming
kwargs["streaming"] = not kwargs["streaming"]
dataset = hf_load_dataset(**kwargs)
if isinstance(dataset, (Dataset, IterableDataset)):
next(iter(dataset))
else:
for k in dataset.keys():
next(iter(dataset[k]))
break

except ValueError as e:
if "trust_remote_code" in str(e):
raise ValueError(
f"{self.__class__.__name__} cannot run remote code from huggingface without setting unitxt.settings.allow_unverified_code=True or by setting environment variable: UNITXT_ALLOW_UNVERIFIED_CODE."
) from e

if self.filtering_lambda is not None:
dataset = dataset.filter(eval(self.filtering_lambda))
Expand Down
4 changes: 2 additions & 2 deletions utils/.secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
"filename": "src/unitxt/loaders.py",
"hashed_secret": "840268f77a57d5553add023cfa8a4d1535f49742",
"is_verified": false,
"line_number": 621,
"line_number": 629,
"is_secret": false
}
],
Expand Down Expand Up @@ -184,5 +184,5 @@
}
]
},
"generated_at": "2025-02-08T13:05:57Z"
"generated_at": "2025-02-08T13:56:45Z"
}
2 changes: 1 addition & 1 deletion utils/prepare_all_artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def main():
os.environ["UNITXT_TEST_CARD_DISABLE"] = "True"
os.environ["UNITXT_TEST_METRIC_DISABLE"] = "True"
os.environ["UNITXT_ALLOW_UNVERIFIED_CODE"] = "True"
os.environ["UNITXT_SKIP_ARTIFACTS_PREPARE_AND_VERIFY"] = "True"
os.environ["UNITXT_SKIP_ARTIFACTS_PREPARE_AND_VERIFY"] = "False"
logger.info("*" * 100)
logger.info("*" * 100)
logger.info(
Expand Down

0 comments on commit e37b7e9

Please sign in to comment.