From c395b50ed3f6df5f2776b5333db6af57a1fe858c Mon Sep 17 00:00:00 2001 From: VsevolodX Date: Tue, 4 Feb 2025 18:49:15 -0800 Subject: [PATCH] update: add owner_id to create --- exabyte_api_client/endpoints/entity.py | 5 ++++- exabyte_api_client/endpoints/jobs.py | 8 ++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/exabyte_api_client/endpoints/entity.py b/exabyte_api_client/endpoints/entity.py index da56c10..1da3d1d 100644 --- a/exabyte_api_client/endpoints/entity.py +++ b/exabyte_api_client/endpoints/entity.py @@ -76,16 +76,19 @@ def update(self, id_, modifier): """ return self.request("PATCH", "/".join((self.name, id_)), data=json.dumps(modifier), headers=self.headers) - def create(self, config): + def create(self, config, owner_id=None): """ Creates a new entity. Args: config (dict): entity config. + owner_id (str): owner ID. Entity is created under user's default account if not specified. Returns: dict: new entity. """ + if owner_id: + config["owner"] = {"_id": owner_id} return self.request("PUT", "/".join((self.name, "create")), data=json.dumps(config), headers=self.headers) def copy(self, id_): diff --git a/exabyte_api_client/endpoints/jobs.py b/exabyte_api_client/endpoints/jobs.py index 808a050..1112d00 100644 --- a/exabyte_api_client/endpoints/jobs.py +++ b/exabyte_api_client/endpoints/jobs.py @@ -110,7 +110,7 @@ def get_compute(self, cluster, ppn=1, nodes=1, queue="D", time_limit="01:00:00", "arguments": {}, } - def create_by_ids(self, materials, workflow_id, project_id, owner_id, prefix, compute=None): + def create_by_ids(self, materials, workflow_id, project_id, prefix, owner_id=None, compute=None): """ Creates jobs from the given materials @@ -118,12 +118,12 @@ def create_by_ids(self, materials, workflow_id, project_id, owner_id, prefix, co materials (list[dict]): list of materials. workflow_id (str): workflow ID. project_id (str): project ID. - owner_id (str): owner ID. - compute (dict): compute configuration. prefix (str): job prefix. + owner_id (str, optional): owner ID. + compute (dict, optional): compute configuration. Returns: - list + list: List of created jobs. """ jobs = [] for material in materials: