Skip to content

Commit

Permalink
Fix flow.to_code() representation of string parameters. (#171)
Browse files Browse the repository at this point in the history
Co-authored-by: Gal Topper <[email protected]>
  • Loading branch information
Gal Topper and Gal Topper authored Feb 15, 2021
1 parent 95f5cdb commit bb00003
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions storey/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ def _to_code(self, taken: Set[str]):
taken.add(var_name)
param_list = []
for key, value in self._kwargs.items():
if isinstance(value, str):
value = f"'{value}'"
param_list.append(f'{key}={value}')
if self._custom_name:
param_list.append(f'name={self.name}')
Expand Down
16 changes: 16 additions & 0 deletions tests/test_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2078,6 +2078,22 @@ def test_split_flow_to_code():
assert reconstructed_code == expected


def test_reader_writer_to_code():
flow = build_flow([
ReadCSV('mycsv.csv'),
WriteToParquet('mypq.pq')
])

reconstructed_code = flow.to_code()
print(reconstructed_code)
expected = """read_c_s_v0 = ReadCSV(paths='mycsv.csv', header=False, build_dict=False, type_inference=True)
write_to_parquet0 = WriteToParquet(path='mypq.pq')
read_c_s_v0.to(write_to_parquet0)
"""
assert reconstructed_code == expected


def test_illegal_step_no_source():
try:
Reduce([], append_and_return, full_event=True).run()
Expand Down

0 comments on commit bb00003

Please sign in to comment.