Skip to content

Commit

Permalink
python/sdk: modify Object.promote to return job ID for status check
Browse files Browse the repository at this point in the history
Signed-off-by: Tony Chen <[email protected]>
  • Loading branch information
Nahemah1022 committed Jul 1, 2024
1 parent 5802f11 commit 575a042
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions docs/python_sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -1308,7 +1308,7 @@ def promote(path: str,
recursive: bool = False,
overwrite_dest: bool = False,
delete_source: bool = False,
src_not_file_share: bool = False) -> Header
src_not_file_share: bool = False) -> str
```

Promotes a file or folder an AIS target can access to a bucket in AIS storage.
Expand All @@ -1328,7 +1328,7 @@ See more info here: https://aiatscale.org/blog/2022/03/17/promote

**Returns**:

Object properties
Job ID (as str) that can be used to check the status of the operation


**Raises**:
Expand Down
6 changes: 3 additions & 3 deletions python/aistore/sdk/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def promote(
overwrite_dest: bool = False,
delete_source: bool = False,
src_not_file_share: bool = False,
) -> Header:
) -> str:
"""
Promotes a file or folder an AIS target can access to a bucket in AIS storage.
These files can be either on the physical disk of an AIS target itself or on a network file system
Expand All @@ -263,7 +263,7 @@ def promote(
src_not_file_share (bool, optional): Optimize if the source is guaranteed to not be on a file share
Returns:
Object properties
Job ID (as str) that can be used to check the status of the operation
Raises:
requests.RequestException: "There was an ambiguous exception that occurred while handling..."
Expand All @@ -286,7 +286,7 @@ def promote(

return self._client.request(
HTTP_METHOD_POST, path=url, params=self._qparams, json=json_val
).headers
).text

def delete(self):
"""
Expand Down
7 changes: 5 additions & 2 deletions python/tests/integration/sdk/test_object_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ def test_promote(self):

# Promote to AIS bucket
obj_name = "promoted_obj/"
self.bucket.object(obj_name).promote(str(local_files_path))
promote_job = self.bucket.object(obj_name).promote(str(local_files_path))
self.client.job(job_id=promote_job).wait_for_idle(timeout=TEST_TIMEOUT)

# Check bucket, only top object is promoted
self.assertEqual(1, len(self.bucket.list_all_objects()))
Expand All @@ -232,12 +233,14 @@ def test_promote(self):
file.write(top_item_updated_contents)

# Promote with recursion, delete source, overwrite destination
self.bucket.object(obj_name).promote(
promote_job = self.bucket.object(obj_name).promote(
str(local_files_path),
recursive=True,
delete_source=True,
overwrite_dest=True,
)
self.client.job(job_id=promote_job).wait_for_idle(timeout=TEST_TIMEOUT)

# Check bucket, both objects promoted, top overwritten
self.assertEqual(2, len(self.bucket.list_all_objects()))
expected_top_obj = obj_name + top_item
Expand Down

0 comments on commit 575a042

Please sign in to comment.