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

[KED-2997] Create rename run and edit notes UI behavior #665

Merged
merged 44 commits into from
Jan 6, 2022
Merged
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
2494eb0
add pencil/edit icon; create run-details modal; open/close of that mo…
tynandebold Dec 2, 2021
0bcf22c
add basic text area in modal
tynandebold Dec 3, 2021
96b0992
Merge branch 'main' of https://github.com/quantumblacklabs/kedro-viz …
tynandebold Dec 6, 2021
fe10f11
local creation of an Input component
tynandebold Dec 6, 2021
2e90f22
create ui folder and add generic textarea and input components
tynandebold Dec 6, 2021
01623a5
use text-decoration for active state
tynandebold Dec 6, 2021
ce09a90
modal gets dynamic data from selected run
tynandebold Dec 6, 2021
15a9690
run details modal tests
tynandebold Dec 7, 2021
e1c08f3
rename textarea to input and use that in modal; remove other input co…
tynandebold Dec 7, 2021
d644efd
test written for input component
tynandebold Dec 7, 2021
7707e34
Merge branch 'main' of https://github.com/quantumblacklabs/kedro-viz …
tynandebold Dec 7, 2021
a9e64b3
updates based on PR review
tynandebold Dec 10, 2021
b175e38
Merge branch 'main' of https://github.com/quantumblacklabs/kedro-viz …
tynandebold Dec 10, 2021
f3a45e0
Rashida's PR reviews; hide edit run button when comparison view is on
tynandebold Dec 14, 2021
1e7f703
Merge branch 'main' of https://github.com/quantumblacklabs/kedro-viz …
tynandebold Dec 14, 2021
810b2a0
Merge branch 'main' of https://github.com/quantumblacklabs/kedro-viz …
tynandebold Dec 17, 2021
9b5fbc9
fix typos; update general edit run modal behavior
tynandebold Dec 17, 2021
1681b4f
Merge branch 'main' of https://github.com/quantumblacklabs/kedro-viz …
tynandebold Dec 17, 2021
29919f9
add runDetails mutation
tynandebold Dec 20, 2021
48c9b8a
remove searchable text; add client to mutation so tests pass
tynandebold Jan 4, 2022
bccfdda
Merge branch 'main' of https://github.com/quantumblacklabs/kedro-viz …
tynandebold Jan 4, 2022
c59b945
don't format schema
tynandebold Jan 4, 2022
40acffd
Update backend schema
rashidakanchwala Jan 4, 2022
b79e682
Fixed mypy error
rashidakanchwala Jan 4, 2022
bb7d883
fixed mypy2
rashidakanchwala Jan 4, 2022
5db44d8
fixed pylint error
rashidakanchwala Jan 4, 2022
2c6f708
update to id from runId in graphql response
rashidakanchwala Jan 4, 2022
f595229
update run_id to id in response -2
rashidakanchwala Jan 4, 2022
63a1320
UpdateRunDetails returns Run
rashidakanchwala Jan 4, 2022
84173ac
correct response from updateRunDetails mutation; reset mutation on er…
tynandebold Jan 5, 2022
c35efe5
fix run-selection anomoly
tynandebold Jan 5, 2022
1abf75a
fix failing RunDetailsModal test
tynandebold Jan 5, 2022
eba39f5
update mutation response
tynandebold Jan 5, 2022
471d03d
Merge branch 'main' of https://github.com/quantumblacklabs/kedro-viz …
tynandebold Jan 5, 2022
327a71b
use the Modal component from the repo, not the QB UI one
tynandebold Jan 5, 2022
dcefcca
fix failing RunDetailsModal test
tynandebold Jan 5, 2022
88f9732
Merge branch 'main' of https://github.com/quantumblacklabs/kedro-viz …
tynandebold Jan 6, 2022
e6fd526
remove working_directory from circleci
tynandebold Jan 6, 2022
f04307e
add working_directory to build_38
tynandebold Jan 6, 2022
3466a2d
use tmp folder instead of repo
tynandebold Jan 6, 2022
ca51744
revert and use arch
tynandebold Jan 6, 2022
27f13cf
revert by removing working_directory from build_38 and test build again
tynandebold Jan 6, 2022
b14fb2f
clear input on trigger; remove arch from circle ci
tynandebold Jan 6, 2022
18db979
Merge branch 'main' of https://github.com/quantumblacklabs/kedro-viz …
tynandebold Jan 6, 2022
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
33 changes: 16 additions & 17 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ commands:
steps:
- run:
name: Install Node dependencies
command: npm install
command: npm install

test_lib_transpilation:
steps:
Expand Down Expand Up @@ -125,8 +125,8 @@ commands:
- checkout
- restore_cache:
keys:
- v${CACHE_VERSION}-dependencies-{{ checksum "package.json" }}
- v${CACHE_VERSION}-dependencies-
- v${CACHE_VERSION}-{{ arch }}-dependencies-{{ checksum "package.json" }}
- v${CACHE_VERSION}-{{ arch }}-dependencies-
Copy link
Contributor

Choose a reason for hiding this comment

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

are these changes relevant to this PR?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sort of. They're an addendum to what @limdauto did yesterday.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yea this is needed to separate linux cache from windows cache in CI.

- install_node_dependencies
- build_npm_package
- run:
Expand All @@ -146,9 +146,9 @@ commands:
- checkout
- restore_cache:
keys:
- v${CACHE_VERSION}-dependencies-{{ checksum "package.json" }}
- v${CACHE_VERSION}-{{ arch }}-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v${CACHE_VERSION}-dependencies-
- v${CACHE_VERSION}-{{ arch }}-dependencies-
- install_node_dependencies
- build_npm_package
- add_ssh_keys:
Expand All @@ -166,24 +166,24 @@ commands:
git commit -m 'Demo build [ci skip]'
git remote add origin https://github.com/quantumblacklabs/kedro-viz.git
git push origin gh-pages --force

build:
description: Run build
steps:
- checkout
- restore_cache:
keys:
- v${CACHE_VERSION}-dependencies-{{ checksum "package.json" }}-{{ checksum "package/requirements.txt" }}-{{ checksum "package/test_requirements.txt" }}
- v${CACHE_VERSION}-{{ arch }}-dependencies-{{ checksum "package.json" }}-{{ checksum "package/requirements.txt" }}-{{ checksum "package/test_requirements.txt" }}
# fallback to using the latest cache if no exact match is found
- v${CACHE_VERSION}-dependencies-
- v${CACHE_VERSION}-{{ arch }}-dependencies-
- setup_python_env
- install_node_dependencies
- save_cache:
paths:
- node_modules
- /home/circleci/.venvs/kedro-viz
- /home/circleci/.cache/pip/
key: v${CACHE_VERSION}-dependencies-{{ checksum "package.json" }}-{{ checksum "package/requirements.txt" }}-{{ checksum "package/test_requirements.txt" }}
key: v${CACHE_VERSION}-{{ arch }}-dependencies-{{ checksum "package.json" }}-{{ checksum "package/requirements.txt" }}-{{ checksum "package/test_requirements.txt" }}
- test_lib_transpilation
- test_lib_import
- run_eslint
Expand Down Expand Up @@ -236,9 +236,9 @@ commands:
- checkout
- restore_cache:
keys:
- v${CACHE_VERSION}-dependencies-{{ checksum "package.json" }}-{{ checksum "package/requirements.txt" }}-{{ checksum "package/test_requirements.txt" }}
- v${CACHE_VERSION}-{{ arch }}-dependencies-{{ checksum "package.json" }}-{{ checksum "package/requirements.txt" }}-{{ checksum "package/test_requirements.txt" }}
# fallback to using the latest cache if no exact match is found
- v${CACHE_VERSION}-dependencies-
- v${CACHE_VERSION}-{{ arch }}-dependencies-
- win_setup_conda
- win_setup_requirements
- install_node_dependencies
Expand All @@ -247,7 +247,7 @@ commands:
- node_modules
- c:\tools\miniconda3\envs\kedro-viz\
- c:\users\circleci\appdata\local\pip\cache\
key: v${CACHE_VERSION}-dependencies-{{ checksum "package.json" }}-{{ checksum "package/requirements.txt" }}-{{ checksum "package/test_requirements.txt" }}
key: v${CACHE_VERSION}-{{ arch }}-dependencies-{{ checksum "package.json" }}-{{ checksum "package/requirements.txt" }}-{{ checksum "package/test_requirements.txt" }}
- run:
name: Run Python unit tests
command: |
Expand All @@ -264,7 +264,6 @@ commands:
behave

