Skip to content

Commit 37e4018

Browse files
author
Michael Baumann
committed
Change get_execution_context to work better in the common cases
Currently, there is not enough reliable information available to accurately determine the execution environment and execution platform. Until that is available, change get_execution_context to provide better values for the most common cases.
1 parent d6d42d7 commit 37e4018

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

terra_notebook_utils/utils.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,19 @@ def is_notebook() -> bool:
7272
def get_execution_context() -> ExecutionContext:
7373
"""
7474
Identify information about the context in which terra-notebook-utils is executing.
75-
Currently, this determination is made based on the presence and value of the WORKSPACE_BUCKET.
76-
Other/improved means may be identified in the future.
75+
TODO Improve the information available and algorithm to identify these values accurately!
7776
"""
78-
execution_environment = ExecutionEnvironment.OTHER
77+
# Workaround current insufficient information by assuming
78+
# the execution environment is Terra, as that is the most
79+
# common and important case.
80+
# execution_environment = ExecutionEnvironment.OTHER
81+
execution_environment = ExecutionEnvironment.TERRA_WORKSPACE
7982
execution_platform = ExecutionPlatform.UNKNOWN
8083
workspace_bucket = os.environ.get('WORKSPACE_BUCKET', None)
81-
if workspace_bucket:
82-
execution_environment = ExecutionEnvironment.TERRA_WORKSPACE
83-
if workspace_bucket.startswith("gs://"):
84-
execution_platform = ExecutionPlatform.GOOGLE
85-
elif workspace_bucket.startswith("https://"):
86-
execution_platform = ExecutionPlatform.AZURE
84+
if workspace_bucket and workspace_bucket.startswith("gs://"):
85+
execution_platform = ExecutionPlatform.GOOGLE
86+
else:
87+
# Workaround current insufficient information by assuming
88+
# the execution platform is not Google then it is Azure.
89+
execution_platform = ExecutionPlatform.AZURE
8790
return ExecutionContext(execution_environment, execution_platform)

0 commit comments

Comments
 (0)