-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow multiple folders in
class_package
node registration key (#123)
* Allowing packages in metadata to overwrite env variable * Adding documentation for class_package key * Restoring plot builds * remove extra line
- Loading branch information
Showing
8 changed files
with
223 additions
and
17 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
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{ | ||
/* | ||
* simple ETL: read from a CSV, reorder the columns and then write data to a CSV | ||
*/ | ||
|
||
"metadata": { | ||
"section_registry": [ | ||
"reader_config", | ||
"pipeline_config", | ||
"writer_config" | ||
], | ||
"class_package": [ | ||
"./src", | ||
"./test/sample_project" | ||
], | ||
}, | ||
"implementation_config": { | ||
"reader_config": { | ||
"read_data": { | ||
"class": "CsvReader", | ||
"filename": "data/tennis.csv", | ||
"destinations": [ | ||
"reorder_cols" | ||
] | ||
} | ||
}, | ||
"pipeline_config": { | ||
"reorder_cols": { | ||
"class": "ColumnReorder", | ||
"cols_order": [ | ||
"id", | ||
"outlook", | ||
"humidity", | ||
"play", | ||
"temp", | ||
"windy" | ||
], | ||
"destinations": [ | ||
"write_output" | ||
] | ||
} | ||
}, | ||
"writer_config": { | ||
"write_output": { | ||
"class": "CsvWriter", | ||
"key": "data", | ||
"dir": "test/sample_project/data", | ||
"filename": "tennis_output.csv" | ||
} | ||
} | ||
} | ||
} | ||
|
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
"""Module to reorder columns in a dataframe | ||
Author(s): | ||
Parul Laul ([email protected]) | ||
""" | ||
import logging | ||
from primrose.base.pipeline import AbstractPipeline | ||
|
||
|
||
class ColumnReorder(AbstractPipeline): | ||
"""Reorder columns in a dataframe""" | ||
|
||
@staticmethod | ||
def necessary_config(node_config): | ||
"""Return the necessary configuration keys for the DataFrameJoiner object | ||
Args: | ||
node_config (dict): set of parameters / attributes for the node | ||
Note: | ||
cols_order: list of column names in desired order | ||
Returns: | ||
set of keys | ||
""" | ||
return set(["cols_order"]) | ||
|
||
def transform(self, data_object): | ||
"""Get DataFrames from the data object and reorder columns | ||
Args: | ||
data_object (DataObject): instance of DataObject | ||
Returns: | ||
data_object (DataObject): instance of DataObject | ||
""" | ||
|
||
upstream_data = data_object.get_upstream_data( | ||
self.instance_name, pop_data=False | ||
) | ||
logging.info("Reordering columns") | ||
data = upstream_data['data'][self.node_config["cols_order"]] | ||
|
||
data_object.add(self, data, overwrite=False) | ||
|
||
return data_object |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
id,outlook,humidity,play,temp,windy | ||
1,sunny,high,no,hot,False | ||
2,sunny,high,no,hot,True | ||
3,overcast,high,yes,hot,False | ||
4,rainy,high,yes,mild,False | ||
5,rainy,normal,yes,cool,False | ||
6,rainy,normal,no,cool,True | ||
7,overcast,normal,yes,cool,True | ||
8,sunny,high,no,mild,False | ||
9,sunny,normal,yes,cool,False | ||
10,rainy,normal,yes,mild,False | ||
11,sunny,normal,yes,mild,True | ||
12,overcast,high,yes,mild,True | ||
13,overcast,normal,yes,hot,False | ||
14,rainy,high,no,mild,True |
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