Skip to content

Commit

Permalink
Address issue when IncludeFile was not specified (fixes #418) (#421)
Browse files Browse the repository at this point in the history
  • Loading branch information
romain-intel authored Jan 23, 2021
1 parent 97ee2cb commit 83c1cdf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions metaflow/includefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ def __init__(
type=FilePathClass(is_text, encoding), **kwargs)

def load_parameter(self, val):
if val is None:
return val
ok, file_type, err = LocalFile.is_file_handled(val)
if not ok:
raise MetaflowException("Parameter '%s' could not be loaded: %s" % (self.name, err))
Expand Down
5 changes: 4 additions & 1 deletion test/core/tests/basic_include.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ class BasicIncludeTest(MetaflowTest):
'myfile_txt': {'default': "'./reg.txt'"},
'myfile_utf8': {'default': "'./utf8.txt'", 'encoding': "'utf8'"},
'myfile_binary': {'default': "'./utf8.txt'", 'is_text': False},
'myfile_overriden': {'default': "'./reg.txt'"}
'myfile_overriden': {'default': "'./reg.txt'"},
'absent_file': {'required': False}
}
HEADER = """
import codecs
Expand All @@ -30,6 +31,8 @@ def step_all(self):
u"UTF Text File \u5e74".encode(encoding='utf8'), self.myfile_binary)
assert_equals("Override Text File", self.myfile_overriden)

# Check that an absent file does not make things crash
assert_equals(None, self.absent_file)
try:
# Include files should be immutable
self.myfile_txt = 5
Expand Down

0 comments on commit 83c1cdf

Please sign in to comment.