예제 #1
0
 def _get_run_link(self, tracking_uri, run_id):
     # if using the default Databricks tracking URI and in a notebook, we can automatically
     # figure out the run-link.
     if is_databricks_default_tracking_uri(tracking_uri) and (
             is_in_databricks_notebook() or is_in_databricks_job()):
         # use DBUtils to determine workspace information.
         workspace_host, workspace_id = get_workspace_info_from_dbutils()
     else:
         # in this scenario, we're not able to automatically extract the workspace ID
         # to proceed, and users will need to pass in a databricks profile with the scheme:
         # databricks://scope:prefix and store the host and workspace-ID as a secret in the
         # Databricks Secret Manager with scope=<scope> and key=<prefix>-workspaceid.
         workspace_host, workspace_id = get_workspace_info_from_databricks_secrets(
             tracking_uri)
         if not workspace_id:
             print(
                 "No workspace ID specified; if your Databricks workspaces share the same"
                 " host URL, you may want to specify the workspace ID (along with the host"
                 " information in the secret manager) for run lineage tracking. For more"
                 " details on how to specify this information in the secret manager,"
                 " please refer to the model registry documentation.")
     # retrieve experiment ID of the run for the URL
     experiment_id = self.get_run(run_id).info.experiment_id
     if workspace_host and run_id and experiment_id:
         return construct_run_url(workspace_host, experiment_id, run_id,
                                  workspace_id)
def test_no_throw():
    """
    Outside of Databricks the databricks_utils methods should never throw and should only return
    None.
    """
    assert not databricks_utils.is_in_databricks_notebook()
    assert not databricks_utils.is_in_databricks_job()
    assert not databricks_utils.is_dbfs_fuse_available()
예제 #3
0
    def request_headers(self):
        request_headers = {}
        if databricks_utils.is_in_databricks_notebook():
            request_headers["notebook_id"] = databricks_utils.get_notebook_id()
        if databricks_utils.is_in_databricks_job():
            request_headers["job_id"] = databricks_utils.get_job_id()
            request_headers["job_run_id"] = databricks_utils.get_job_run_id()
            request_headers["job_type"] = databricks_utils.get_job_type()
        if databricks_utils.is_in_cluster():
            request_headers["cluster_id"] = databricks_utils.get_cluster_id()

        return request_headers
예제 #4
0
def is_flavor_supported_for_associated_package_versions(flavor_name):
    """
    :return: True if the specified flavor is supported for the currently-installed versions of its
             associated packages
    """
    module_name, module_key = FLAVOR_TO_MODULE_NAME_AND_VERSION_INFO_KEY[
        flavor_name]
    actual_version = importlib.import_module(module_name).__version__

    # In Databricks, treat 'pyspark 3.x.y.dev0' as 'pyspark 3.x.y'
    if module_name == "pyspark" and (is_in_databricks_notebook()
                                     or is_in_databricks_job()):
        actual_version = _strip_dev_version_suffix(actual_version)

    if _violates_pep_440(actual_version) or _is_pre_or_dev_release(
            actual_version):
        return False
    min_version, max_version, _ = get_min_max_version_and_pip_release(
        module_key)
    return _check_version_in_range(actual_version, min_version, max_version)
예제 #5
0
 def in_context(self):
     return databricks_utils.is_in_databricks_job()
 def in_context(self):
     return (databricks_utils.is_in_cluster()
             or databricks_utils.is_in_databricks_notebook()
             or databricks_utils.is_in_databricks_job())
 def in_context(self):
     return (databricks_utils.is_in_databricks_job()
             and databricks_utils.get_job_type_info() == "NORMAL")