-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OSS Nux] Add kill switch + persist Nux dismissal in temp folder (#11758
) ### Summary & Motivation Couple of changes: 1. Only show the Nux if you're on localhost 2. Persist that we dismissed the nux in the directory we use for telemetry too 3. Add killswitch to completely disable this For the kill switch in dagser.yaml we need to add ``` nux: enabled: False ``` ### How I Tested These Changes Unit tests for the graphql Made sure the file was persisted and stayed past restarts but wasn't sure how to effectively test this in python. <img width="770" alt="Screen Shot 2023-01-17 at 5 58 23 PM" src="https://user-images.githubusercontent.com/2286579/213030927-26d05434-eb6c-4015-8a84-6f0255340e53.png">
- Loading branch information
Showing
8 changed files
with
132 additions
and
3 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
30 changes: 30 additions & 0 deletions
30
python_modules/dagster-graphql/dagster_graphql_tests/graphql/test_nux.py
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,30 @@ | ||
from dagster_graphql.test.utils import ( | ||
execute_dagster_graphql, | ||
) | ||
|
||
SET_NUX_SEEN_MUTATION = """ | ||
mutation SetNuxSeen { | ||
setNuxSeen | ||
} | ||
""" | ||
|
||
GET_SHOULD_SHOW_NUX_QUERY = """ | ||
query ShouldShowNux { | ||
shouldShowNux | ||
} | ||
""" | ||
|
||
|
||
def test_stores_nux_seen_state(graphql_context): | ||
result = execute_dagster_graphql(graphql_context, GET_SHOULD_SHOW_NUX_QUERY) | ||
assert not result.errors | ||
assert result.data | ||
assert result.data["shouldShowNux"] is True | ||
|
||
execute_dagster_graphql(graphql_context, SET_NUX_SEEN_MUTATION) | ||
|
||
result = execute_dagster_graphql(graphql_context, GET_SHOULD_SHOW_NUX_QUERY) | ||
assert not result.errors | ||
assert result.data | ||
assert result.data["shouldShowNux"] is False |
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,28 @@ | ||
import os | ||
|
||
import yaml | ||
|
||
from dagster._core.telemetry import get_or_create_dir_from_dagster_home | ||
|
||
NUX_FILE_STR = "nux.yaml" | ||
|
||
|
||
# Filepath for where we store if we've seen the nux | ||
def nux_seen_filepath(): | ||
return os.path.join(get_or_create_dir_from_dagster_home(".nux"), "nux.yaml") | ||
|
||
|
||
# Sets whether we've shown the Nux to any user on this instance | ||
def set_nux_seen(): | ||
try: # In case we encounter an error while writing to user's file system | ||
with open(nux_seen_filepath(), "w", encoding="utf8") as nux_seen_file: | ||
# the contents of the file dont matter, we just check that it exists, but lets write seen: True here anyways. | ||
yaml.dump({"seen": 1}, nux_seen_file, default_flow_style=False) | ||
except Exception: | ||
return "<<unable_to_write_nux_seen>>" | ||
|
||
|
||
# Gets whether we've shown the Nux to any user on this instance | ||
def get_has_seen_nux(): | ||
# We only care about the existence of the file | ||
return os.path.exists(nux_seen_filepath()) |