Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ini file processor #329

Merged
merged 12 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from 11 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
1 change: 1 addition & 0 deletions docs/task_on_kart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ It is also possible to specify a file format other than pkl. The supported file
- .feather
- .png
- .jpg
- .ini


If dump something other than the above, can use :func:`~gokart.TaskOnKart.make_model_target`.
Expand Down
1 change: 1 addition & 0 deletions gokart/file_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ def make_file_processor(file_path: str, store_index_in_feather: bool) -> FilePro
'.feather': FeatherFileProcessor(store_index_in_feather=store_index_in_feather),
'.png': BinaryFileProcessor(),
'.jpg': BinaryFileProcessor(),
'.ini': TextFileProcessor(),
maronuu marked this conversation as resolved.
Show resolved Hide resolved
}

extension = os.path.splitext(file_path)[1]
Expand Down
14 changes: 14 additions & 0 deletions test/test_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import boto3
import numpy as np
import pandas as pd
from luigi.configuration.cfg_parser import LuigiConfigParser
from matplotlib import pyplot
from moto import mock_s3

Expand Down Expand Up @@ -127,6 +128,19 @@ def test_save_and_load_feather_without_store_index_in_feather(self):

pd.testing.assert_frame_equal(loaded, obj)

def test_save_and_load_config_ini_file(self):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maronuu will you remove this test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed, Thank you for the comment.

obj = LuigiConfigParser()
obj['common'] = {'a': '1', 'b': 'yes', 'c': 2}
obj['example'] = {}
obj['example']['d'] = 'foo'
obj['example']['e'] = 'true'
file_path = os.path.join(_get_temporary_directory(), 'test.ini')

target = make_target(file_path=file_path, unique_id=None)
target.dump(obj)
loaded = target.load()
self.assertEqual(loaded, [str(obj)], msg='should save an object as List[str].')

def test_last_modified_time(self):
obj = pd.DataFrame(dict(a=[1, 2], b=[3, 4]))
file_path = os.path.join(_get_temporary_directory(), 'test.csv')
Expand Down