Skip to content

Commit

Permalink
Merge 4f373cd into 459cdef
Browse files Browse the repository at this point in the history
  • Loading branch information
roblim committed Aug 21, 2019
2 parents 459cdef + 4f373cd commit 1a15db5
Show file tree
Hide file tree
Showing 5 changed files with 1,406 additions and 277 deletions.
8 changes: 8 additions & 0 deletions great_expectations/data_asset/data_asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ def __init__(self, *args, **kwargs):

if profiler is not None:
profiler.profile(self)
if data_context and hasattr(data_context, '_expectation_explorer_manager'):
self.set_default_expectation_argument("include_config", True)

def autoinspect(self, profiler):
"""Deprecated: use profile instead.
Expand Down Expand Up @@ -101,6 +103,10 @@ def profile(self, profiler):
expectation_suite, validation_results = profiler.profile(self)
return expectation_suite, validation_results

#TODO: add warning if no expectation_explorer_manager and how to turn on
def edit_expectation_suite(self):
return self._data_context._expectation_explorer_manager.edit_expectation_suite(self)

@classmethod
def expectation(cls, method_arg_names):
"""Manages configuration and running of expectation objects.
Expand Down Expand Up @@ -833,6 +839,7 @@ def save_expectation_suite(
else:
raise ValueError("Unable to save config: filepath or data_context must be available.")

#TODO: when validate is called and expectation editor is in data_context, need to bypass widget creation
def validate(self,
expectation_suite=None,
run_id=None,
Expand Down Expand Up @@ -998,6 +1005,7 @@ def validate(self,

result = expectation_method(
catch_exceptions=catch_exceptions,
include_config=True,
**evaluation_args
)

Expand Down
32 changes: 17 additions & 15 deletions great_expectations/data_context/data_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -1537,17 +1537,7 @@ def __init__(self, context_root_dir=None, data_asset_name_delimiter='/'):
# #TODO: Factor this out into a helper function in GE. It doesn't belong inside this method.
# # determine the "context root directory" - this is the parent of "great_expectations" dir
if context_root_dir is None:
if os.path.isdir("../notebooks") and os.path.isfile("../great_expectations.yml"):
context_root_dir = "../"
elif os.path.isdir("./great_expectations") and \
os.path.isfile("./great_expectations/great_expectations.yml"):
context_root_dir = "./great_expectations"
elif os.path.isdir("./") and os.path.isfile("./great_expectations.yml"):
context_root_dir = "./"
else:
raise DataContextError(
"Unable to locate context root directory. Please provide a directory name."
)
context_root_dir = self.find_context_root_dir()
context_root_directory = os.path.abspath(context_root_dir)
self._context_root_directory = context_root_directory

Expand Down Expand Up @@ -1595,17 +1585,30 @@ def add_datasource(self, name, type_, **kwargs):
super(DataContext, self).add_datasource(name, type_, **kwargs)
self._save_project_config()

def find_context_root_dir(self):
if os.path.isdir("../notebooks") and os.path.isfile("../great_expectations.yml"):
return "../"
elif os.path.isdir("./great_expectations") and \
os.path.isfile("./great_expectations/great_expectations.yml"):
return "./great_expectations"
elif os.path.isdir("./") and os.path.isfile("./great_expectations.yml"):
return "./"
else:
raise DataContextError(
"Unable to locate context root directory. Please provide a directory name."
)


class ExplorerDataContext(ConfigOnlyDataContext):
class ExplorerDataContext(DataContext):

def __init__(self, config, expectation_explorer=False, data_asset_name_delimiter='/'):
def __init__(self, context_root_dir=None, expectation_explorer=True, data_asset_name_delimiter='/'):
"""
expectation_explorer: If True, load the expectation explorer manager, which will modify GE return objects \
to include ipython notebook widgets.
"""

super(ExplorerDataContext, self).__init__(
config,
context_root_dir,
data_asset_name_delimiter,
)

Expand All @@ -1624,7 +1627,6 @@ def update_return_obj(self, data_asset, return_obj):
Returns:
return_obj: the return object, potentially changed into a widget by the configured expectation explorer
"""
return return_obj
if self._expectation_explorer:
return self._expectation_explorer_manager.create_expectation_widget(data_asset, return_obj)
else:
Expand Down

0 comments on commit 1a15db5

Please sign in to comment.