def _create_resources_of_all_kinds(db: DBInterface, db_session: sqlalchemy.orm.Session, project: str): # Create several functions with several tags labels = { "name": "value", "name2": "value2", } function = { "bla": "blabla", "metadata": { "labels": labels }, "status": { "bla": "blabla" }, } function_names = ["function_name_1", "function_name_2", "function_name_3"] function_tags = ["some_tag", "some_tag2", "some_tag3"] for function_name in function_names: for function_tag in function_tags: db.store_function( db_session, function, function_name, project, tag=function_tag, versioned=True, ) # Create several artifacts with several tags artifact = { "bla": "blabla", "labels": labels, "status": { "bla": "blabla" }, } artifact_keys = ["artifact_key_1", "artifact_key_2", "artifact_key_3"] artifact_uids = ["some_uid", "some_uid2", "some_uid3"] artifact_tags = ["some_tag", "some_tag2", "some_tag3"] for artifact_key in artifact_keys: for artifact_uid in artifact_uids: for artifact_tag in artifact_tags: for artifact_iter in range(3): db.store_artifact( db_session, artifact_key, artifact, artifact_uid, artifact_iter, artifact_tag, project, ) # Create several runs run = { "bla": "blabla", "metadata": { "labels": labels }, "status": { "bla": "blabla" }, } run_uids = ["some_uid", "some_uid2", "some_uid3"] for run_uid in run_uids: for run_iter in range(3): db.store_run(db_session, run, run_uid, project, run_iter) # Create several logs log = b"some random log" log_uids = ["some_uid", "some_uid2", "some_uid3"] for log_uid in log_uids: db.store_log(db_session, log_uid, project, log) # Create several schedule schedule = { "bla": "blabla", "status": { "bla": "blabla" }, } schedule_cron_trigger = schemas.ScheduleCronTrigger(year=1999) schedule_names = ["schedule_name_1", "schedule_name_2", "schedule_name_3"] for schedule_name in schedule_names: db.create_schedule( db_session, project, schedule_name, schemas.ScheduleKinds.job, schedule, schedule_cron_trigger, labels, ) feature_set = schemas.FeatureSet( metadata=schemas.ObjectMetadata(name="dummy", tag="latest", labels={"owner": "nobody"}), spec=schemas.FeatureSetSpec( entities=[ schemas.Entity(name="ent1", value_type="str", labels={"label": "1"}) ], features=[ schemas.Feature(name="feat1", value_type="str", labels={"label": "1"}) ], ), status={}, ) db.create_feature_set(db_session, project, feature_set) feature_vector = schemas.FeatureVector( metadata=schemas.ObjectMetadata(name="dummy", tag="latest", labels={"owner": "somebody"}), spec=schemas.ObjectSpec(), status=schemas.ObjectStatus(state="created"), ) db.create_feature_vector(db_session, project, feature_vector)
def _create_resources_of_all_kinds(db_session: Session, project: str): db = mlrun.api.utils.singletons.db.get_db() # add labels to project project_schema = mlrun.api.schemas.Project( metadata=mlrun.api.schemas.ProjectMetadata(name=project, labels={"key": "value"}), spec=mlrun.api.schemas.ProjectSpec(description="some desc"), ) db.store_project(db_session, project, project_schema) # Create several functions with several tags labels = { "name": "value", "name2": "value2", } function = { "bla": "blabla", "metadata": { "labels": labels }, "status": { "bla": "blabla" }, } function_names = ["function_name_1", "function_name_2", "function_name_3"] function_tags = ["some_tag", "some_tag2", "some_tag3"] for function_name in function_names: for function_tag in function_tags: db.store_function( db_session, function, function_name, project, tag=function_tag, versioned=True, ) # Create several artifacts with several tags artifact = { "bla": "blabla", "labels": labels, "status": { "bla": "blabla" }, } artifact_keys = ["artifact_key_1", "artifact_key_2", "artifact_key_3"] artifact_uids = ["some_uid", "some_uid2", "some_uid3"] artifact_tags = ["some_tag", "some_tag2", "some_tag3"] for artifact_key in artifact_keys: for artifact_uid in artifact_uids: for artifact_tag in artifact_tags: for artifact_iter in range(3): db.store_artifact( db_session, artifact_key, artifact, artifact_uid, artifact_iter, artifact_tag, project, ) # Create several runs run = { "bla": "blabla", "metadata": { "labels": labels }, "status": { "bla": "blabla" }, } run_uids = ["some_uid", "some_uid2", "some_uid3"] for run_uid in run_uids: for run_iter in range(3): db.store_run(db_session, run, run_uid, project, run_iter) # Create several logs log = b"some random log" log_uids = ["some_uid", "some_uid2", "some_uid3"] for log_uid in log_uids: db.store_log(db_session, log_uid, project, log) # Create several schedule schedule = { "bla": "blabla", "status": { "bla": "blabla" }, } schedule_cron_trigger = mlrun.api.schemas.ScheduleCronTrigger(year=1999) schedule_names = ["schedule_name_1", "schedule_name_2", "schedule_name_3"] for schedule_name in schedule_names: db.create_schedule( db_session, project, schedule_name, mlrun.api.schemas.ScheduleKinds.job, schedule, schedule_cron_trigger, mlrun.config.config.httpdb.scheduling.default_concurrency_limit, labels, ) feature_set = mlrun.api.schemas.FeatureSet( metadata=mlrun.api.schemas.ObjectMetadata(name="dummy", tag="latest", labels={"owner": "nobody"}), spec=mlrun.api.schemas.FeatureSetSpec( entities=[ mlrun.api.schemas.Entity(name="ent1", value_type="str", labels={"label": "1"}) ], features=[ mlrun.api.schemas.Feature(name="feat1", value_type="str", labels={"label": "1"}) ], ), status={}, ) db.create_feature_set(db_session, project, feature_set) feature_vector = mlrun.api.schemas.FeatureVector( metadata=mlrun.api.schemas.ObjectMetadata(name="dummy", tag="latest", labels={"owner": "somebody"}), spec=mlrun.api.schemas.ObjectSpec(), status=mlrun.api.schemas.ObjectStatus(state="created"), ) db.create_feature_vector(db_session, project, feature_vector)