Skip to content

Commit

Permalink
[Runtimes] Set jobs dbpath from configuration instead of client [Back…
Browse files Browse the repository at this point in the history
…port 0.5.x] (#581)
  • Loading branch information
Hedingber committed Dec 9, 2020
1 parent 06c2608 commit 03aa8d1
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 13 deletions.
2 changes: 2 additions & 0 deletions mlrun/config.py
Expand Up @@ -88,6 +88,8 @@
# allowed to be scheduled to run more then 2 times in X. Can't be less then 1 minute
"min_allowed_interval": "10 minutes"
},
# The API needs to know what is its k8s svc url so it could enrich it in the jobs it creates
"api_url": "",
},
}

Expand Down
7 changes: 3 additions & 4 deletions mlrun/runtimes/base.py
Expand Up @@ -93,14 +93,13 @@ def __init__(
workdir=None,
default_handler=None,
pythonpath=None,
rundb=None,
):

self.command = command or ""
self.image = image or ""
self.mode = mode
self.args = args or []
self.rundb = rundb
self.rundb = None
self.description = description or ""
self.workdir = workdir
self.pythonpath = pythonpath
Expand Down Expand Up @@ -482,8 +481,8 @@ def _generate_runtime_env(self, runobj: RunObject):
runtime_env = {"MLRUN_EXEC_CONFIG": runobj.to_json()}
if runobj.spec.verbose:
runtime_env["MLRUN_LOG_LEVEL"] = "debug"
if self.spec.rundb:
runtime_env["MLRUN_DBPATH"] = self.spec.rundb
if config.httpdb.api_url:
runtime_env["MLRUN_DBPATH"] = config.httpdb.api_url
if self.metadata.namespace or config.namespace:
runtime_env["MLRUN_NAMESPACE"] = self.metadata.namespace or config.namespace
return runtime_env
Expand Down
2 changes: 0 additions & 2 deletions mlrun/runtimes/daskjob.py
Expand Up @@ -70,7 +70,6 @@ def __init__(
min_replicas=None,
max_replicas=None,
scheduler_timeout=None,
rundb=None,
):

super().__init__(
Expand All @@ -90,7 +89,6 @@ def __init__(
entry_points=entry_points,
description=description,
image_pull_secret=image_pull_secret,
rundb=rundb,
)
self.args = args

Expand Down
6 changes: 3 additions & 3 deletions mlrun/runtimes/function.py
Expand Up @@ -251,7 +251,6 @@ def deploy(
self.metadata.project = project
if tag:
self.metadata.tag = tag
self._ensure_run_db()
state = ""
last_log_timestamp = 1

Expand Down Expand Up @@ -283,6 +282,7 @@ def deploy(

else:
self.save(versioned=False)
self._ensure_run_db()
address = deploy_nuclio_function(self, dashboard=dashboard, watch=True)
if address:
self.spec.command = "http://{}".format(address)
Expand Down Expand Up @@ -321,8 +321,8 @@ def _get_state(self, dashboard="", last_log_timestamp=None, verbose=False):
def _get_runtime_env(self):
# for runtime specific env var enrichment (before deploy)
runtime_env = {}
if self.spec.rundb:
runtime_env["MLRUN_DBPATH"] = self.spec.rundb
if self.spec.rundb or mlconf.httpdb.api_url:
runtime_env["MLRUN_DBPATH"] = self.spec.rundb or mlconf.httpdb.api_url
if mlconf.namespace:
runtime_env["MLRUN_NAMESPACE"] = mlconf.namespace
return runtime_env
Expand Down
2 changes: 0 additions & 2 deletions mlrun/runtimes/pod.py
Expand Up @@ -43,7 +43,6 @@ def __init__(
service_account=None,
build=None,
image_pull_secret=None,
rundb=None,
):
super().__init__(
command=command,
Expand All @@ -55,7 +54,6 @@ def __init__(
description=description,
workdir=workdir,
default_handler=default_handler,
rundb=rundb,
)
self._volumes = {}
self._volume_mounts = {}
Expand Down
2 changes: 0 additions & 2 deletions mlrun/runtimes/sparkjob.py
Expand Up @@ -106,7 +106,6 @@ def __init__(
restart_policy=None,
deps=None,
main_class=None,
rundb=None,
):

super().__init__(
Expand All @@ -122,7 +121,6 @@ def __init__(
image_pull_policy=image_pull_policy,
service_account=service_account,
image_pull_secret=image_pull_secret,
rundb=rundb,
)

self.driver_resources = driver_resources
Expand Down

0 comments on commit 03aa8d1

Please sign in to comment.