Skip to content

Commit

Permalink
set columns with list (#299)
Browse files Browse the repository at this point in the history
* set columns with list

* lock

* fix test

* Check path existence
  • Loading branch information
mski-iksm authored Nov 1, 2022
1 parent ba88726 commit ad8f190
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 542 deletions.
3 changes: 3 additions & 0 deletions gokart/s3_zip_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ def exists(self) -> bool:

def make_archive(self) -> None:
extension = os.path.splitext(self._file_path)[1]
if not os.path.exists(self._temporary_directory):
# Check path existence since shutil.make_archive() of python 3.10+ does not check it.
raise FileNotFoundError(f'Temporary directory {self._temporary_directory} is not found.')
shutil.make_archive(base_name=self._temporary_directory, format=extension[1:], root_dir=self._temporary_directory)
self._client.put(self._temporary_file_path(), self._file_path)

Expand Down
2 changes: 1 addition & 1 deletion gokart/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def _flatten_recursively(dfs):

required_columns = required_columns or set()
if data.empty and len(data.index) == 0 and len(required_columns - set(data.columns)) > 0:
return pd.DataFrame(columns=required_columns)
return pd.DataFrame(columns=list(required_columns))
assert required_columns.issubset(set(data.columns)), f'data must have columns {required_columns}, but actually have only {data.columns}.'
if drop_columns:
data = data[list(required_columns)]
Expand Down
2 changes: 1 addition & 1 deletion gokart/testing/check_if_run_with_empty_data_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def _test_run_with_empty_data_frame(cmdline_args: List[str], test_run_params: te
if test_run_params.namespace is not None:
all_tasks = [t for t in all_tasks if t.task_namespace == test_run_params.namespace]

with patch('gokart.TaskOnKart.load_data_frame', new=lambda *args, required_columns=None, **kwargs: pd.DataFrame(columns=required_columns)):
with patch('gokart.TaskOnKart.load_data_frame', new=lambda *args, required_columns=None, **kwargs: pd.DataFrame(columns=list(required_columns))):
with patch('gokart.TaskOnKart.dump', new=lambda *args, **kwargs: None):
test_status_list = [_run_with_test_status(t) for t in all_tasks]

Expand Down
Loading

0 comments on commit ad8f190

Please sign in to comment.