mlrun 1.10.0rc2__py3-none-any.whl → 1.10.0rc3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of mlrun might be problematic. Click here for more details.

Files changed (50) hide show
  1. mlrun/__init__.py +2 -2
  2. mlrun/__main__.py +2 -2
  3. mlrun/artifacts/base.py +6 -6
  4. mlrun/artifacts/dataset.py +1 -1
  5. mlrun/artifacts/document.py +1 -1
  6. mlrun/artifacts/model.py +1 -1
  7. mlrun/artifacts/plots.py +2 -2
  8. mlrun/common/runtimes/constants.py +1 -8
  9. mlrun/common/schemas/artifact.py +1 -1
  10. mlrun/common/schemas/pipeline.py +1 -1
  11. mlrun/common/schemas/project.py +1 -1
  12. mlrun/common/schemas/runs.py +1 -1
  13. mlrun/config.py +4 -4
  14. mlrun/datastore/datastore_profile.py +2 -2
  15. mlrun/datastore/sources.py +3 -3
  16. mlrun/datastore/store_resources.py +3 -3
  17. mlrun/datastore/targets.py +5 -5
  18. mlrun/datastore/utils.py +2 -2
  19. mlrun/db/base.py +6 -6
  20. mlrun/db/httpdb.py +66 -66
  21. mlrun/errors.py +22 -1
  22. mlrun/feature_store/common.py +5 -5
  23. mlrun/feature_store/feature_set.py +10 -6
  24. mlrun/feature_store/feature_vector.py +8 -6
  25. mlrun/launcher/base.py +1 -1
  26. mlrun/lists.py +1 -1
  27. mlrun/model_monitoring/__init__.py +0 -1
  28. mlrun/model_monitoring/api.py +0 -44
  29. mlrun/model_monitoring/applications/evidently/base.py +3 -41
  30. mlrun/model_monitoring/controller.py +1 -1
  31. mlrun/model_monitoring/writer.py +1 -4
  32. mlrun/projects/operations.py +3 -3
  33. mlrun/projects/project.py +19 -19
  34. mlrun/run.py +10 -10
  35. mlrun/runtimes/base.py +6 -6
  36. mlrun/runtimes/kubejob.py +2 -2
  37. mlrun/runtimes/nuclio/function.py +3 -3
  38. mlrun/runtimes/nuclio/serving.py +13 -23
  39. mlrun/serving/__init__.py +5 -1
  40. mlrun/serving/server.py +39 -3
  41. mlrun/serving/states.py +34 -1
  42. mlrun/utils/helpers.py +10 -4
  43. mlrun/utils/version/version.json +2 -2
  44. {mlrun-1.10.0rc2.dist-info → mlrun-1.10.0rc3.dist-info}/METADATA +21 -9
  45. {mlrun-1.10.0rc2.dist-info → mlrun-1.10.0rc3.dist-info}/RECORD +49 -50
  46. {mlrun-1.10.0rc2.dist-info → mlrun-1.10.0rc3.dist-info}/WHEEL +1 -1
  47. mlrun/model_monitoring/tracking_policy.py +0 -124
  48. {mlrun-1.10.0rc2.dist-info → mlrun-1.10.0rc3.dist-info}/entry_points.txt +0 -0
  49. {mlrun-1.10.0rc2.dist-info → mlrun-1.10.0rc3.dist-info}/licenses/LICENSE +0 -0
  50. {mlrun-1.10.0rc2.dist-info → mlrun-1.10.0rc3.dist-info}/top_level.txt +0 -0
@@ -333,12 +333,14 @@ class FeatureVector(ModelObj):
333
333
  @property
334
334
  def uri(self):
335
335
  """fully qualified feature vector uri"""
336
- uri = (
337
- f"{self._metadata.project or mlconf.default_project}/{self._metadata.name}"
338
- )
339
- uri = get_store_uri(StorePrefix.FeatureVector, uri)
336
+ project = self._metadata.project or mlconf.active_project
337
+ name = self._metadata.name
338
+
339
+ base = name if not project else f"{project}/{name}"
340
+ uri = get_store_uri(StorePrefix.FeatureVector, base)
341
+
340
342
  if self._metadata.tag:
341
- uri += ":" + self._metadata.tag
343
+ uri += f":{self._metadata.tag}"
342
344
  return uri
343
345
 
344
346
  def link_analysis(self, name, uri):
@@ -385,7 +387,7 @@ class FeatureVector(ModelObj):
385
387
  def save(self, tag="", versioned=False):
386
388
  """save to mlrun db"""
387
389
  db = mlrun.get_run_db()
388
- self.metadata.project = self.metadata.project or mlconf.default_project
390
+ self.metadata.project = self.metadata.project or mlconf.active_project
389
391
  tag = tag or self.metadata.tag
390
392
  as_dict = self.to_dict()
391
393
  db.store_feature_vector(as_dict, tag=tag, versioned=versioned)
mlrun/launcher/base.py CHANGED
@@ -273,7 +273,7 @@ class BaseLauncher(abc.ABC):
273
273
  project_name
274
274
  or run.metadata.project
275
275
  or runtime.metadata.project
276
- or mlrun.mlconf.default_project
276
+ or mlrun.mlconf.active_project
277
277
  )
278
278
  run.spec.parameters = params or run.spec.parameters
279
279
  run.spec.inputs = inputs or run.spec.inputs
mlrun/lists.py CHANGED
@@ -55,7 +55,7 @@ class RunList(list):
55
55
  for run in self:
56
56
  iterations = get_in(run, "status.iterations", "")
57
57
  row = [
58
- get_in(run, "metadata.project", config.default_project),
58
+ get_in(run, "metadata.project", config.active_project),
59
59
  get_in(run, "metadata.uid", ""),
60
60
  get_in(run, "metadata.iteration", ""),
61
61
  get_in(run, "status.start_time", ""),
@@ -16,4 +16,3 @@ from mlrun.common.schemas import ModelEndpoint, ModelEndpointList
16
16
 
17
17
  from .db import get_tsdb_connector
18
18
  from .helpers import get_stream_path
19
- from .tracking_policy import TrackingPolicy
@@ -14,7 +14,6 @@
14
14
 
15
15
  import hashlib
16
16
  import typing
17
- import warnings
18
17
  from datetime import datetime
19
18
 
20
19
  import numpy as np
@@ -136,12 +135,6 @@ def record_results(
136
135
  infer_results_df: typing.Optional[pd.DataFrame] = None,
137
136
  sample_set_statistics: typing.Optional[dict[str, typing.Any]] = None,
138
137
  monitoring_mode: mm_constants.ModelMonitoringMode = mm_constants.ModelMonitoringMode.enabled,
139
- # Deprecated arguments:
140
- drift_threshold: typing.Optional[float] = None,
141
- possible_drift_threshold: typing.Optional[float] = None,
142
- trigger_monitoring_job: bool = False,
143
- artifacts_tag: str = "",
144
- default_batch_image: str = "mlrun/mlrun",
145
138
  ) -> ModelEndpoint:
146
139
  """
147
140
  Write a provided inference dataset to model endpoint parquet target. If not exist, generate a new model endpoint
@@ -166,47 +159,10 @@ def record_results(
166
159
  the current model endpoint.
167
160
  :param monitoring_mode: If enabled, apply model monitoring features on the provided endpoint id. Enabled
168
161
  by default.
169
- :param drift_threshold: (deprecated) The threshold of which to mark drifts.
170
- :param possible_drift_threshold: (deprecated) The threshold of which to mark possible drifts.
171
- :param trigger_monitoring_job: (deprecated) If true, run the batch drift job. If not exists, the monitoring
172
- batch function will be registered through MLRun API with the provided image.
173
- :param artifacts_tag: (deprecated) Tag to use for all the artifacts resulted from the function.
174
- Will be relevant only if the monitoring batch job has been triggered.
175
- :param default_batch_image: (deprecated) The image that will be used when registering the model monitoring
176
- batch job.
177
162
 
178
163
  :return: A ModelEndpoint object
179
164
  """
180
165
 
181
- if drift_threshold is not None or possible_drift_threshold is not None:
182
- warnings.warn(
183
- "Custom drift threshold arguments are deprecated since version "
184
- "1.7.0 and have no effect. They will be removed in version 1.9.0.\n"
185
- "To enable the default histogram data drift application, run:\n"
186
- "`project.enable_model_monitoring()`.",
187
- FutureWarning,
188
- )
189
- if trigger_monitoring_job is not False:
190
- warnings.warn(
191
- "`trigger_monitoring_job` argument is deprecated since version "
192
- "1.7.0 and has no effect. It will be removed in version 1.9.0.\n"
193
- "To enable the default histogram data drift application, run:\n"
194
- "`project.enable_model_monitoring()`.",
195
- FutureWarning,
196
- )
197
- if artifacts_tag != "":
198
- warnings.warn(
199
- "`artifacts_tag` argument is deprecated since version "
200
- "1.7.0 and has no effect. It will be removed in version 1.9.0.",
201
- FutureWarning,
202
- )
203
- if default_batch_image != "mlrun/mlrun":
204
- warnings.warn(
205
- "`default_batch_image` argument is deprecated since version "
206
- "1.7.0 and has no effect. It will be removed in version 1.9.0.",
207
- FutureWarning,
208
- )
209
-
210
166
  db = mlrun.get_run_db()
211
167
 
212
168
  model_endpoint = get_or_create_model_endpoint(
@@ -12,8 +12,6 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- import json
16
- import posixpath
17
15
  import warnings
18
16
  from abc import ABC
19
17
  from tempfile import NamedTemporaryFile
@@ -60,7 +58,6 @@ except ModuleNotFoundError:
60
58
 
61
59
  if _HAS_EVIDENTLY:
62
60
  from evidently.core.report import Snapshot
63
- from evidently.legacy.ui.storage.local.base import METADATA_PATH, FSLocation
64
61
  from evidently.ui.workspace import (
65
62
  STR_UUID,
66
63
  CloudWorkspace,
@@ -100,14 +97,13 @@ class EvidentlyModelMonitoringApplicationBase(
100
97
  self.evidently_project_id = evidently_project_id
101
98
  self.evidently_project = self.load_project()
102
99
 
103
- def load_project(self) -> Project:
100
+ def load_project(self) -> "Project":
104
101
  """Load the Evidently project."""
105
102
  return self.evidently_workspace.get_project(self.evidently_project_id)
106
103
 
107
- def get_workspace(self) -> WorkspaceBase:
104
+ def get_workspace(self) -> "WorkspaceBase":
108
105
  """Get the Evidently workspace. Override this method for customize access to the workspace."""
109
106
  if self.evidently_workspace_path:
110
- self._log_location(self.evidently_workspace_path)
111
107
  return Workspace.create(self.evidently_workspace_path)
112
108
  else:
113
109
  raise MLRunValueError(
@@ -116,44 +112,10 @@ class EvidentlyModelMonitoringApplicationBase(
116
112
  "`EVIDENTLY_API_KEY` environment variable. In other cases, override this method."
117
113
  )
118
114
 
119
- def get_cloud_workspace(self) -> CloudWorkspace:
115
+ def get_cloud_workspace(self) -> "CloudWorkspace":
120
116
  """Load the Evidently cloud workspace according to the `EVIDENTLY_API_KEY` environment variable."""
121
117
  return CloudWorkspace()
122
118
 
123
- @staticmethod
124
- def _log_location(evidently_workspace_path):
125
- # TODO remove function + usage after solving issue ML-9530
126
- location = FSLocation(base_path=evidently_workspace_path)
127
- location.invalidate_cache("")
128
- paths = [p for p in location.listdir("") if location.isdir(p)]
129
-
130
- for path in paths:
131
- metadata_path = posixpath.join(path, METADATA_PATH)
132
- full_path = posixpath.join(location.path, metadata_path)
133
- print(f"evidently json issue, working on path: {full_path}")
134
- try:
135
- with location.open(metadata_path) as f:
136
- content = json.load(f)
137
- print(
138
- f"evidently json issue, successful load path: {full_path}, content: {content}"
139
- )
140
- except FileNotFoundError:
141
- print(f"evidently json issue, path not found: {full_path}")
142
- continue
143
- except json.decoder.JSONDecodeError as json_error:
144
- print(
145
- f"evidently json issue, path got json error, path:{full_path}, error: {json_error}"
146
- )
147
- print("evidently json issue, file content:")
148
- with location.open(metadata_path) as f:
149
- print(f.read())
150
- continue
151
- except Exception as error:
152
- print(
153
- f"evidently json issue, path got general error, path:{full_path}, error: {error}"
154
- )
155
- continue
156
-
157
119
  @staticmethod
158
120
  def log_evidently_object(
159
121
  monitoring_context: mm_context.MonitoringApplicationContext,
@@ -251,7 +251,7 @@ class MonitoringApplicationController:
251
251
 
252
252
  def __init__(self) -> None:
253
253
  """Initialize Monitoring Application Controller"""
254
- self.project = cast(str, mlrun.mlconf.default_project)
254
+ self.project = cast(str, mlrun.mlconf.active_project)
255
255
  self.project_obj = mlrun.get_run_db().get_project(name=self.project)
256
256
  logger.debug(f"Initializing {self.__class__.__name__}", project=self.project)
257
257
 
@@ -129,10 +129,7 @@ class ModelMonitoringWriter(StepToDict):
129
129
  )
130
130
  kind = event.pop(WriterEvent.EVENT_KIND, WriterEventKind.RESULT)
131
131
  result_event = _AppResultEvent(json.loads(event.pop(WriterEvent.DATA, "{}")))
132
- if not result_event: # BC for < 1.7.0, can be removed in 1.9.0
133
- result_event = _AppResultEvent(event)
134
- else:
135
- result_event.update(_AppResultEvent(event))
132
+ result_event.update(_AppResultEvent(event))
136
133
 
137
134
  expected_keys = list(
138
135
  set(WriterEvent.list()).difference(
@@ -309,9 +309,9 @@ def build_function(
309
309
  :param force_build: Force building the image, even when no changes were made
310
310
  """
311
311
  if not overwrite_build_params:
312
- # TODO: change overwrite_build_params default to True in 1.9.0
312
+ # TODO: change overwrite_build_params default to True in 1.10.0
313
313
  warnings.warn(
314
- "The `overwrite_build_params` parameter default will change from 'False' to 'True' in 1.9.0.",
314
+ "The `overwrite_build_params` parameter default will change from 'False' to 'True' in 1.10.0.",
315
315
  mlrun.utils.OverwriteBuildParamsWarning,
316
316
  )
317
317
 
@@ -340,7 +340,7 @@ def build_function(
340
340
  skip_deployed=skip_deployed,
341
341
  )
342
342
  else:
343
- # TODO: remove filter once overwrite_build_params default is changed to True in 1.9.0
343
+ # TODO: remove filter once overwrite_build_params default is changed to True in 1.10.0
344
344
  with warnings.catch_warnings():
345
345
  warnings.simplefilter(
346
346
  "ignore", category=mlrun.utils.OverwriteBuildParamsWarning
mlrun/projects/project.py CHANGED
@@ -278,7 +278,7 @@ def new_project(
278
278
  for key, val in parameters.items():
279
279
  project.spec.params[key] = val
280
280
 
281
- _set_as_current_default_project(project)
281
+ _set_as_current_active_project(project)
282
282
 
283
283
  if save and mlrun.mlconf.dbpath:
284
284
  if overwrite:
@@ -451,7 +451,7 @@ def load_project(
451
451
  if sync_functions:
452
452
  project.sync_functions(save=to_save)
453
453
 
454
- _set_as_current_default_project(project)
454
+ _set_as_current_active_project(project)
455
455
 
456
456
  return project
457
457
 
@@ -471,7 +471,7 @@ def get_or_create_project(
471
471
  allow_cross_project: Optional[bool] = None,
472
472
  ) -> "MlrunProject":
473
473
  """Load a project from MLRun DB, or create/import if it does not exist.
474
- The project will become the default project for the current session.
474
+ The project will become the active project for the current session.
475
475
 
476
476
  MLRun looks for a project.yaml file with project definition and objects in the project root path
477
477
  and use it to initialize the project, in addition it runs the project_setup.py file (if it exists)
@@ -757,10 +757,10 @@ def _project_instance_from_struct(struct, name, allow_cross_project):
757
757
  )
758
758
 
759
759
  if allow_cross_project is None:
760
- # TODO: Remove this warning in version 1.9.0 and also fix cli to support allow_cross_project
760
+ # TODO: Remove this warning in version 1.10.0 and also fix cli to support allow_cross_project
761
761
  warnings.warn(
762
762
  f"Project {name=} is different than specified on the context's project yaml. "
763
- "This behavior is deprecated and will not be supported from version 1.9.0."
763
+ "This behavior is deprecated and will not be supported from version 1.10.0."
764
764
  )
765
765
  logger.warn(error_message)
766
766
  elif allow_cross_project:
@@ -2479,9 +2479,9 @@ class MlrunProject(ModelObj):
2479
2479
  :param fetch_credentials_from_sys_config: If true, fetch the credentials from the system configuration.
2480
2480
  """
2481
2481
  if default_controller_image != "mlrun/mlrun":
2482
- # TODO: Remove this in 1.9.0
2482
+ # TODO: Remove this in 1.10.0
2483
2483
  warnings.warn(
2484
- "'default_controller_image' is deprecated and will be removed in 1.9.0, "
2484
+ "'default_controller_image' is deprecated in 1.7.0 and will be removed in 1.10.0, "
2485
2485
  "use 'image' instead",
2486
2486
  FutureWarning,
2487
2487
  )
@@ -2892,9 +2892,9 @@ class MlrunProject(ModelObj):
2892
2892
 
2893
2893
  :param name: name of the model-monitoring-function/s (under the project)
2894
2894
  """
2895
- # TODO: Remove this in 1.9.0
2895
+ # TODO: Remove this in 1.10.0
2896
2896
  warnings.warn(
2897
- "'remove_model_monitoring_function' is deprecated and will be removed in 1.9.0. "
2897
+ "'remove_model_monitoring_function' is deprecated in 1.7.0 and will be removed in 1.10.0. "
2898
2898
  "Please use `delete_model_monitoring_function` instead.",
2899
2899
  FutureWarning,
2900
2900
  )
@@ -4107,9 +4107,9 @@ class MlrunProject(ModelObj):
4107
4107
  (by default `/home/mlrun_code`)
4108
4108
  """
4109
4109
  if not overwrite_build_params:
4110
- # TODO: change overwrite_build_params default to True in 1.9.0
4110
+ # TODO: change overwrite_build_params default to True in 1.10.0
4111
4111
  warnings.warn(
4112
- "The `overwrite_build_params` parameter default will change from 'False' to 'True' in 1.9.0.",
4112
+ "The `overwrite_build_params` parameter default will change from 'False' to 'True' in 1.10.0.",
4113
4113
  mlrun.utils.OverwriteBuildParamsWarning,
4114
4114
  )
4115
4115
  default_image_name = mlrun.mlconf.default_project_image_name.format(
@@ -4186,9 +4186,9 @@ class MlrunProject(ModelObj):
4186
4186
  )
4187
4187
 
4188
4188
  if not overwrite_build_params:
4189
- # TODO: change overwrite_build_params default to True in 1.9.0
4189
+ # TODO: change overwrite_build_params default to True in 1.10.0
4190
4190
  warnings.warn(
4191
- "The `overwrite_build_params` parameter default will change from 'False' to 'True' in 1.9.0.",
4191
+ "The `overwrite_build_params` parameter default will change from 'False' to 'True' in 1.10.0.",
4192
4192
  mlrun.utils.OverwriteBuildParamsWarning,
4193
4193
  )
4194
4194
 
@@ -4516,7 +4516,7 @@ class MlrunProject(ModelObj):
4516
4516
  artifacts generated from a hyper-param run. If only a single iteration exists, will return the artifact
4517
4517
  from that iteration. If using ``best_iter``, the ``iter`` parameter must not be used.
4518
4518
  :param tree: Return artifacts of the requested tree.
4519
- :param limit: Maximum number of artifacts to return.
4519
+ :param limit: Deprecated - Maximum number of artifacts to return (will be removed in 1.11.0).
4520
4520
  :param format_: The format in which to return the artifacts. Default is 'full'.
4521
4521
  """
4522
4522
  db = mlrun.db.get_run_db(secrets=self._secrets)
@@ -4789,7 +4789,7 @@ class MlrunProject(ModelObj):
4789
4789
  :param states: List only runs whose state is one of the provided states.
4790
4790
  :param sort: Whether to sort the result according to their start time. Otherwise, results will be
4791
4791
  returned by their internal order in the DB (order will not be guaranteed).
4792
- :param last: Deprecated - currently not used (will be removed in 1.9.0).
4792
+ :param last: Deprecated - currently not used (will be removed in 1.10.0).
4793
4793
  :param iter: If ``True`` return runs from all iterations. Otherwise, return only runs whose ``iter`` is 0.
4794
4794
  :param start_time_from: Filter by run start time in ``[start_time_from, start_time_to]``.
4795
4795
  :param start_time_to: Filter by run start time in ``[start_time_from, start_time_to]``.
@@ -4800,9 +4800,9 @@ class MlrunProject(ModelObj):
4800
4800
  :param end_time_to: Filter by run end time in ``[end_time_from, end_time_to]``.
4801
4801
  """
4802
4802
  if state:
4803
- # TODO: Remove this in 1.9.0
4803
+ # TODO: Remove this in 1.10.0
4804
4804
  warnings.warn(
4805
- "'state' is deprecated and will be removed in 1.9.0. Use 'states' instead.",
4805
+ "'state' is deprecated in 1.7.0 and will be removed in 1.10.0. Use 'states' instead.",
4806
4806
  FutureWarning,
4807
4807
  )
4808
4808
 
@@ -5460,8 +5460,8 @@ class MlrunProject(ModelObj):
5460
5460
  return os.getenv("V3IO_USERNAME") or self.spec.owner
5461
5461
 
5462
5462
 
5463
- def _set_as_current_default_project(project: MlrunProject):
5464
- mlrun.mlconf.default_project = project.metadata.name
5463
+ def _set_as_current_active_project(project: MlrunProject):
5464
+ mlrun.mlconf.active_project = project.metadata.name
5465
5465
  pipeline_context.set(project)
5466
5466
 
5467
5467
 
mlrun/run.py CHANGED
@@ -223,7 +223,7 @@ def get_or_create_ctx(
223
223
  :param spec: dictionary holding run spec
224
224
  :param with_env: look for context in environment vars, default True
225
225
  :param rundb: path/url to the metadata and artifact database
226
- :param project: project to initiate the context in (by default `mlrun.mlconf.default_project`)
226
+ :param project: project to initiate the context in (by default `mlrun.mlconf.active_project`)
227
227
  :param upload_artifacts: when using local context (not as part of a job/run), upload artifacts to the
228
228
  system default artifact path location
229
229
  :param labels: (deprecated - use spec instead) dict of the context labels.
@@ -261,7 +261,7 @@ def get_or_create_ctx(
261
261
  """
262
262
  if labels:
263
263
  warnings.warn(
264
- "The `labels` argument is deprecated and will be removed in 1.9.0. "
264
+ "The `labels` argument is deprecated in 1.7.0 and will be removed in 1.10.0. "
265
265
  "Please use `spec` instead, e.g.:\n"
266
266
  "spec={'metadata': {'labels': {'key': 'value'}}}",
267
267
  FutureWarning,
@@ -298,7 +298,7 @@ def get_or_create_ctx(
298
298
  newspec = {}
299
299
  if upload_artifacts:
300
300
  artifact_path = mlrun.utils.helpers.template_artifact_path(
301
- mlconf.artifact_path, project or mlconf.default_project
301
+ mlconf.artifact_path, project or mlconf.active_project
302
302
  )
303
303
  update_in(newspec, ["spec", RunKeys.output_path], artifact_path)
304
304
 
@@ -312,7 +312,7 @@ def get_or_create_ctx(
312
312
  logger.info(f"Logging run results to: {out}")
313
313
 
314
314
  newspec["metadata"]["project"] = (
315
- newspec["metadata"].get("project") or project or mlconf.default_project
315
+ newspec["metadata"].get("project") or project or mlconf.active_project
316
316
  )
317
317
 
318
318
  newspec["metadata"].setdefault("labels", {})
@@ -369,9 +369,9 @@ def import_function(url="", secrets=None, db="", project=None, new_name=None):
369
369
  url, is_hub_uri = extend_hub_uri_if_needed(url)
370
370
  runtime = import_function_to_dict(url, secrets)
371
371
  function = new_function(runtime=runtime)
372
- project = project or mlrun.mlconf.default_project
372
+ project = project or mlrun.mlconf.active_project
373
373
  # When we're importing from the hub we want to assign to a target project, otherwise any store on it will
374
- # simply default to the default project
374
+ # simply default to the active project
375
375
  if project and is_hub_uri:
376
376
  function.metadata.project = project
377
377
  if new_name:
@@ -464,7 +464,7 @@ def new_function(
464
464
  f = new_function().run(task, handler=myfunction)
465
465
 
466
466
  :param name: function name
467
- :param project: function project (none for 'default')
467
+ :param project: function project (none for the active project)
468
468
  :param tag: function version tag (none for 'latest')
469
469
 
470
470
  :param kind: runtime type (local, job, nuclio, spark, mpijob, dask, ..)
@@ -523,7 +523,7 @@ def new_function(
523
523
 
524
524
  runner.metadata.name = name
525
525
  runner.metadata.project = (
526
- runner.metadata.project or project or mlconf.default_project
526
+ runner.metadata.project or project or mlconf.active_project
527
527
  )
528
528
  if tag:
529
529
  runner.metadata.tag = tag
@@ -640,7 +640,7 @@ def code_to_function(
640
640
  Learn more about :doc:`../../concepts/functions-overview`
641
641
 
642
642
  :param name: function name, typically best to use hyphen-case
643
- :param project: project used to namespace the function, defaults to 'default'
643
+ :param project: project used to namespace the function, defaults to the active project
644
644
  :param tag: function tag to track multiple versions of the same function, defaults to 'latest'
645
645
  :param filename: path to .py/.ipynb file, defaults to current jupyter notebook
646
646
  :param handler: The default function handler to call for the job or nuclio function, in batch functions
@@ -729,7 +729,7 @@ def code_to_function(
729
729
  fn.spec.volume_mounts.append(vol.get("volumeMount"))
730
730
 
731
731
  fn.spec.description = description
732
- fn.metadata.project = project or mlconf.default_project
732
+ fn.metadata.project = project or mlconf.active_project
733
733
  fn.metadata.tag = tag
734
734
  fn.metadata.categories = categories
735
735
  fn.metadata.labels = labels or fn.metadata.labels
mlrun/runtimes/base.py CHANGED
@@ -148,10 +148,10 @@ class FunctionSpec(ModelObj):
148
148
 
149
149
  @property
150
150
  def clone_target_dir(self):
151
- # TODO: remove this property in 1.9.0
151
+ # TODO: remove this property in 1.10.0
152
152
  if self.build.source_code_target_dir:
153
153
  warnings.warn(
154
- "The clone_target_dir attribute is deprecated in 1.6.2 and will be removed in 1.9.0. "
154
+ "The clone_target_dir attribute is deprecated in 1.6.2 and will be removed in 1.10.0. "
155
155
  "Use spec.build.source_code_target_dir instead.",
156
156
  FutureWarning,
157
157
  )
@@ -159,10 +159,10 @@ class FunctionSpec(ModelObj):
159
159
 
160
160
  @clone_target_dir.setter
161
161
  def clone_target_dir(self, clone_target_dir):
162
- # TODO: remove this property in 1.9.0
162
+ # TODO: remove this property in 1.10.0
163
163
  if clone_target_dir:
164
164
  warnings.warn(
165
- "The clone_target_dir attribute is deprecated in 1.6.2 and will be removed in 1.9.0. "
165
+ "The clone_target_dir attribute is deprecated in 1.6.2 and will be removed in 1.10.0. "
166
166
  "Use spec.build.source_code_target_dir instead.",
167
167
  FutureWarning,
168
168
  )
@@ -470,14 +470,14 @@ class BaseRuntime(ModelObj):
470
470
  :return: Dictionary with all the variables that could be parsed
471
471
  """
472
472
  runtime_env = {
473
- "MLRUN_DEFAULT_PROJECT": self.metadata.project or config.default_project
473
+ "MLRUN_ACTIVE_PROJECT": self.metadata.project or config.active_project
474
474
  }
475
475
  if runobj:
476
476
  runtime_env["MLRUN_EXEC_CONFIG"] = runobj.to_json(
477
477
  exclude_notifications_params=True
478
478
  )
479
479
  if runobj.metadata.project:
480
- runtime_env["MLRUN_DEFAULT_PROJECT"] = runobj.metadata.project
480
+ runtime_env["MLRUN_ACTIVE_PROJECT"] = runobj.metadata.project
481
481
  if runobj.spec.verbose:
482
482
  runtime_env["MLRUN_LOG_LEVEL"] = "DEBUG"
483
483
  if config.httpdb.api_url:
mlrun/runtimes/kubejob.py CHANGED
@@ -114,9 +114,9 @@ class KubejobRuntime(KubeResource):
114
114
  e.g. builder_env={"GIT_TOKEN": token}
115
115
  """
116
116
  if not overwrite:
117
- # TODO: change overwrite default to True in 1.9.0
117
+ # TODO: change overwrite default to True in 1.10.0
118
118
  warnings.warn(
119
- "The `overwrite` parameter default will change from 'False' to 'True' in 1.9.0.",
119
+ "The `overwrite` parameter default will change from 'False' to 'True' in 1.10.0.",
120
120
  mlrun.utils.OverwriteBuildParamsWarning,
121
121
  )
122
122
  image = mlrun.utils.helpers.remove_image_protocol_prefix(image)
@@ -623,9 +623,9 @@ class RemoteRuntime(KubeResource):
623
623
  :param force_build: set True for force building the image
624
624
  """
625
625
  if auth_info:
626
- # TODO: remove in 1.9.0
626
+ # TODO: remove in 1.10.0
627
627
  warnings.warn(
628
- "'auth_info' is deprecated for nuclio runtimes in 1.7.0 and will be removed in 1.9.0",
628
+ "'auth_info' is deprecated for nuclio runtimes in 1.7.0 and will be removed in 1.10.0",
629
629
  FutureWarning,
630
630
  )
631
631
 
@@ -833,7 +833,7 @@ class RemoteRuntime(KubeResource):
833
833
  def _get_runtime_env(self):
834
834
  # for runtime specific env var enrichment (before deploy)
835
835
  runtime_env = {
836
- "MLRUN_DEFAULT_PROJECT": self.metadata.project or mlconf.default_project,
836
+ "MLRUN_ACTIVE_PROJECT": self.metadata.project or mlconf.active_project,
837
837
  }
838
838
  if mlconf.httpdb.api_url:
839
839
  runtime_env["MLRUN_DBPATH"] = mlconf.httpdb.api_url
@@ -11,12 +11,12 @@
11
11
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
-
14
+ import copy
15
15
  import json
16
16
  import os
17
17
  import warnings
18
18
  from copy import deepcopy
19
- from typing import TYPE_CHECKING, Optional, Union
19
+ from typing import Optional, Union
20
20
 
21
21
  import nuclio
22
22
  from nuclio import KafkaTrigger
@@ -27,7 +27,11 @@ from mlrun.datastore import get_kafka_brokers_from_dict, parse_kafka_url
27
27
  from mlrun.model import ObjectList
28
28
  from mlrun.runtimes.function_reference import FunctionReference
29
29
  from mlrun.secrets import SecretsStore
30
- from mlrun.serving.server import GraphServer, create_graph_server
30
+ from mlrun.serving.server import (
31
+ GraphServer,
32
+ add_system_steps_to_graph,
33
+ create_graph_server,
34
+ )
31
35
  from mlrun.serving.states import (
32
36
  RootFlowStep,
33
37
  RouterStep,
@@ -43,10 +47,6 @@ from .function import NuclioSpec, RemoteRuntime, min_nuclio_versions
43
47
 
44
48
  serving_subkind = "serving_v2"
45
49
 
46
- if TYPE_CHECKING:
47
- # remove this block in 1.9.0
48
- from mlrun.model_monitoring import TrackingPolicy
49
-
50
50
 
51
51
  def new_v2_model_server(
52
52
  name,
@@ -95,7 +95,6 @@ class ServingSpec(NuclioSpec):
95
95
  "default_class",
96
96
  "secret_sources",
97
97
  "track_models",
98
- "tracking_policy",
99
98
  ]
100
99
 
101
100
  def __init__(
@@ -132,7 +131,6 @@ class ServingSpec(NuclioSpec):
132
131
  graph_initializer=None,
133
132
  error_stream=None,
134
133
  track_models=None,
135
- tracking_policy=None,
136
134
  secret_sources=None,
137
135
  default_content_type=None,
138
136
  node_name=None,
@@ -207,7 +205,6 @@ class ServingSpec(NuclioSpec):
207
205
  self.graph_initializer = graph_initializer
208
206
  self.error_stream = error_stream
209
207
  self.track_models = track_models
210
- self.tracking_policy = tracking_policy
211
208
  self.secret_sources = secret_sources or []
212
209
  self.default_content_type = default_content_type
213
210
  self.model_endpoint_creation_task_name = model_endpoint_creation_task_name
@@ -314,7 +311,6 @@ class ServingRuntime(RemoteRuntime):
314
311
  batch: Optional[int] = None,
315
312
  sampling_percentage: float = 100,
316
313
  stream_args: Optional[dict] = None,
317
- tracking_policy: Optional[Union["TrackingPolicy", dict]] = None,
318
314
  enable_tracking: bool = True,
319
315
  ) -> None:
320
316
  """Apply on your serving function to monitor a deployed model, including real-time dashboards to detect drift
@@ -361,20 +357,12 @@ class ServingRuntime(RemoteRuntime):
361
357
  if batch:
362
358
  warnings.warn(
363
359
  "The `batch` size parameter was deprecated in version 1.8.0 and is no longer used. "
364
- "It will be removed in 1.10.",
365
- # TODO: Remove this in 1.10
360
+ "It will be removed in 1.11.",
361
+ # TODO: Remove this in 1.11
366
362
  FutureWarning,
367
363
  )
368
364
  if stream_args:
369
365
  self.spec.parameters["stream_args"] = stream_args
370
- if tracking_policy is not None:
371
- warnings.warn(
372
- "The `tracking_policy` argument is deprecated from version 1.7.0 "
373
- "and has no effect. It will be removed in 1.9.0.\n"
374
- "To set the desired model monitoring time window and schedule, use "
375
- "the `base_period` argument in `project.enable_model_monitoring()`.",
376
- FutureWarning,
377
- )
378
366
 
379
367
  def add_model(
380
368
  self,
@@ -719,7 +707,6 @@ class ServingRuntime(RemoteRuntime):
719
707
  "graph_initializer": self.spec.graph_initializer,
720
708
  "error_stream": self.spec.error_stream,
721
709
  "track_models": self.spec.track_models,
722
- "tracking_policy": None,
723
710
  "default_content_type": self.spec.default_content_type,
724
711
  "model_endpoint_creation_task_name": self.spec.model_endpoint_creation_task_name,
725
712
  }
@@ -761,10 +748,13 @@ class ServingRuntime(RemoteRuntime):
761
748
  set_paths(workdir)
762
749
  os.chdir(workdir)
763
750
 
751
+ system_graph = None
752
+ if isinstance(self.spec.graph, RootFlowStep):
753
+ system_graph = add_system_steps_to_graph(copy.deepcopy(self.spec.graph))
764
754
  server = create_graph_server(
765
755
  parameters=self.spec.parameters,
766
756
  load_mode=self.spec.load_mode,
767
- graph=self.spec.graph,
757
+ graph=system_graph or self.spec.graph,
768
758
  verbose=self.verbose,
769
759
  current_function=current_function,
770
760
  graph_initializer=self.spec.graph_initializer,