-
Notifications
You must be signed in to change notification settings - Fork 113
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
Preview dataset #1288
Preview dataset #1288
Changes from 21 commits
007f7c2
0ff46cf
e469560
38e641c
4fd5136
6ca4ec4
36931d0
2abe3a6
85dda7c
6aa6b6e
9a6eae7
dc19dd1
d41b4f6
5d775cf
6e143f9
de652bd
20bcefd
6a90f53
a7c07b0
e7b1a56
2ce39d0
c6ec97a
0a6c107
4c4a2a1
7990f5a
3d1de36
1f578a5
e5fab1d
15e61d4
9869229
bc7a12c
a772729
ed13b44
bc25c3e
e446fdd
c726a7b
36b7c66
3658109
538cf9c
63b0b7d
4f558c7
8d5ed2a
1244076
e3f7924
9b89c6c
0455310
3d54783
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,9 @@ | |
|
||
logger = logging.getLogger(__name__) | ||
|
||
PREVIEW_DATASETS = ["pandas.csv_dataset.CSVDataSet", | ||
"pandas.parquet_dataset.ParquetDataSet", "pandas.excel_dataset.ExcelDataSet"] | ||
|
||
|
||
def _pretty_name(name: str) -> str: | ||
name = name.replace("-", " ").replace("_", " ").replace(":", ": ") | ||
|
@@ -555,13 +558,20 @@ class DataNodeMetadata(GraphNodeMetadata): | |
# command to run the pipeline to this data node | ||
run_command: Optional[str] = field(init=False, default=None) | ||
|
||
preview: Optional[Dict] = field(init=False, default=None) | ||
|
||
# TODO: improve this scheme. | ||
def __post_init__(self, data_node: DataNode): | ||
self.type = data_node.dataset_type | ||
dataset = cast(AbstractDataSet, data_node.kedro_obj) | ||
dataset_description = dataset._describe() | ||
self.filepath = _parse_filepath(dataset_description) | ||
|
||
if self.type in PREVIEW_DATASETS: | ||
# If the kedro-datasets is on the latest and does have the _preview | ||
if (hasattr(dataset, '_preview')): | ||
self.preview = dataset._preview(40) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Based on our telemetry, hardly anyone uses this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's interesting. I would argue this is a slightly more compelling thing for users to actually change, but it's also something we can wait to see if users start asking for :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is now done @datajoely 😄 I just included this today, by default this feature is always on unless user chooses to change it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it toggled or can they pass the preview number of rows? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is just toggled on and off at the moment, with the number of rows sets to 40 |
||
|
||
# Run command is only available if a node is an output, i.e. not a free input | ||
if not data_node.is_free_input: | ||
self.run_command = f"kedro run --to-outputs={data_node.full_name}" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import PreviewTable from './preview-table'; | ||
|
||
export default PreviewTable; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import React from 'react'; | ||
import className from 'classnames'; | ||
|
||
import './preview-table.css'; | ||
|
||
const PreviewTable = ({ data, size = 'small' }) => { | ||
const headers = Object.keys(data); | ||
Huongg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const nRows = Object.keys(data[headers[0]]); | ||
Huongg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
return ( | ||
<table | ||
className={className('preview-table', { | ||
'preview-table__small': size === 'small', | ||
'preview-table__large': size === 'large', | ||
})} | ||
cellSpacing={0} | ||
> | ||
<tbody> | ||
<tr className="preview-table__row-header"> | ||
{headers.map((header) => ( | ||
<th className="preview-table__header" key={header}> | ||
{header} | ||
</th> | ||
))} | ||
</tr> | ||
{nRows.map((index) => ( | ||
<tr className="preview-table__row" key={index}> | ||
{headers.map((header, i) => { | ||
return ( | ||
<td className="preview-table__data" key={i}> | ||
{data[header][index]} | ||
</td> | ||
); | ||
})} | ||
</tr> | ||
))} | ||
</tbody> | ||
</table> | ||
); | ||
}; | ||
|
||
export default PreviewTable; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
@use '../../styles/variables' as variables; | ||
@use '../../styles/extends'; | ||
|
||
.kui-theme--light { | ||
--color-highlight: #{variables.$grey-200}; | ||
} | ||
|
||
.kui-theme--dark { | ||
--color-highlight: #{variables.$slate-400}; | ||
} | ||
|
||
.preview-table__header { | ||
font-size: 12px; | ||
font-weight: 600; | ||
line-height: 16px; | ||
padding-bottom: 12px; | ||
} | ||
|
||
.preview-table__data { | ||
font-size: 12px; | ||
font-weight: 400; | ||
line-height: 16px; | ||
padding-bottom: 8px; | ||
} | ||
|
||
.preview-table__small { | ||
margin: 30px 32px; | ||
|
||
.preview-table__header, | ||
.preview-table__data { | ||
text-align: left; | ||
padding-right: 32px; | ||
} | ||
} | ||
|
||
.preview-table__large { | ||
margin: auto 30px 30px auto; | ||
|
||
.preview-table__header, | ||
.preview-table__data { | ||
padding: 12px 42px 12px 22px; | ||
text-align: left; | ||
} | ||
} | ||
|
||
.preview-table__row:hover { | ||
background: var(--color-highlight); | ||
cursor: pointer; | ||
} | ||
|
||
.preview-table__header, | ||
.preview-table__data { | ||
position: relative; | ||
outline: 0; | ||
} | ||
|
||
.preview-table__header:hover { | ||
cursor: pointer; | ||
} | ||
|
||
.preview-table__header:hover::after { | ||
background: var(--color-highlight); | ||
content: ''; | ||
height: 100vh; | ||
left: 0; | ||
position: absolute; | ||
top: -12px; | ||
width: 95%; | ||
z-index: -1; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Supporting Spark and launch would be a really nice stretch goal, but not a dealbreaker