Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/scripts/mr_generate_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ def combine_result(
reports_paths = list(reports_dir.glob("*/report.json"))

for report_path in reports_paths:
report_dict = json.load(open(report_path))
with open(report_path) as f:
report_dict = json.load(f)
data = combine_result(data, report_dict)

summary_file = os.environ["SUMMARY_FILE"]
Expand Down
16 changes: 7 additions & 9 deletions rasa/nlu/utils/pattern_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,19 @@ def read_lookup_table_file(lookup_table_file: Text) -> List[Text]:
Elements listed in the lookup table file.
"""
try:
f = open(lookup_table_file, "r", encoding=rasa.shared.utils.io.DEFAULT_ENCODING)
with open(lookup_table_file, "r", encoding=rasa.shared.utils.io.DEFAULT_ENCODING) as f:
elements_to_regex = []
for line in f:
new_element = line.strip()
if new_element:
elements_to_regex.append(new_element)
return elements_to_regex
except OSError:
raise ValueError(
f"Could not load lookup table {lookup_table_file}. "
f"Please make sure you've provided the correct path."
)

elements_to_regex = []
with f:
for line in f:
new_element = line.strip()
if new_element:
elements_to_regex.append(new_element)
return elements_to_regex


def _collect_regex_features(
training_data: TrainingData, use_only_entities: bool = False
Expand Down
7 changes: 3 additions & 4 deletions tests/nlu/featurizers/test_convert_featurizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,9 @@ def test_raise_wrong_model_file(
tmp_path: Path,
):
# create a dummy file
temp_file = os.path.join(tmp_path, "saved_model.pb")
f = open(temp_file, "wb")
f.close()
component_config = {FEATURIZER_CLASS_ALIAS: "alias", "model_url": temp_file}
temp_file = tmp_path / "saved_model.pb"
temp_file.touch()
component_config = {FEATURIZER_CLASS_ALIAS: "alias", "model_url": str(temp_file)}

with pytest.raises(RasaException) as excinfo:
_ = create_or_load_convert_featurizer(component_config)
Expand Down