-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed magic dependency and added github pipeline for windows,mac. (#…
…105) Signed-off-by: Varun Mittal <[email protected]>
- Loading branch information
1 parent
42d997e
commit b38896d
Showing
7 changed files
with
34 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,21 @@ | ||
import magic | ||
|
||
from focus_validator.data_loaders.csv_data_loader import CSVDataLoader | ||
from focus_validator.data_loaders.parquet_data_loader import ParquetDataLoader | ||
from focus_validator.exceptions import FocusNotImplementedError | ||
|
||
|
||
def get_file_mime_type(filename): | ||
f = magic.Magic(uncompress=True) | ||
return f.from_file(filename=filename) | ||
|
||
|
||
class DataLoader: | ||
def __init__(self, data_filename): | ||
self.data_filename = data_filename | ||
self.data_loader_class = self.find_data_loader() | ||
self.data_loader = self.data_loader_class(self.data_filename) | ||
|
||
def find_data_loader(self): | ||
file_mime_type = get_file_mime_type(self.data_filename) | ||
|
||
if file_mime_type in ["ASCII text", "CSV text", "CSV ASCII text"]: | ||
if self.data_filename.endswith(".csv"): | ||
return CSVDataLoader | ||
elif file_mime_type == "Apache Parquet": | ||
elif self.data_filename.endswith(".parquet"): | ||
return ParquetDataLoader | ||
else: | ||
raise FocusNotImplementedError( | ||
msg=f"Validator for file_type '{file_mime_type}' not implemented yet." | ||
) | ||
raise FocusNotImplementedError("File type not implemented yet.") | ||
|
||
def load(self): | ||
return self.data_loader.load() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters