mlrun 1.7.2rc3__py3-none-any.whl → 1.8.0rc2__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 (250) hide show
  1. mlrun/__init__.py +18 -18
  2. mlrun/__main__.py +3 -3
  3. mlrun/alerts/alert.py +19 -12
  4. mlrun/artifacts/__init__.py +0 -2
  5. mlrun/artifacts/base.py +34 -11
  6. mlrun/artifacts/dataset.py +16 -16
  7. mlrun/artifacts/manager.py +13 -13
  8. mlrun/artifacts/model.py +66 -53
  9. mlrun/common/constants.py +6 -0
  10. mlrun/common/formatters/__init__.py +1 -0
  11. mlrun/common/formatters/feature_set.py +1 -0
  12. mlrun/common/formatters/function.py +1 -0
  13. mlrun/common/formatters/model_endpoint.py +30 -0
  14. mlrun/common/formatters/pipeline.py +1 -2
  15. mlrun/common/formatters/project.py +9 -0
  16. mlrun/common/model_monitoring/__init__.py +0 -3
  17. mlrun/common/model_monitoring/helpers.py +1 -1
  18. mlrun/common/runtimes/constants.py +1 -2
  19. mlrun/common/schemas/__init__.py +7 -2
  20. mlrun/common/schemas/alert.py +31 -18
  21. mlrun/common/schemas/api_gateway.py +3 -3
  22. mlrun/common/schemas/artifact.py +7 -13
  23. mlrun/common/schemas/auth.py +6 -4
  24. mlrun/common/schemas/background_task.py +7 -7
  25. mlrun/common/schemas/client_spec.py +2 -2
  26. mlrun/common/schemas/clusterization_spec.py +2 -2
  27. mlrun/common/schemas/common.py +53 -3
  28. mlrun/common/schemas/datastore_profile.py +1 -1
  29. mlrun/common/schemas/feature_store.py +9 -9
  30. mlrun/common/schemas/frontend_spec.py +4 -4
  31. mlrun/common/schemas/function.py +10 -10
  32. mlrun/common/schemas/hub.py +1 -1
  33. mlrun/common/schemas/k8s.py +3 -3
  34. mlrun/common/schemas/memory_reports.py +3 -3
  35. mlrun/common/schemas/model_monitoring/__init__.py +8 -1
  36. mlrun/common/schemas/model_monitoring/constants.py +62 -12
  37. mlrun/common/schemas/model_monitoring/grafana.py +1 -1
  38. mlrun/common/schemas/model_monitoring/model_endpoint_v2.py +149 -0
  39. mlrun/common/schemas/model_monitoring/model_endpoints.py +22 -6
  40. mlrun/common/schemas/notification.py +18 -3
  41. mlrun/common/schemas/object.py +1 -1
  42. mlrun/common/schemas/pagination.py +4 -4
  43. mlrun/common/schemas/partition.py +137 -0
  44. mlrun/common/schemas/pipeline.py +2 -2
  45. mlrun/common/schemas/project.py +22 -17
  46. mlrun/common/schemas/runs.py +2 -2
  47. mlrun/common/schemas/runtime_resource.py +5 -5
  48. mlrun/common/schemas/schedule.py +1 -1
  49. mlrun/common/schemas/secret.py +1 -1
  50. mlrun/common/schemas/tag.py +3 -3
  51. mlrun/common/schemas/workflow.py +5 -5
  52. mlrun/config.py +65 -15
  53. mlrun/data_types/__init__.py +0 -2
  54. mlrun/data_types/data_types.py +0 -1
  55. mlrun/data_types/infer.py +3 -1
  56. mlrun/data_types/spark.py +4 -4
  57. mlrun/data_types/to_pandas.py +2 -11
  58. mlrun/datastore/__init__.py +0 -2
  59. mlrun/datastore/alibaba_oss.py +4 -1
  60. mlrun/datastore/azure_blob.py +4 -1
  61. mlrun/datastore/base.py +12 -4
  62. mlrun/datastore/datastore.py +9 -3
  63. mlrun/datastore/datastore_profile.py +20 -20
  64. mlrun/datastore/dbfs_store.py +4 -1
  65. mlrun/datastore/filestore.py +4 -1
  66. mlrun/datastore/google_cloud_storage.py +4 -1
  67. mlrun/datastore/hdfs.py +4 -1
  68. mlrun/datastore/inmem.py +4 -1
  69. mlrun/datastore/redis.py +4 -1
  70. mlrun/datastore/s3.py +4 -1
  71. mlrun/datastore/sources.py +51 -49
  72. mlrun/datastore/store_resources.py +0 -2
  73. mlrun/datastore/targets.py +22 -23
  74. mlrun/datastore/utils.py +2 -2
  75. mlrun/datastore/v3io.py +4 -1
  76. mlrun/datastore/wasbfs/fs.py +13 -12
  77. mlrun/db/base.py +170 -64
  78. mlrun/db/factory.py +3 -0
  79. mlrun/db/httpdb.py +986 -238
  80. mlrun/db/nopdb.py +155 -57
  81. mlrun/errors.py +2 -2
  82. mlrun/execution.py +55 -29
  83. mlrun/feature_store/__init__.py +0 -2
  84. mlrun/feature_store/api.py +40 -40
  85. mlrun/feature_store/common.py +9 -9
  86. mlrun/feature_store/feature_set.py +20 -18
  87. mlrun/feature_store/feature_vector.py +27 -24
  88. mlrun/feature_store/retrieval/base.py +14 -9
  89. mlrun/feature_store/retrieval/job.py +2 -1
  90. mlrun/feature_store/steps.py +2 -2
  91. mlrun/features.py +30 -13
  92. mlrun/frameworks/__init__.py +1 -2
  93. mlrun/frameworks/_common/__init__.py +1 -2
  94. mlrun/frameworks/_common/artifacts_library.py +2 -2
  95. mlrun/frameworks/_common/mlrun_interface.py +10 -6
  96. mlrun/frameworks/_common/model_handler.py +29 -27
  97. mlrun/frameworks/_common/producer.py +3 -1
  98. mlrun/frameworks/_dl_common/__init__.py +1 -2
  99. mlrun/frameworks/_dl_common/loggers/__init__.py +1 -2
  100. mlrun/frameworks/_dl_common/loggers/mlrun_logger.py +4 -4
  101. mlrun/frameworks/_dl_common/loggers/tensorboard_logger.py +3 -3
  102. mlrun/frameworks/_ml_common/__init__.py +1 -2
  103. mlrun/frameworks/_ml_common/loggers/__init__.py +1 -2
  104. mlrun/frameworks/_ml_common/model_handler.py +21 -21
  105. mlrun/frameworks/_ml_common/plans/__init__.py +1 -2
  106. mlrun/frameworks/_ml_common/plans/confusion_matrix_plan.py +3 -1
  107. mlrun/frameworks/_ml_common/plans/dataset_plan.py +3 -3
  108. mlrun/frameworks/_ml_common/plans/roc_curve_plan.py +4 -4
  109. mlrun/frameworks/auto_mlrun/__init__.py +1 -2
  110. mlrun/frameworks/auto_mlrun/auto_mlrun.py +22 -15
  111. mlrun/frameworks/huggingface/__init__.py +1 -2
  112. mlrun/frameworks/huggingface/model_server.py +9 -9
  113. mlrun/frameworks/lgbm/__init__.py +47 -44
  114. mlrun/frameworks/lgbm/callbacks/__init__.py +1 -2
  115. mlrun/frameworks/lgbm/callbacks/logging_callback.py +4 -2
  116. mlrun/frameworks/lgbm/callbacks/mlrun_logging_callback.py +4 -2
  117. mlrun/frameworks/lgbm/mlrun_interfaces/__init__.py +1 -2
  118. mlrun/frameworks/lgbm/mlrun_interfaces/mlrun_interface.py +5 -5
  119. mlrun/frameworks/lgbm/model_handler.py +15 -11
  120. mlrun/frameworks/lgbm/model_server.py +11 -7
  121. mlrun/frameworks/lgbm/utils.py +2 -2
  122. mlrun/frameworks/onnx/__init__.py +1 -2
  123. mlrun/frameworks/onnx/dataset.py +3 -3
  124. mlrun/frameworks/onnx/mlrun_interface.py +2 -2
  125. mlrun/frameworks/onnx/model_handler.py +7 -5
  126. mlrun/frameworks/onnx/model_server.py +8 -6
  127. mlrun/frameworks/parallel_coordinates.py +11 -11
  128. mlrun/frameworks/pytorch/__init__.py +22 -23
  129. mlrun/frameworks/pytorch/callbacks/__init__.py +1 -2
  130. mlrun/frameworks/pytorch/callbacks/callback.py +2 -1
  131. mlrun/frameworks/pytorch/callbacks/logging_callback.py +15 -8
  132. mlrun/frameworks/pytorch/callbacks/mlrun_logging_callback.py +19 -12
  133. mlrun/frameworks/pytorch/callbacks/tensorboard_logging_callback.py +22 -15
  134. mlrun/frameworks/pytorch/callbacks_handler.py +36 -30
  135. mlrun/frameworks/pytorch/mlrun_interface.py +17 -17
  136. mlrun/frameworks/pytorch/model_handler.py +21 -17
  137. mlrun/frameworks/pytorch/model_server.py +13 -9
  138. mlrun/frameworks/sklearn/__init__.py +19 -18
  139. mlrun/frameworks/sklearn/estimator.py +2 -2
  140. mlrun/frameworks/sklearn/metric.py +3 -3
  141. mlrun/frameworks/sklearn/metrics_library.py +8 -6
  142. mlrun/frameworks/sklearn/mlrun_interface.py +3 -2
  143. mlrun/frameworks/sklearn/model_handler.py +4 -3
  144. mlrun/frameworks/tf_keras/__init__.py +11 -12
  145. mlrun/frameworks/tf_keras/callbacks/__init__.py +1 -2
  146. mlrun/frameworks/tf_keras/callbacks/logging_callback.py +17 -14
  147. mlrun/frameworks/tf_keras/callbacks/mlrun_logging_callback.py +15 -12
  148. mlrun/frameworks/tf_keras/callbacks/tensorboard_logging_callback.py +21 -18
  149. mlrun/frameworks/tf_keras/model_handler.py +17 -13
  150. mlrun/frameworks/tf_keras/model_server.py +12 -8
  151. mlrun/frameworks/xgboost/__init__.py +19 -18
  152. mlrun/frameworks/xgboost/model_handler.py +13 -9
  153. mlrun/launcher/base.py +3 -4
  154. mlrun/launcher/local.py +1 -1
  155. mlrun/launcher/remote.py +1 -1
  156. mlrun/lists.py +4 -3
  157. mlrun/model.py +110 -46
  158. mlrun/model_monitoring/__init__.py +1 -2
  159. mlrun/model_monitoring/api.py +6 -6
  160. mlrun/model_monitoring/applications/_application_steps.py +13 -15
  161. mlrun/model_monitoring/applications/histogram_data_drift.py +41 -15
  162. mlrun/model_monitoring/applications/results.py +55 -3
  163. mlrun/model_monitoring/controller.py +185 -223
  164. mlrun/model_monitoring/db/_schedules.py +156 -0
  165. mlrun/model_monitoring/db/_stats.py +189 -0
  166. mlrun/model_monitoring/db/stores/__init__.py +1 -1
  167. mlrun/model_monitoring/db/stores/base/store.py +6 -65
  168. mlrun/model_monitoring/db/stores/sqldb/models/__init__.py +0 -25
  169. mlrun/model_monitoring/db/stores/sqldb/models/base.py +0 -97
  170. mlrun/model_monitoring/db/stores/sqldb/models/mysql.py +2 -58
  171. mlrun/model_monitoring/db/stores/sqldb/models/sqlite.py +0 -15
  172. mlrun/model_monitoring/db/stores/sqldb/sql_store.py +6 -257
  173. mlrun/model_monitoring/db/stores/v3io_kv/kv_store.py +9 -271
  174. mlrun/model_monitoring/db/tsdb/base.py +76 -24
  175. mlrun/model_monitoring/db/tsdb/tdengine/schemas.py +61 -6
  176. mlrun/model_monitoring/db/tsdb/tdengine/stream_graph_steps.py +33 -0
  177. mlrun/model_monitoring/db/tsdb/tdengine/tdengine_connector.py +253 -28
  178. mlrun/model_monitoring/db/tsdb/v3io/stream_graph_steps.py +1 -0
  179. mlrun/model_monitoring/db/tsdb/v3io/v3io_connector.py +35 -17
  180. mlrun/model_monitoring/helpers.py +91 -1
  181. mlrun/model_monitoring/model_endpoint.py +4 -2
  182. mlrun/model_monitoring/stream_processing.py +16 -13
  183. mlrun/model_monitoring/tracking_policy.py +10 -3
  184. mlrun/model_monitoring/writer.py +47 -26
  185. mlrun/package/__init__.py +3 -6
  186. mlrun/package/context_handler.py +1 -1
  187. mlrun/package/packager.py +12 -9
  188. mlrun/package/packagers/__init__.py +0 -2
  189. mlrun/package/packagers/default_packager.py +14 -11
  190. mlrun/package/packagers/numpy_packagers.py +16 -7
  191. mlrun/package/packagers/pandas_packagers.py +18 -18
  192. mlrun/package/packagers/python_standard_library_packagers.py +25 -11
  193. mlrun/package/packagers_manager.py +31 -14
  194. mlrun/package/utils/__init__.py +0 -3
  195. mlrun/package/utils/_pickler.py +6 -6
  196. mlrun/platforms/__init__.py +3 -16
  197. mlrun/platforms/iguazio.py +4 -1
  198. mlrun/projects/operations.py +27 -27
  199. mlrun/projects/pipelines.py +34 -35
  200. mlrun/projects/project.py +535 -182
  201. mlrun/run.py +13 -10
  202. mlrun/runtimes/__init__.py +1 -3
  203. mlrun/runtimes/base.py +15 -11
  204. mlrun/runtimes/daskjob.py +9 -9
  205. mlrun/runtimes/generators.py +2 -1
  206. mlrun/runtimes/kubejob.py +4 -5
  207. mlrun/runtimes/mounts.py +572 -0
  208. mlrun/runtimes/mpijob/__init__.py +0 -2
  209. mlrun/runtimes/mpijob/abstract.py +7 -6
  210. mlrun/runtimes/nuclio/api_gateway.py +7 -7
  211. mlrun/runtimes/nuclio/application/application.py +11 -11
  212. mlrun/runtimes/nuclio/function.py +13 -13
  213. mlrun/runtimes/nuclio/serving.py +9 -9
  214. mlrun/runtimes/pod.py +154 -45
  215. mlrun/runtimes/remotesparkjob.py +3 -2
  216. mlrun/runtimes/sparkjob/__init__.py +0 -2
  217. mlrun/runtimes/sparkjob/spark3job.py +21 -11
  218. mlrun/runtimes/utils.py +6 -5
  219. mlrun/serving/merger.py +6 -4
  220. mlrun/serving/remote.py +18 -17
  221. mlrun/serving/routers.py +27 -27
  222. mlrun/serving/server.py +1 -1
  223. mlrun/serving/states.py +76 -71
  224. mlrun/serving/utils.py +13 -2
  225. mlrun/serving/v1_serving.py +3 -2
  226. mlrun/serving/v2_serving.py +4 -4
  227. mlrun/track/__init__.py +1 -1
  228. mlrun/track/tracker.py +2 -2
  229. mlrun/track/trackers/mlflow_tracker.py +6 -5
  230. mlrun/utils/async_http.py +1 -1
  231. mlrun/utils/helpers.py +70 -16
  232. mlrun/utils/logger.py +106 -4
  233. mlrun/utils/notifications/notification/__init__.py +22 -19
  234. mlrun/utils/notifications/notification/base.py +33 -14
  235. mlrun/utils/notifications/notification/console.py +6 -6
  236. mlrun/utils/notifications/notification/git.py +11 -11
  237. mlrun/utils/notifications/notification/ipython.py +10 -9
  238. mlrun/utils/notifications/notification/mail.py +149 -0
  239. mlrun/utils/notifications/notification/slack.py +6 -6
  240. mlrun/utils/notifications/notification/webhook.py +18 -22
  241. mlrun/utils/notifications/notification_pusher.py +43 -31
  242. mlrun/utils/regex.py +3 -1
  243. mlrun/utils/version/version.json +2 -2
  244. {mlrun-1.7.2rc3.dist-info → mlrun-1.8.0rc2.dist-info}/METADATA +18 -14
  245. mlrun-1.8.0rc2.dist-info/RECORD +358 -0
  246. {mlrun-1.7.2rc3.dist-info → mlrun-1.8.0rc2.dist-info}/WHEEL +1 -1
  247. mlrun-1.7.2rc3.dist-info/RECORD +0 -351
  248. {mlrun-1.7.2rc3.dist-info → mlrun-1.8.0rc2.dist-info}/LICENSE +0 -0
  249. {mlrun-1.7.2rc3.dist-info → mlrun-1.8.0rc2.dist-info}/entry_points.txt +0 -0
  250. {mlrun-1.7.2rc3.dist-info → mlrun-1.8.0rc2.dist-info}/top_level.txt +0 -0
mlrun/projects/project.py CHANGED
@@ -33,13 +33,11 @@ from typing import Callable, Optional, Union
33
33
  import dotenv
34
34
  import git
35
35
  import git.exc
36
- import mlrun_pipelines.common.models
37
- import mlrun_pipelines.mounts
38
36
  import nuclio.utils
39
37
  import requests
40
38
  import yaml
41
- from mlrun_pipelines.models import PipelineNodeWrapper
42
39
 
40
+ import mlrun.artifacts.model
43
41
  import mlrun.common.formatters
44
42
  import mlrun.common.helpers
45
43
  import mlrun.common.runtimes.constants
@@ -51,16 +49,19 @@ import mlrun.k8s_utils
51
49
  import mlrun.lists
52
50
  import mlrun.model_monitoring.applications as mm_app
53
51
  import mlrun.runtimes
52
+ import mlrun.runtimes.mounts
54
53
  import mlrun.runtimes.nuclio.api_gateway
55
54
  import mlrun.runtimes.pod
56
55
  import mlrun.runtimes.utils
57
56
  import mlrun.serving
58
57
  import mlrun.utils
59
58
  import mlrun.utils.regex
59
+ import mlrun_pipelines.common.models
60
60
  from mlrun.alerts.alert import AlertConfig
61
61
  from mlrun.common.schemas.alert import AlertTemplate
62
62
  from mlrun.datastore.datastore_profile import DatastoreProfile, DatastoreProfile2Json
63
63
  from mlrun.runtimes.nuclio.function import RemoteRuntime
64
+ from mlrun_pipelines.models import PipelineNodeWrapper
64
65
 
65
66
  from ..artifacts import Artifact, ArtifactProducer, DatasetArtifact, ModelArtifact
66
67
  from ..artifacts.manager import ArtifactManager, dict_to_artifact, extend_artifact_path
@@ -126,15 +127,15 @@ def new_project(
126
127
  context: str = "./",
127
128
  init_git: bool = False,
128
129
  user_project: bool = False,
129
- remote: str = None,
130
- from_template: str = None,
131
- secrets: dict = None,
132
- description: str = None,
133
- subpath: str = None,
130
+ remote: Optional[str] = None,
131
+ from_template: Optional[str] = None,
132
+ secrets: Optional[dict] = None,
133
+ description: Optional[str] = None,
134
+ subpath: Optional[str] = None,
134
135
  save: bool = True,
135
136
  overwrite: bool = False,
136
- parameters: dict = None,
137
- default_function_node_selector: dict = None,
137
+ parameters: Optional[dict] = None,
138
+ default_function_node_selector: Optional[dict] = None,
138
139
  ) -> "MlrunProject":
139
140
  """Create a new MLRun project, optionally load it from a yaml/zip/git template
140
141
 
@@ -291,17 +292,17 @@ def new_project(
291
292
 
292
293
  def load_project(
293
294
  context: str = "./",
294
- url: str = None,
295
- name: str = None,
296
- secrets: dict = None,
295
+ url: Optional[str] = None,
296
+ name: Optional[str] = None,
297
+ secrets: Optional[dict] = None,
297
298
  init_git: bool = False,
298
- subpath: str = None,
299
+ subpath: Optional[str] = None,
299
300
  clone: bool = False,
300
301
  user_project: bool = False,
301
302
  save: bool = True,
302
303
  sync_functions: bool = False,
303
- parameters: dict = None,
304
- allow_cross_project: bool = None,
304
+ parameters: Optional[dict] = None,
305
+ allow_cross_project: Optional[bool] = None,
305
306
  ) -> "MlrunProject":
306
307
  """Load an MLRun project from git or tar or dir
307
308
 
@@ -437,16 +438,16 @@ def load_project(
437
438
  def get_or_create_project(
438
439
  name: str,
439
440
  context: str = "./",
440
- url: str = None,
441
- secrets: dict = None,
441
+ url: Optional[str] = None,
442
+ secrets: Optional[dict] = None,
442
443
  init_git=False,
443
- subpath: str = None,
444
+ subpath: Optional[str] = None,
444
445
  clone: bool = False,
445
446
  user_project: bool = False,
446
- from_template: str = None,
447
+ from_template: Optional[str] = None,
447
448
  save: bool = True,
448
- parameters: dict = None,
449
- allow_cross_project: bool = None,
449
+ parameters: Optional[dict] = None,
450
+ allow_cross_project: Optional[bool] = None,
450
451
  ) -> "MlrunProject":
451
452
  """Load a project from MLRun DB, or create/import if it does not exist
452
453
 
@@ -823,14 +824,14 @@ class ProjectSpec(ModelObj):
823
824
  origin_url=None,
824
825
  goals=None,
825
826
  load_source_on_run=None,
826
- default_requirements: typing.Union[str, list[str]] = None,
827
+ default_requirements: Optional[typing.Union[str, list[str]]] = None,
827
828
  desired_state=mlrun.common.schemas.ProjectState.online.value,
828
829
  owner=None,
829
830
  disable_auto_mount=None,
830
831
  workdir=None,
831
832
  default_image=None,
832
833
  build=None,
833
- custom_packagers: list[tuple[str, bool]] = None,
834
+ custom_packagers: Optional[list[tuple[str, bool]]] = None,
834
835
  default_function_node_selector=None,
835
836
  ):
836
837
  self.repo = None
@@ -1253,7 +1254,11 @@ class MlrunProject(ModelObj):
1253
1254
  raise exc
1254
1255
 
1255
1256
  def get_artifact_uri(
1256
- self, key: str, category: str = "artifact", tag: str = None, iter: int = None
1257
+ self,
1258
+ key: str,
1259
+ category: str = "artifact",
1260
+ tag: Optional[str] = None,
1261
+ iter: Optional[int] = None,
1257
1262
  ) -> str:
1258
1263
  """return the project artifact uri (store://..) from the artifact key
1259
1264
 
@@ -1353,7 +1358,7 @@ class MlrunProject(ModelObj):
1353
1358
  workflow_path: str,
1354
1359
  embed: bool = False,
1355
1360
  engine: Optional[str] = None,
1356
- args_schema: list[EntrypointParam] = None,
1361
+ args_schema: Optional[list[EntrypointParam]] = None,
1357
1362
  handler: Optional[str] = None,
1358
1363
  schedule: typing.Union[str, mlrun.common.schemas.ScheduleCronTrigger] = None,
1359
1364
  ttl: Optional[int] = None,
@@ -1425,8 +1430,8 @@ class MlrunProject(ModelObj):
1425
1430
  self,
1426
1431
  key,
1427
1432
  artifact: typing.Union[str, dict, Artifact] = None,
1428
- target_path: str = None,
1429
- tag: str = None,
1433
+ target_path: Optional[str] = None,
1434
+ tag: Optional[str] = None,
1430
1435
  ):
1431
1436
  """add/set an artifact in the project spec (will be registered on load)
1432
1437
 
@@ -1646,7 +1651,7 @@ class MlrunProject(ModelObj):
1646
1651
  deletion_strategy: mlrun.common.schemas.artifact.ArtifactsDeletionStrategies = (
1647
1652
  mlrun.common.schemas.artifact.ArtifactsDeletionStrategies.metadata_only
1648
1653
  ),
1649
- secrets: dict = None,
1654
+ secrets: Optional[dict] = None,
1650
1655
  ):
1651
1656
  """Delete an artifact object in the DB and optionally delete the artifact data
1652
1657
 
@@ -1777,7 +1782,7 @@ class MlrunProject(ModelObj):
1777
1782
  :param key: artifact key or artifact class ()
1778
1783
  :param body: will use the body as the artifact content
1779
1784
  :param model_file: path to the local model file we upload (see also model_dir)
1780
- or to a model file data url (e.g. http://host/path/model.pkl)
1785
+ or to a model file data url (e.g. `http://host/path/model.pkl`)
1781
1786
  :param model_dir: path to the local dir holding the model file and extra files
1782
1787
  :param artifact_path: target artifact path (when not using the default)
1783
1788
  to define a subpath under the default location use:
@@ -1953,12 +1958,12 @@ class MlrunProject(ModelObj):
1953
1958
  str,
1954
1959
  mm_app.ModelMonitoringApplicationBase,
1955
1960
  ] = None,
1956
- name: str = None,
1957
- image: str = None,
1961
+ name: Optional[str] = None,
1962
+ image: Optional[str] = None,
1958
1963
  handler=None,
1959
- with_repo: bool = None,
1960
- tag: str = None,
1961
- requirements: typing.Union[str, list[str]] = None,
1964
+ with_repo: Optional[bool] = None,
1965
+ tag: Optional[str] = None,
1966
+ requirements: Optional[typing.Union[str, list[str]]] = None,
1962
1967
  requirements_file: str = "",
1963
1968
  **application_kwargs,
1964
1969
  ) -> mlrun.runtimes.BaseRuntime:
@@ -1990,8 +1995,6 @@ class MlrunProject(ModelObj):
1990
1995
  :param application_kwargs: Additional keyword arguments to be passed to the
1991
1996
  monitoring application's constructor.
1992
1997
  """
1993
-
1994
- function_object: RemoteRuntime = None
1995
1998
  (
1996
1999
  resolved_function_name,
1997
2000
  function_object,
@@ -2015,17 +2018,17 @@ class MlrunProject(ModelObj):
2015
2018
 
2016
2019
  def create_model_monitoring_function(
2017
2020
  self,
2018
- func: str = None,
2021
+ func: Optional[str] = None,
2019
2022
  application_class: typing.Union[
2020
2023
  str,
2021
2024
  mm_app.ModelMonitoringApplicationBase,
2022
2025
  ] = None,
2023
- name: str = None,
2024
- image: str = None,
2025
- handler: str = None,
2026
- with_repo: bool = None,
2027
- tag: str = None,
2028
- requirements: typing.Union[str, list[str]] = None,
2026
+ name: Optional[str] = None,
2027
+ image: Optional[str] = None,
2028
+ handler: Optional[str] = None,
2029
+ with_repo: Optional[bool] = None,
2030
+ tag: Optional[str] = None,
2031
+ requirements: Optional[typing.Union[str, list[str]]] = None,
2029
2032
  requirements_file: str = "",
2030
2033
  **application_kwargs,
2031
2034
  ) -> mlrun.runtimes.BaseRuntime:
@@ -2089,7 +2092,6 @@ class MlrunProject(ModelObj):
2089
2092
  ) -> tuple[str, mlrun.runtimes.BaseRuntime, dict]:
2090
2093
  import mlrun.model_monitoring.api
2091
2094
 
2092
- function_object: RemoteRuntime = None
2093
2095
  kind = None
2094
2096
  if (isinstance(func, str) or func is None) and application_class is not None:
2095
2097
  kind = mlrun.run.RuntimeKinds.serving
@@ -2128,9 +2130,6 @@ class MlrunProject(ModelObj):
2128
2130
  mm_constants.ModelMonitoringAppLabel.VAL,
2129
2131
  )
2130
2132
 
2131
- if not mlrun.mlconf.is_ce_mode():
2132
- function_object.apply(mlrun.mount_v3io())
2133
-
2134
2133
  return resolved_function_name, function_object, func
2135
2134
 
2136
2135
  def _wait_for_functions_deployment(self, function_names: list[str]) -> None:
@@ -2269,7 +2268,7 @@ class MlrunProject(ModelObj):
2269
2268
  delete_stream_function: bool = False,
2270
2269
  delete_histogram_data_drift_app: bool = True,
2271
2270
  delete_user_applications: bool = False,
2272
- user_application_list: list[str] = None,
2271
+ user_application_list: Optional[list[str]] = None,
2273
2272
  ) -> None:
2274
2273
  """
2275
2274
  Disable model monitoring application controller, writer, stream, histogram data drift application
@@ -2329,11 +2328,11 @@ class MlrunProject(ModelObj):
2329
2328
  func: typing.Union[str, mlrun.runtimes.BaseRuntime] = None,
2330
2329
  name: str = "",
2331
2330
  kind: str = "job",
2332
- image: str = None,
2333
- handler: str = None,
2334
- with_repo: bool = None,
2335
- tag: str = None,
2336
- requirements: typing.Union[str, list[str]] = None,
2331
+ image: Optional[str] = None,
2332
+ handler: Optional[str] = None,
2333
+ with_repo: Optional[bool] = None,
2334
+ tag: Optional[str] = None,
2335
+ requirements: Optional[typing.Union[str, list[str]]] = None,
2337
2336
  requirements_file: str = "",
2338
2337
  ) -> mlrun.runtimes.BaseRuntime:
2339
2338
  """
@@ -2427,11 +2426,11 @@ class MlrunProject(ModelObj):
2427
2426
  func: typing.Union[str, mlrun.runtimes.BaseRuntime] = None,
2428
2427
  name: str = "",
2429
2428
  kind: str = "",
2430
- image: str = None,
2431
- handler: str = None,
2432
- with_repo: bool = None,
2433
- tag: str = None,
2434
- requirements: typing.Union[str, list[str]] = None,
2429
+ image: Optional[str] = None,
2430
+ handler: Optional[str] = None,
2431
+ with_repo: Optional[bool] = None,
2432
+ tag: Optional[str] = None,
2433
+ requirements: Optional[typing.Union[str, list[str]]] = None,
2435
2434
  requirements_file: str = "",
2436
2435
  ) -> tuple[str, str, mlrun.runtimes.BaseRuntime, dict]:
2437
2436
  if (
@@ -2654,8 +2653,8 @@ class MlrunProject(ModelObj):
2654
2653
 
2655
2654
  def pull(
2656
2655
  self,
2657
- branch: str = None,
2658
- remote: str = None,
2656
+ branch: Optional[str] = None,
2657
+ remote: Optional[str] = None,
2659
2658
  secrets: Union[SecretsStore, dict] = None,
2660
2659
  ):
2661
2660
  """pull/update sources from git or tar into the context dir
@@ -2768,10 +2767,10 @@ class MlrunProject(ModelObj):
2768
2767
  branch,
2769
2768
  message=None,
2770
2769
  update=True,
2771
- remote: str = None,
2772
- add: list = None,
2773
- author_name: str = None,
2774
- author_email: str = None,
2770
+ remote: Optional[str] = None,
2771
+ add: Optional[list] = None,
2772
+ author_name: Optional[str] = None,
2773
+ author_email: Optional[str] = None,
2775
2774
  secrets: Union[SecretsStore, dict] = None,
2776
2775
  ):
2777
2776
  """update spec and push updates to remote git repo
@@ -2834,7 +2833,7 @@ class MlrunProject(ModelObj):
2834
2833
 
2835
2834
  def sync_functions(
2836
2835
  self,
2837
- names: list = None,
2836
+ names: Optional[list] = None,
2838
2837
  always: bool = True,
2839
2838
  save: bool = False,
2840
2839
  silent: bool = False,
@@ -2978,8 +2977,8 @@ class MlrunProject(ModelObj):
2978
2977
 
2979
2978
  def set_secrets(
2980
2979
  self,
2981
- secrets: dict = None,
2982
- file_path: str = None,
2980
+ secrets: Optional[dict] = None,
2981
+ file_path: Optional[str] = None,
2983
2982
  provider: typing.Union[str, mlrun.common.schemas.SecretProviderName] = None,
2984
2983
  ):
2985
2984
  """
@@ -3056,24 +3055,24 @@ class MlrunProject(ModelObj):
3056
3055
 
3057
3056
  def run(
3058
3057
  self,
3059
- name: str = None,
3060
- workflow_path: str = None,
3061
- arguments: dict[str, typing.Any] = None,
3062
- artifact_path: str = None,
3063
- workflow_handler: typing.Union[str, typing.Callable] = None,
3064
- namespace: str = None,
3058
+ name: Optional[str] = None,
3059
+ workflow_path: Optional[str] = None,
3060
+ arguments: Optional[dict[str, typing.Any]] = None,
3061
+ artifact_path: Optional[str] = None,
3062
+ workflow_handler: Optional[typing.Union[str, typing.Callable]] = None,
3063
+ namespace: Optional[str] = None,
3065
3064
  sync: bool = False,
3066
3065
  watch: bool = False,
3067
3066
  dirty: bool = False,
3068
- engine: str = None,
3069
- local: bool = None,
3067
+ engine: Optional[str] = None,
3068
+ local: Optional[bool] = None,
3070
3069
  schedule: typing.Union[
3071
3070
  str, mlrun.common.schemas.ScheduleCronTrigger, bool
3072
3071
  ] = None,
3073
- timeout: int = None,
3074
- source: str = None,
3075
- cleanup_ttl: int = None,
3076
- notifications: list[mlrun.model.Notification] = None,
3072
+ timeout: Optional[int] = None,
3073
+ source: Optional[str] = None,
3074
+ cleanup_ttl: Optional[int] = None,
3075
+ notifications: Optional[list[mlrun.model.Notification]] = None,
3077
3076
  workflow_runner_node_selector: typing.Optional[dict[str, str]] = None,
3078
3077
  ) -> _PipelineRunStatus:
3079
3078
  """Run a workflow using kubeflow pipelines
@@ -3280,7 +3279,7 @@ class MlrunProject(ModelObj):
3280
3279
 
3281
3280
  return db.create_project(self.to_dict())
3282
3281
 
3283
- def export(self, filepath=None, include_files: str = None):
3282
+ def export(self, filepath=None, include_files: Optional[str] = None):
3284
3283
  """save the project object into a yaml file or zip archive (default to project.yaml)
3285
3284
 
3286
3285
  By default, the project object is exported to a yaml file, when the filepath suffix is '.zip'
@@ -3385,30 +3384,85 @@ class MlrunProject(ModelObj):
3385
3384
  "and set `rebuild_images=True`"
3386
3385
  )
3387
3386
 
3387
+ def list_model_endpoints(
3388
+ self,
3389
+ model: Optional[str] = None,
3390
+ function: Optional[str] = None,
3391
+ labels: Optional[list[str]] = None,
3392
+ start: str = "now-1h",
3393
+ end: str = "now",
3394
+ top_level: bool = False,
3395
+ uids: Optional[list[str]] = None,
3396
+ ) -> list[mlrun.model_monitoring.model_endpoint.ModelEndpoint]:
3397
+ """
3398
+ Returns a list of `ModelEndpoint` objects. Each `ModelEndpoint` object represents the current state of a
3399
+ model endpoint. This functions supports filtering by the following parameters:
3400
+ 1) model
3401
+ 2) function
3402
+ 3) labels
3403
+ 4) top level
3404
+ 5) uids
3405
+ By default, when no filters are applied, all available endpoints for the given project will be listed.
3406
+
3407
+ In addition, this functions provides a facade for listing endpoint related metrics. This facade is time-based
3408
+ and depends on the 'start' and 'end' parameters.
3409
+
3410
+ :param model: The name of the model to filter by
3411
+ :param function: The name of the function to filter by
3412
+ :param labels: Filter model endpoints by label key-value pairs or key existence. This can be provided as:
3413
+ - A dictionary in the format `{"label": "value"}` to match specific label key-value pairs,
3414
+ or `{"label": None}` to check for key existence.
3415
+ - A list of strings formatted as `"label=value"` to match specific label key-value pairs,
3416
+ or just `"label"` for key existence.
3417
+ - A comma-separated string formatted as `"label1=value1,label2"` to match entities with
3418
+ the specified key-value pairs or key existence.
3419
+ :param start: The start time of the metrics. Can be represented by a string containing an RFC 3339 time, a
3420
+ Unix timestamp in milliseconds, a relative time (`'now'` or `'now-[0-9]+[mhd]'`, where
3421
+ `m` = minutes, `h` = hours, `'d'` = days, and `'s'` = seconds), or 0 for the earliest time.
3422
+ :param end: The end time of the metrics. Can be represented by a string containing an RFC 3339 time, a
3423
+ Unix timestamp in milliseconds, a relative time (`'now'` or `'now-[0-9]+[mhd]'`, where
3424
+ `m` = minutes, `h` = hours, `'d'` = days, and `'s'` = seconds), or 0 for the earliest time.
3425
+ :param top_level: if true will return only routers and endpoint that are NOT children of any router
3426
+ :param uids: if passed will return a list `ModelEndpoint` object with uid in uids
3427
+
3428
+ :returns: Returns a list of `ModelEndpoint` objects.
3429
+ """
3430
+ db = mlrun.db.get_run_db(secrets=self._secrets)
3431
+ return db.list_model_endpoints(
3432
+ project=self.name,
3433
+ model=model,
3434
+ function=function,
3435
+ labels=labels,
3436
+ start=start,
3437
+ end=end,
3438
+ top_level=top_level,
3439
+ uids=uids,
3440
+ )
3441
+
3388
3442
  def run_function(
3389
3443
  self,
3390
3444
  function: typing.Union[str, mlrun.runtimes.BaseRuntime],
3391
- handler: str = None,
3445
+ handler: Optional[str] = None,
3392
3446
  name: str = "",
3393
- params: dict = None,
3394
- hyperparams: dict = None,
3447
+ params: Optional[dict] = None,
3448
+ hyperparams: Optional[dict] = None,
3395
3449
  hyper_param_options: mlrun.model.HyperParamOptions = None,
3396
- inputs: dict = None,
3397
- outputs: list[str] = None,
3450
+ inputs: Optional[dict] = None,
3451
+ outputs: Optional[list[str]] = None,
3398
3452
  workdir: str = "",
3399
- labels: dict = None,
3453
+ labels: Optional[dict] = None,
3400
3454
  base_task: mlrun.model.RunTemplate = None,
3401
3455
  watch: bool = True,
3402
- local: bool = None,
3403
- verbose: bool = None,
3404
- selector: str = None,
3405
- auto_build: bool = None,
3456
+ local: Optional[bool] = None,
3457
+ verbose: Optional[bool] = None,
3458
+ selector: Optional[str] = None,
3459
+ auto_build: Optional[bool] = None,
3406
3460
  schedule: typing.Union[str, mlrun.common.schemas.ScheduleCronTrigger] = None,
3407
- artifact_path: str = None,
3408
- notifications: list[mlrun.model.Notification] = None,
3461
+ artifact_path: Optional[str] = None,
3462
+ notifications: Optional[list[mlrun.model.Notification]] = None,
3409
3463
  returns: Optional[list[Union[str, dict[str, str]]]] = None,
3410
3464
  builder_env: Optional[dict] = None,
3411
- reset_on_run: bool = None,
3465
+ reset_on_run: Optional[bool] = None,
3412
3466
  ) -> typing.Union[mlrun.model.RunObject, PipelineNodeWrapper]:
3413
3467
  """Run a local or remote task as part of a local/kubeflow pipeline
3414
3468
 
@@ -3501,18 +3555,18 @@ class MlrunProject(ModelObj):
3501
3555
  def build_function(
3502
3556
  self,
3503
3557
  function: typing.Union[str, mlrun.runtimes.BaseRuntime],
3504
- with_mlrun: bool = None,
3558
+ with_mlrun: Optional[bool] = None,
3505
3559
  skip_deployed: bool = False,
3506
- image: str = None,
3507
- base_image: str = None,
3508
- commands: list = None,
3509
- secret_name: str = None,
3510
- requirements: typing.Union[str, list[str]] = None,
3511
- mlrun_version_specifier: str = None,
3512
- builder_env: dict = None,
3560
+ image: Optional[str] = None,
3561
+ base_image: Optional[str] = None,
3562
+ commands: Optional[list] = None,
3563
+ secret_name: Optional[str] = None,
3564
+ requirements: Optional[typing.Union[str, list[str]]] = None,
3565
+ mlrun_version_specifier: Optional[str] = None,
3566
+ builder_env: Optional[dict] = None,
3513
3567
  overwrite_build_params: bool = False,
3514
- requirements_file: str = None,
3515
- extra_args: str = None,
3568
+ requirements_file: Optional[str] = None,
3569
+ extra_args: Optional[str] = None,
3516
3570
  force_build: bool = False,
3517
3571
  ) -> typing.Union[BuildStatus, PipelineNodeWrapper]:
3518
3572
  """deploy ML function, build container with its dependencies
@@ -3557,18 +3611,18 @@ class MlrunProject(ModelObj):
3557
3611
 
3558
3612
  def build_config(
3559
3613
  self,
3560
- image: str = None,
3614
+ image: Optional[str] = None,
3561
3615
  set_as_default: bool = False,
3562
- with_mlrun: bool = None,
3563
- base_image: str = None,
3564
- commands: list = None,
3565
- secret_name: str = None,
3566
- requirements: typing.Union[str, list[str]] = None,
3616
+ with_mlrun: Optional[bool] = None,
3617
+ base_image: Optional[str] = None,
3618
+ commands: Optional[list] = None,
3619
+ secret_name: Optional[str] = None,
3620
+ requirements: Optional[typing.Union[str, list[str]]] = None,
3567
3621
  overwrite_build_params: bool = False,
3568
- requirements_file: str = None,
3569
- builder_env: dict = None,
3570
- extra_args: str = None,
3571
- source_code_target_dir: str = None,
3622
+ requirements_file: Optional[str] = None,
3623
+ builder_env: Optional[dict] = None,
3624
+ extra_args: Optional[str] = None,
3625
+ source_code_target_dir: Optional[str] = None,
3572
3626
  ):
3573
3627
  """specify builder configuration for the project
3574
3628
 
@@ -3622,19 +3676,19 @@ class MlrunProject(ModelObj):
3622
3676
 
3623
3677
  def build_image(
3624
3678
  self,
3625
- image: str = None,
3679
+ image: Optional[str] = None,
3626
3680
  set_as_default: bool = True,
3627
- with_mlrun: bool = None,
3628
- base_image: str = None,
3629
- commands: list = None,
3630
- secret_name: str = None,
3631
- requirements: typing.Union[str, list[str]] = None,
3632
- mlrun_version_specifier: str = None,
3633
- builder_env: dict = None,
3681
+ with_mlrun: Optional[bool] = None,
3682
+ base_image: Optional[str] = None,
3683
+ commands: Optional[list] = None,
3684
+ secret_name: Optional[str] = None,
3685
+ requirements: Optional[typing.Union[str, list[str]]] = None,
3686
+ mlrun_version_specifier: Optional[str] = None,
3687
+ builder_env: Optional[dict] = None,
3634
3688
  overwrite_build_params: bool = False,
3635
- requirements_file: str = None,
3636
- extra_args: str = None,
3637
- target_dir: str = None,
3689
+ requirements_file: Optional[str] = None,
3690
+ extra_args: Optional[str] = None,
3691
+ target_dir: Optional[str] = None,
3638
3692
  ) -> typing.Union[BuildStatus, PipelineNodeWrapper]:
3639
3693
  """Builder docker image for the project, based on the project's build config. Parameters allow to override
3640
3694
  the build config.
@@ -3740,12 +3794,12 @@ class MlrunProject(ModelObj):
3740
3794
  def deploy_function(
3741
3795
  self,
3742
3796
  function: typing.Union[str, mlrun.runtimes.BaseRuntime],
3743
- models: list = None,
3744
- env: dict = None,
3745
- tag: str = None,
3746
- verbose: bool = None,
3747
- builder_env: dict = None,
3748
- mock: bool = None,
3797
+ models: Optional[list] = None,
3798
+ env: Optional[dict] = None,
3799
+ tag: Optional[str] = None,
3800
+ verbose: Optional[bool] = None,
3801
+ builder_env: Optional[dict] = None,
3802
+ mock: Optional[bool] = None,
3749
3803
  ) -> typing.Union[DeployStatus, PipelineNodeWrapper]:
3750
3804
  """deploy real-time (nuclio based) functions
3751
3805
 
@@ -3792,15 +3846,15 @@ class MlrunProject(ModelObj):
3792
3846
  self,
3793
3847
  name=None,
3794
3848
  tag=None,
3795
- labels: Optional[Union[dict[str, str], list[str]]] = None,
3849
+ labels: Optional[Union[str, dict[str, Optional[str]], list[str]]] = None,
3796
3850
  since=None,
3797
3851
  until=None,
3798
- iter: int = None,
3852
+ iter: Optional[int] = None,
3799
3853
  best_iteration: bool = False,
3800
- kind: str = None,
3854
+ kind: Optional[str] = None,
3801
3855
  category: typing.Union[str, mlrun.common.schemas.ArtifactCategories] = None,
3802
- tree: str = None,
3803
- limit: int = None,
3856
+ tree: Optional[str] = None,
3857
+ limit: Optional[int] = None,
3804
3858
  format_: Optional[
3805
3859
  mlrun.common.formatters.ArtifactFormat
3806
3860
  ] = mlrun.common.formatters.ArtifactFormat.full,
@@ -3813,7 +3867,7 @@ class MlrunProject(ModelObj):
3813
3867
  Examples::
3814
3868
 
3815
3869
  # Get latest version of all artifacts in project
3816
- latest_artifacts = project.list_artifacts("", tag="latest")
3870
+ latest_artifacts = project.list_artifacts(tag="latest")
3817
3871
  # check different artifact versions for a specific artifact, return as objects list
3818
3872
  result_versions = project.list_artifacts("results", tag="*").to_objects()
3819
3873
 
@@ -3821,8 +3875,13 @@ class MlrunProject(ModelObj):
3821
3875
  case-sensitive. This means that querying for ``~name`` may return artifacts named
3822
3876
  ``my_Name_1`` or ``surname``.
3823
3877
  :param tag: Return artifacts assigned this tag.
3824
- :param labels: Return artifacts that have these labels. Labels can either be a dictionary {"label": "value"} or
3825
- a list of "label=value" (match label key and value) or "label" (match just label key) strings.
3878
+ :param labels: Filter artifacts by label key-value pairs or key existence. This can be provided as:
3879
+ - A dictionary in the format `{"label": "value"}` to match specific label key-value pairs,
3880
+ or `{"label": None}` to check for key existence.
3881
+ - A list of strings formatted as `"label=value"` to match specific label key-value pairs,
3882
+ or just `"label"` for key existence.
3883
+ - A comma-separated string formatted as `"label1=value1,label2"` to match entities with
3884
+ the specified key-value pairs or key existence.
3826
3885
  :param since: Not in use in :py:class:`HTTPRunDB`.
3827
3886
  :param until: Not in use in :py:class:`HTTPRunDB`.
3828
3887
  :param iter: Return artifacts from a specific iteration (where ``iter=0`` means the root iteration). If
@@ -3853,17 +3912,80 @@ class MlrunProject(ModelObj):
3853
3912
  limit=limit,
3854
3913
  )
3855
3914
 
3915
+ def paginated_list_artifacts(
3916
+ self,
3917
+ *args,
3918
+ page: Optional[int] = None,
3919
+ page_size: Optional[int] = None,
3920
+ page_token: Optional[str] = None,
3921
+ **kwargs,
3922
+ ) -> tuple[mlrun.lists.ArtifactList, Optional[str]]:
3923
+ """List artifacts with support for pagination and various filtering options.
3924
+
3925
+ This method retrieves a paginated list of artifacts based on the specified filter parameters.
3926
+ Pagination is controlled using the `page`, `page_size`, and `page_token` parameters. The method
3927
+ will return a list of artifacts that match the filtering criteria provided.
3928
+
3929
+ The returned result is an `ArtifactList` (list of dict), use `.to_objects()` to convert it to a list of
3930
+ RunObjects, `.show()` to view graphically in Jupyter, and `.to_df()` to convert to a DataFrame.
3931
+
3932
+ For detailed information about the parameters, refer to the list_artifacts method:
3933
+ See :py:func:`~list_artifacts` for more details.
3934
+
3935
+ Examples::
3936
+
3937
+ # Fetch first page of artifacts with page size of 5
3938
+ artifacts, token = project.paginated_list_artifacts("results", page_size=5)
3939
+ # Fetch next page using the pagination token from the previous response
3940
+ artifacts, token = project.paginated_list_artifacts("results", page_token=token)
3941
+ # Fetch artifacts for a specific page (e.g., page 3)
3942
+ artifacts, token = project.paginated_list_artifacts(
3943
+ "results", page=3, page_size=5
3944
+ )
3945
+
3946
+ # Automatically iterate over all pages without explicitly specifying the page number
3947
+ artifacts = []
3948
+ token = None
3949
+ while True:
3950
+ page_artifacts, token = project.paginated_list_artifacts(
3951
+ page_token=token, page_size=5
3952
+ )
3953
+ artifacts.extend(page_artifacts)
3954
+
3955
+ # If token is None and page_artifacts is empty, we've reached the end (no more artifacts).
3956
+ # If token is None and page_artifacts is not empty, we've fetched the last page of artifacts.
3957
+ if not token:
3958
+ break
3959
+ print(f"Total artifacts retrieved: {len(artifacts)}")
3960
+
3961
+ :param page: The page number to retrieve. If not provided, the next page will be retrieved.
3962
+ :param page_size: The number of items per page to retrieve. Up to `page_size` responses are expected.
3963
+ :param page_token: A pagination token used to retrieve the next page of results. Should not be provided
3964
+ for the first request.
3965
+
3966
+ :returns: A tuple containing the list of artifacts and an optional `page_token` for pagination.
3967
+ """
3968
+ db = mlrun.db.get_run_db(secrets=self._secrets)
3969
+ return db.paginated_list_artifacts(
3970
+ *args,
3971
+ project=self.metadata.name,
3972
+ page=page,
3973
+ page_size=page_size,
3974
+ page_token=page_token,
3975
+ **kwargs,
3976
+ )
3977
+
3856
3978
  def list_models(
3857
3979
  self,
3858
3980
  name=None,
3859
3981
  tag=None,
3860
- labels: Optional[Union[dict[str, str], list[str]]] = None,
3982
+ labels: Optional[Union[str, dict[str, Optional[str]], list[str]]] = None,
3861
3983
  since=None,
3862
3984
  until=None,
3863
- iter: int = None,
3985
+ iter: Optional[int] = None,
3864
3986
  best_iteration: bool = False,
3865
- tree: str = None,
3866
- limit: int = None,
3987
+ tree: Optional[str] = None,
3988
+ limit: Optional[int] = None,
3867
3989
  format_: Optional[
3868
3990
  mlrun.common.formatters.ArtifactFormat
3869
3991
  ] = mlrun.common.formatters.ArtifactFormat.full,
@@ -3873,15 +3995,20 @@ class MlrunProject(ModelObj):
3873
3995
  Examples::
3874
3996
 
3875
3997
  # Get latest version of all models in project
3876
- latest_models = project.list_models("", tag="latest")
3998
+ latest_models = project.list_models(tag="latest")
3877
3999
 
3878
4000
 
3879
4001
  :param name: Name of artifacts to retrieve. Name with '~' prefix is used as a like query, and is not
3880
4002
  case-sensitive. This means that querying for ``~name`` may return artifacts named
3881
4003
  ``my_Name_1`` or ``surname``.
3882
4004
  :param tag: Return artifacts assigned this tag.
3883
- :param labels: Return artifacts that have these labels. Labels can either be a dictionary {"label": "value"} or
3884
- a list of "label=value" (match label key and value) or "label" (match just label key) strings.
4005
+ :param labels: Filter model artifacts by label key-value pairs or key existence. This can be provided as:
4006
+ - A dictionary in the format `{"label": "value"}` to match specific label key-value pairs,
4007
+ or `{"label": None}` to check for key existence.
4008
+ - A list of strings formatted as `"label=value"` to match specific label key-value pairs,
4009
+ or just `"label"` for key existence.
4010
+ - A comma-separated string formatted as `"label1=value1,label2"` to match entities with
4011
+ the specified key-value pairs or key existence.
3885
4012
  :param since: Not in use in :py:class:`HTTPRunDB`.
3886
4013
  :param until: Not in use in :py:class:`HTTPRunDB`.
3887
4014
  :param iter: Return artifacts from a specific iteration (where ``iter=0`` means the root iteration). If
@@ -3903,13 +4030,79 @@ class MlrunProject(ModelObj):
3903
4030
  until=until,
3904
4031
  iter=iter,
3905
4032
  best_iteration=best_iteration,
3906
- kind="model",
4033
+ kind=mlrun.artifacts.model.ModelArtifact.kind,
3907
4034
  tree=tree,
3908
4035
  limit=limit,
3909
4036
  format_=format_,
3910
4037
  ).to_objects()
3911
4038
 
3912
- def list_functions(self, name=None, tag=None, labels=None):
4039
+ def paginated_list_models(
4040
+ self,
4041
+ *args,
4042
+ page: Optional[int] = None,
4043
+ page_size: Optional[int] = None,
4044
+ page_token: Optional[str] = None,
4045
+ **kwargs,
4046
+ ) -> tuple[mlrun.lists.ArtifactList, Optional[str]]:
4047
+ """List models in project with support for pagination and various filtering options.
4048
+
4049
+ This method retrieves a paginated list of artifacts based on the specified filter parameters.
4050
+ Pagination is controlled using the `page`, `page_size`, and `page_token` parameters. The method
4051
+ will return a list of artifacts that match the filtering criteria provided.
4052
+
4053
+ For detailed information about the parameters, refer to the list_models method:
4054
+ See :py:func:`~list_models` for more details.
4055
+
4056
+ Examples::
4057
+
4058
+ # Fetch first page of artifacts with page size of 5
4059
+ artifacts, token = project.paginated_list_models("results", page_size=5)
4060
+ # Fetch next page using the pagination token from the previous response
4061
+ artifacts, token = project.paginated_list_models("results", page_token=token)
4062
+ # Fetch artifacts for a specific page (e.g., page 3)
4063
+ artifacts, token = project.paginated_list_models("results", page=3, page_size=5)
4064
+
4065
+ # Automatically iterate over all pages without explicitly specifying the page number
4066
+ artifacts = []
4067
+ token = None
4068
+ while True:
4069
+ page_artifacts, token = project.paginated_list_models(
4070
+ page_token=token, page_size=5
4071
+ )
4072
+ artifacts.extend(page_artifacts)
4073
+
4074
+ # If token is None and page_artifacts is empty, we've reached the end (no more artifacts).
4075
+ # If token is None and page_artifacts is not empty, we've fetched the last page of artifacts.
4076
+ if not token:
4077
+ break
4078
+ print(f"Total artifacts retrieved: {len(artifacts)}")
4079
+
4080
+ :param page: The page number to retrieve. If not provided, the next page will be retrieved.
4081
+ :param page_size: The number of items per page to retrieve. Up to `page_size` responses are expected.
4082
+ :param page_token: A pagination token used to retrieve the next page of results. Should not be provided
4083
+ for the first request.
4084
+
4085
+ :returns: A tuple containing the list of artifacts and an optional `page_token` for pagination.
4086
+ """
4087
+ db = mlrun.db.get_run_db(secrets=self._secrets)
4088
+ return db.paginated_list_artifacts(
4089
+ *args,
4090
+ project=self.metadata.name,
4091
+ kind=mlrun.artifacts.model.ModelArtifact.kind,
4092
+ page=page,
4093
+ page_size=page_size,
4094
+ page_token=page_token,
4095
+ **kwargs,
4096
+ )
4097
+
4098
+ def list_functions(
4099
+ self,
4100
+ name: Optional[str] = None,
4101
+ tag: Optional[str] = None,
4102
+ labels: Optional[Union[str, dict[str, Optional[str]], list[str]]] = None,
4103
+ kind: Optional[str] = None,
4104
+ format_: Optional[str] = None,
4105
+ ):
3913
4106
  """Retrieve a list of functions, filtered by specific criteria.
3914
4107
 
3915
4108
  example::
@@ -3919,20 +4112,95 @@ class MlrunProject(ModelObj):
3919
4112
 
3920
4113
  :param name: Return only functions with a specific name.
3921
4114
  :param tag: Return function versions with specific tags. To return only tagged functions, set tag to ``"*"``.
3922
- :param labels: Return functions that have specific labels assigned to them.
4115
+ :param labels: Filter functions by label key-value pairs or key existence. This can be provided as:
4116
+ - A dictionary in the format `{"label": "value"}` to match specific label key-value pairs,
4117
+ or `{"label": None}` to check for key existence.
4118
+ - A list of strings formatted as `"label=value"` to match specific label key-value pairs,
4119
+ or just `"label"` for key existence.
4120
+ - A comma-separated string formatted as `"label1=value1,label2"` to match entities with
4121
+ the specified key-value pairs or key existence.
4122
+ :param kind: Return functions of the specified kind. If not provided, all function kinds will be returned.
4123
+ :param format_: The format in which to return the functions. Default is 'full'.
3923
4124
  :returns: List of function objects.
3924
4125
  """
3925
4126
  db = mlrun.db.get_run_db(secrets=self._secrets)
3926
- functions = db.list_functions(name, self.metadata.name, tag=tag, labels=labels)
4127
+ functions = db.list_functions(
4128
+ name,
4129
+ project=self.metadata.name,
4130
+ tag=tag,
4131
+ kind=kind,
4132
+ labels=labels,
4133
+ format_=format_,
4134
+ )
3927
4135
  if functions:
3928
4136
  # convert dict to function objects
3929
4137
  return [mlrun.new_function(runtime=func) for func in functions]
3930
4138
 
4139
+ def paginated_list_functions(
4140
+ self,
4141
+ *args,
4142
+ page: Optional[int] = None,
4143
+ page_size: Optional[int] = None,
4144
+ page_token: Optional[str] = None,
4145
+ **kwargs,
4146
+ ) -> tuple[list, Optional[str]]:
4147
+ """List functions with support for pagination and various filtering options.
4148
+
4149
+ This method retrieves a paginated list of functions based on the specified filter parameters.
4150
+ Pagination is controlled using the `page`, `page_size`, and `page_token` parameters. The method
4151
+ will return a list of functions that match the filtering criteria provided.
4152
+
4153
+ For detailed information about the parameters, refer to the list_functions method:
4154
+ See :py:func:`~list_functions` for more details.
4155
+
4156
+ Examples::
4157
+
4158
+ # Fetch first page of functions with page size of 5
4159
+ functions, token = project.paginated_list_functions(page_size=5)
4160
+ # Fetch next page using the pagination token from the previous response
4161
+ functions, token = project.paginated_list_functions(page_token=token)
4162
+ # Fetch functions for a specific page (e.g., page 3)
4163
+ functions, token = project.paginated_list_functions(page=3, page_size=5)
4164
+
4165
+ # Automatically iterate over all pages without explicitly specifying the page number
4166
+ functions = []
4167
+ token = None
4168
+ while True:
4169
+ page_functions, token = project.paginated_list_functions(
4170
+ page_token=token, page_size=5
4171
+ )
4172
+ functions.extend(page_functions)
4173
+
4174
+ # If token is None and page_functions is empty, we've reached the end (no more functions).
4175
+ # If token is None and page_functions is not empty, we've fetched the last page of functions.
4176
+ if not token:
4177
+ break
4178
+ print(f"Total functions retrieved: {len(functions)}")
4179
+
4180
+ :param page: The page number to retrieve. If not provided, the next page will be retrieved.
4181
+ :param page_size: The number of items per page to retrieve. Up to `page_size` responses are expected.
4182
+ :param page_token: A pagination token used to retrieve the next page of results. Should not be provided
4183
+ for the first request.
4184
+
4185
+ :returns: A tuple containing the list of functions and an optional `page_token` for pagination.
4186
+ """
4187
+ db = mlrun.db.get_run_db(secrets=self._secrets)
4188
+ functions, token = db.paginated_list_functions(
4189
+ *args,
4190
+ project=self.metadata.name,
4191
+ page=page,
4192
+ page_size=page_size,
4193
+ page_token=page_token,
4194
+ **kwargs,
4195
+ )
4196
+ # convert dict to function objects
4197
+ return [mlrun.new_function(runtime=func) for func in functions], token
4198
+
3931
4199
  def list_model_monitoring_functions(
3932
4200
  self,
3933
4201
  name: Optional[str] = None,
3934
4202
  tag: Optional[str] = None,
3935
- labels: Optional[list[str]] = None,
4203
+ labels: Optional[Union[str, dict[str, Optional[str]], list[str]]] = None,
3936
4204
  ) -> Optional[list]:
3937
4205
  """
3938
4206
  Retrieve a list of all the model monitoring functions.
@@ -3942,8 +4210,13 @@ class MlrunProject(ModelObj):
3942
4210
 
3943
4211
  :param name: Return only functions with a specific name.
3944
4212
  :param tag: Return function versions with specific tags.
3945
- :param labels: Return functions that have specific labels assigned to them.
3946
-
4213
+ :param labels: Filter functions by label key-value pairs or key existence. This can be provided as:
4214
+ - A dictionary in the format `{"label": "value"}` to match specific label key-value pairs,
4215
+ or `{"label": None}` to check for key existence.
4216
+ - A list of strings formatted as `"label=value"` to match specific label key-value pairs,
4217
+ or just `"label"` for key existence.
4218
+ - A comma-separated string formatted as `"label1=value1,label2"` to match entities with
4219
+ the specified key-value pairs or key existence.
3947
4220
  :returns: List of function objects.
3948
4221
  """
3949
4222
 
@@ -3960,7 +4233,7 @@ class MlrunProject(ModelObj):
3960
4233
  self,
3961
4234
  name: Optional[str] = None,
3962
4235
  uid: Optional[Union[str, list[str]]] = None,
3963
- labels: Optional[Union[str, list[str]]] = None,
4236
+ labels: Optional[Union[str, dict[str, Optional[str]], list[str]]] = None,
3964
4237
  state: Optional[
3965
4238
  mlrun.common.runtimes.constants.RunStates
3966
4239
  ] = None, # Backward compatibility
@@ -3995,9 +4268,13 @@ class MlrunProject(ModelObj):
3995
4268
 
3996
4269
  :param name: Name of the run to retrieve.
3997
4270
  :param uid: Unique ID of the run.
3998
- :param labels: A list of labels to filter by. Label filters work by either filtering a specific value
3999
- of a label (i.e. list("key=value")) or by looking for the existence of a given
4000
- key (i.e. "key").
4271
+ :param labels: Filter runs by label key-value pairs or key existence. This can be provided as:
4272
+ - A dictionary in the format `{"label": "value"}` to match specific label key-value pairs,
4273
+ or `{"label": None}` to check for key existence.
4274
+ - A list of strings formatted as `"label=value"` to match specific label key-value pairs,
4275
+ or just `"label"` for key existence.
4276
+ - A comma-separated string formatted as `"label1=value1,label2"` to match entities with
4277
+ the specified key-value pairs or key existence.
4001
4278
  :param state: Deprecated - List only runs whose state is specified.
4002
4279
  :param states: List only runs whose state is one of the provided states.
4003
4280
  :param sort: Whether to sort the result according to their start time. Otherwise, results will be
@@ -4023,9 +4300,11 @@ class MlrunProject(ModelObj):
4023
4300
  uid,
4024
4301
  self.metadata.name,
4025
4302
  labels=labels,
4026
- states=mlrun.utils.helpers.as_list(state)
4027
- if state is not None
4028
- else states or None,
4303
+ states=(
4304
+ mlrun.utils.helpers.as_list(state)
4305
+ if state is not None
4306
+ else states or None
4307
+ ),
4029
4308
  sort=sort,
4030
4309
  last=last,
4031
4310
  iter=iter,
@@ -4036,6 +4315,68 @@ class MlrunProject(ModelObj):
4036
4315
  **kwargs,
4037
4316
  )
4038
4317
 
4318
+ def paginated_list_runs(
4319
+ self,
4320
+ *args,
4321
+ page: Optional[int] = None,
4322
+ page_size: Optional[int] = None,
4323
+ page_token: Optional[str] = None,
4324
+ **kwargs,
4325
+ ) -> tuple[mlrun.lists.RunList, Optional[str]]:
4326
+ """List runs with support for pagination and various filtering options.
4327
+
4328
+ This method retrieves a paginated list of runs based on the specified filter parameters.
4329
+ Pagination is controlled using the `page`, `page_size`, and `page_token` parameters. The method
4330
+ will return a list of runs that match the filtering criteria provided.
4331
+
4332
+ The returned result is a `` (list of dict), use `.to_objects()` to convert it to a list of RunObjects,
4333
+ `.show()` to view graphically in Jupyter, `.to_df()` to convert to a DataFrame, and `compare()` to
4334
+ generate comparison table and PCP plot.
4335
+
4336
+ For detailed information about the parameters, refer to the list_runs method:
4337
+ See :py:func:`~list_runs` for more details.
4338
+
4339
+ Examples::
4340
+
4341
+ # Fetch first page of runs with page size of 5
4342
+ runs, token = project.paginated_list_runs(page_size=5)
4343
+ # Fetch next page using the pagination token from the previous response
4344
+ runs, token = project.paginated_list_runs(page_token=token)
4345
+ # Fetch runs for a specific page (e.g., page 3)
4346
+ runs, token = project.paginated_list_runs(page=3, page_size=5)
4347
+
4348
+ # Automatically iterate over all pages without explicitly specifying the page number
4349
+ runs = []
4350
+ token = None
4351
+ while True:
4352
+ page_runs, token = project.paginated_list_runs(
4353
+ page_token=token, page_size=5
4354
+ )
4355
+ runs.extend(page_runs)
4356
+
4357
+ # If token is None and page_runs is empty, we've reached the end (no more runs).
4358
+ # If token is None and page_runs is not empty, we've fetched the last page of runs.
4359
+ if not token:
4360
+ break
4361
+ print(f"Total runs retrieved: {len(runs)}")
4362
+
4363
+ :param page: The page number to retrieve. If not provided, the next page will be retrieved.
4364
+ :param page_size: The number of items per page to retrieve. Up to `page_size` responses are expected.
4365
+ :param page_token: A pagination token used to retrieve the next page of results. Should not be provided
4366
+ for the first request.
4367
+
4368
+ :returns: A tuple containing the list of runs and an optional `page_token` for pagination.
4369
+ """
4370
+ db = mlrun.db.get_run_db(secrets=self._secrets)
4371
+ return db.paginated_list_runs(
4372
+ *args,
4373
+ project=self.metadata.name,
4374
+ page=page,
4375
+ page_size=page_size,
4376
+ page_token=page_token,
4377
+ **kwargs,
4378
+ )
4379
+
4039
4380
  def register_datastore_profile(self, profile: DatastoreProfile):
4040
4381
  private_body = DatastoreProfile2Json.get_json_private(profile)
4041
4382
  public_body = DatastoreProfile2Json.get_json_public(profile)
@@ -4188,13 +4529,17 @@ class MlrunProject(ModelObj):
4188
4529
  mlrun.db.get_run_db().delete_api_gateway(name=name, project=self.name)
4189
4530
 
4190
4531
  def store_alert_config(
4191
- self, alert_data: AlertConfig, alert_name: typing.Optional[str] = None
4532
+ self,
4533
+ alert_data: AlertConfig,
4534
+ alert_name: typing.Optional[str] = None,
4535
+ force_reset: bool = False,
4192
4536
  ) -> AlertConfig:
4193
4537
  """
4194
4538
  Create/modify an alert.
4195
4539
 
4196
4540
  :param alert_data: The data of the alert.
4197
4541
  :param alert_name: The name of the alert.
4542
+ :param force_reset: If True and the alert already exists, the alert would be reset.
4198
4543
  :return: the created/modified alert.
4199
4544
  """
4200
4545
  if not alert_data:
@@ -4208,7 +4553,9 @@ class MlrunProject(ModelObj):
4208
4553
  project=alert_data.project,
4209
4554
  )
4210
4555
  alert_data.project = self.metadata.name
4211
- return db.store_alert_config(alert_name, alert_data, project=self.metadata.name)
4556
+ return db.store_alert_config(
4557
+ alert_name, alert_data, project=self.metadata.name, force_reset=force_reset
4558
+ )
4212
4559
 
4213
4560
  def get_alert_config(self, alert_name: str) -> AlertConfig:
4214
4561
  """
@@ -4230,7 +4577,7 @@ class MlrunProject(ModelObj):
4230
4577
  return db.list_alerts_configs(self.metadata.name)
4231
4578
 
4232
4579
  def delete_alert_config(
4233
- self, alert_data: AlertConfig = None, alert_name: str = None
4580
+ self, alert_data: AlertConfig = None, alert_name: Optional[str] = None
4234
4581
  ):
4235
4582
  """
4236
4583
  Delete an alert.
@@ -4250,7 +4597,7 @@ class MlrunProject(ModelObj):
4250
4597
  db.delete_alert_config(alert_name, self.metadata.name)
4251
4598
 
4252
4599
  def reset_alert_config(
4253
- self, alert_data: AlertConfig = None, alert_name: str = None
4600
+ self, alert_data: AlertConfig = None, alert_name: Optional[str] = None
4254
4601
  ):
4255
4602
  """
4256
4603
  Reset an alert.
@@ -4292,8 +4639,8 @@ class MlrunProject(ModelObj):
4292
4639
  self,
4293
4640
  action: Callable,
4294
4641
  remote: str,
4295
- args: list = None,
4296
- kwargs: dict = None,
4642
+ args: Optional[list] = None,
4643
+ kwargs: Optional[dict] = None,
4297
4644
  secrets: Union[SecretsStore, dict] = None,
4298
4645
  ):
4299
4646
  """Run an arbitrary Git routine while the remote is enriched with secrets
@@ -4370,7 +4717,7 @@ class MlrunProject(ModelObj):
4370
4717
  def _resolve_artifact_producer(
4371
4718
  self,
4372
4719
  artifact: typing.Union[str, Artifact],
4373
- project_producer_tag: str = None,
4720
+ project_producer_tag: Optional[str] = None,
4374
4721
  ) -> tuple[ArtifactProducer, bool]:
4375
4722
  """
4376
4723
  Resolve the artifact producer of the given artifact.
@@ -4400,28 +4747,34 @@ class MlrunProject(ModelObj):
4400
4747
  )
4401
4748
 
4402
4749
  if producer_dict.get("kind", "") == "run":
4403
- return ArtifactProducer(
4404
- name=producer_dict.get("name", ""),
4405
- kind=producer_dict.get("kind", ""),
4406
- project=producer_project,
4407
- tag=producer_tag,
4408
- owner=producer_dict.get("owner", ""),
4409
- ), True
4750
+ return (
4751
+ ArtifactProducer(
4752
+ name=producer_dict.get("name", ""),
4753
+ kind=producer_dict.get("kind", ""),
4754
+ project=producer_project,
4755
+ tag=producer_tag,
4756
+ owner=producer_dict.get("owner", ""),
4757
+ ),
4758
+ True,
4759
+ )
4410
4760
 
4411
4761
  # do not retain the artifact's producer, replace it with the project as the producer
4412
4762
  project_producer_tag = project_producer_tag or self._get_project_tag()
4413
- return ArtifactProducer(
4414
- kind="project",
4415
- name=self.metadata.name,
4416
- project=self.metadata.name,
4417
- tag=project_producer_tag,
4418
- owner=self._resolve_artifact_owner(),
4419
- ), False
4763
+ return (
4764
+ ArtifactProducer(
4765
+ kind="project",
4766
+ name=self.metadata.name,
4767
+ project=self.metadata.name,
4768
+ tag=project_producer_tag,
4769
+ owner=self._resolve_artifact_owner(),
4770
+ ),
4771
+ False,
4772
+ )
4420
4773
 
4421
4774
  def _resolve_existing_artifact(
4422
4775
  self,
4423
4776
  item: typing.Union[str, Artifact],
4424
- tag: str = None,
4777
+ tag: Optional[str] = None,
4425
4778
  ) -> typing.Optional[Artifact]:
4426
4779
  """
4427
4780
  Check if there is and existing artifact with the given item and tag.