jobs:

build_37:
executor: circleci_machine
environment:
Expand Down Expand Up @@ -308,8 +307,8 @@ jobs:
- checkout
- restore_cache:
keys:
- v${CACHE_VERSION}-dependencies-{{ checksum "package.json" }}
- v${CACHE_VERSION}-dependencies-
- v${CACHE_VERSION}-{{ arch }}-dependencies-{{ checksum "package.json" }}
- v${CACHE_VERSION}-{{ arch }}-dependencies-
- install_node_dependencies
- build_npm_package
- run:
Expand All @@ -328,9 +327,9 @@ jobs:
- checkout
- restore_cache:
keys:
- v${CACHE_VERSION}-dependencies-{{ checksum "package.json" }}
- v${CACHE_VERSION}-{{ arch }}-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v${CACHE_VERSION}-dependencies-
- v${CACHE_VERSION}-{{ arch }}-dependencies-
- setup_python_env
- run:
name: Install twine
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"snyk-test": "snyk test -prune-repeated-subdependencies"
},
"dependencies": {
"@apollo/client": "^3.5.5",
"@apollo/client": "^3.5.6",
"@graphql-tools/schema": "7.1.5",
"@material-ui/core": "^4.11.4",
"@material-ui/icons": "^4.11.2",
Expand Down Expand Up @@ -138,4 +138,4 @@
"not op_mini all"
],
"snyk": true
}
}
81 changes: 57 additions & 24 deletions package/kedro_viz/api/graphql.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class JSONObject(dict):
https://github.com/python/mypy/issues/2477
"""


else:
JSONObject = strawberry.scalar(
NewType("JSONObject", dict),
Expand All @@ -46,7 +47,11 @@ def format_run(run_id: str, run_blob: Dict) -> Run:
"""
session = data_access_manager.db_session
git_data = run_blob.get("git")
user_details = session.query(UserRunDetailsModel).filter(UserRunDetailsModel.run_id == run_id).scalar()
user_details = (
session.query(UserRunDetailsModel)
.filter(UserRunDetailsModel.run_id == run_id)
.scalar()
)
run = Run(
id=ID(run_id),
author="",
Expand Down Expand Up @@ -95,7 +100,9 @@ def get_all_runs() -> List[Run]:
return runs


def format_run_tracking_data(tracking_data: Dict, show_diff: Optional[bool] = False) -> JSONObject:
def format_run_tracking_data(
tracking_data: Dict, show_diff: Optional[bool] = False
) -> JSONObject:
"""Convert tracking data in the front-end format.
Args:
Expand Down Expand Up @@ -140,7 +147,9 @@ def format_run_tracking_data(tracking_data: Dict, show_diff: Optional[bool] = Fa

for run_id, run_tracking_data in tracking_data.items():
for tracking_name, data in run_tracking_data.items():
formatted_tracking_data[tracking_name].append({"runId": run_id, "value": data})
formatted_tracking_data[tracking_name].append(
{"runId": run_id, "value": data}
)
if not show_diff:
for tracking_key, run_tracking_data in list(formatted_tracking_data.items()):
if len(run_tracking_data) != len(tracking_data):
Expand All @@ -149,7 +158,9 @@ def format_run_tracking_data(tracking_data: Dict, show_diff: Optional[bool] = Fa
return JSONObject(formatted_tracking_data)


def get_run_tracking_data(run_ids: List[ID], show_diff: Optional[bool] = False) -> List[TrackingDataset]:
def get_run_tracking_data(
run_ids: List[ID], show_diff: Optional[bool] = False
) -> List[TrackingDataset]:
# pylint: disable=protected-access,import-outside-toplevel
"""Get all tracking data for a list of runs. Tracking data contains the data from the
tracking MetricsDataSet and JSONDataSet instances that have been logged
Expand Down Expand Up @@ -179,7 +190,9 @@ def get_run_tracking_data(run_ids: List[ID], show_diff: Optional[bool] = False)
run_id = ID(run_id)
file_path = dataset._get_versioned_path(str(run_id))
if Path(file_path).is_file():
with dataset._fs.open(file_path, **dataset._fs_open_args_load) as fs_file:
with dataset._fs.open(
file_path, **dataset._fs_open_args_load
) as fs_file:
json_data = json.load(fs_file)
all_runs[run_id] = json_data
else:
Expand Down Expand Up @@ -238,7 +251,9 @@ def run_metadata(self, run_ids: List[ID]) -> List[Run]:
return get_runs(run_ids)

@strawberry.field
def run_tracking_data(self, run_ids: List[ID], show_diff: Optional[bool] = False) -> List[TrackingDataset]:
def run_tracking_data(
self, run_ids: List[ID], show_diff: Optional[bool] = False
) -> List[TrackingDataset]:
"""Query to get data for specific runs from the session store"""
return get_run_tracking_data(run_ids, show_diff)

Expand All @@ -261,18 +276,20 @@ class RunInput:
class UpdateRunDetailsSuccess:
"""Response type for sucessful update of runs"""

run_details: JSONObject
run: Run


@strawberry.type
class UpdateRunDetailsFailure:
"""Response type for failed update of runs"""

run_id: ID
id: ID
error_message: str


Response = strawberry.union("UpdateRunDetailsResponse", (UpdateRunDetailsSuccess, UpdateRunDetailsFailure))
Response = strawberry.union(
"UpdateRunDetailsResponse", (UpdateRunDetailsSuccess, UpdateRunDetailsFailure)
)


@strawberry.type
Expand All @@ -284,34 +301,50 @@ def update_run_details(self, run_id: ID, run_input: RunInput) -> Response:
"""Updates run details based on run inputs provided by user"""
runs = get_runs([run_id])
if not runs:
return UpdateRunDetailsFailure(run_id=run_id, error_message=f"Given run_id: {run_id} doesn't exist")
return UpdateRunDetailsFailure(
id=run_id, error_message=f"Given run_id: {run_id} doesn't exist"
)
existing_run = runs[0]
updated_user_run_details = {
"run_id": run_id,
"bookmark": run_input.bookmark if run_input.bookmark is not None else existing_run.bookmark,
"notes": run_input.notes if run_input.notes is not None else existing_run.notes,
}

new_run = existing_run
# if user doesn't provide a new title, use the old title.
if run_input.title is None:
updated_user_run_details["title"] = existing_run.title
new_run.title = existing_run.title
# if user provides an empty title, we assume they want to revert to the old timestamp title
elif run_input.title.strip() == "":
updated_user_run_details["title"] = existing_run.timestamp
new_run.title = existing_run.timestamp
else:
updated_user_run_details["title"] = run_input.title
new_run.title = run_input.title

new_run.bookmark = (
run_input.bookmark
if run_input.bookmark is not None
else existing_run.bookmark
)

new_run.notes = (
run_input.notes if run_input.notes is not None else existing_run.notes
)

updated_user_run_details = {
"run_id": run_id,
"title": new_run.title,
"bookmark": new_run.bookmark,
"notes": new_run.notes,
}

session = data_access_manager.db_session
user_run_details = session.query(UserRunDetailsModel).filter(UserRunDetailsModel.run_id == run_id).first()
user_run_details = (
session.query(UserRunDetailsModel)
.filter(UserRunDetailsModel.run_id == run_id)
.first()
)
if not user_run_details:
session.add(UserRunDetailsModel(**updated_user_run_details)) # type: ignore
session.add(UserRunDetailsModel(**updated_user_run_details)) # type: ignore
else:
for key, value in updated_user_run_details.items():
setattr(user_run_details, key, value)
session.commit()
return UpdateRunDetailsSuccess(
run_details=JSONObject(updated_user_run_details)
)
return UpdateRunDetailsSuccess(new_run)


schema = strawberry.Schema(query=Query, mutation=Mutation)
Expand Down
2 changes: 1 addition & 1 deletion package/kedro_viz/integrations/kedro/sqlite_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def to_json(self) -> str:

branch = git.Repo(search_parent_directories=True).active_branch
value["branch"] = branch.name
except ImportError as exc: # pragma: no cover
except ImportError as exc: # pragma: no cover
logger.warning("%s:%s", exc.__class__.__name__, exc.msg)

if _is_json_serializable(value):
Expand Down
Loading