Skip to content

Commit fc58b56

Browse files
committed
API client for dataset copy
1 parent 7874938 commit fc58b56

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

dataikuapi/dss/dataset.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from ..utils import DataikuUTF8CSVReader
33
from ..utils import DataikuStreamedHttpUTF8CSVReader
44
import json
5+
from .future import DSSFuture
56
from .metrics import ComputedMetrics
67
from .discussion import DSSObjectDiscussions
78

@@ -152,6 +153,23 @@ def clear(self, partitions=None):
152153
"DELETE", "/projects/%s/datasets/%s/data" % (self.project_key, self.dataset_name),
153154
params={"partitions" : partitions})
154155

156+
def copy_to(self, target, sync_schema=True, write_mode="OVERWRITE"):
157+
"""
158+
Copies the data of this dataset to another dataset
159+
160+
:param target Dataset: a :class:`dataikuapi.dss.dataset.DSSDataset` representing the target of this copy
161+
:returns: a DSSFuture representing the operation
162+
"""
163+
dqr = {
164+
"targetProjectKey" : target.project_key,
165+
"targetDatasetName": target.dataset_name,
166+
"syncSchema": sync_schema,
167+
"writeMode" : write_mode
168+
}
169+
print(dqr)
170+
future_resp = self.client._perform_json("POST", "/projects/%s/datasets/%s/actions/copyTo" % (self.project_key, self.dataset_name), body=dqr)
171+
return DSSFuture(self.client, future_resp.get("jobId", None), future_resp)
172+
155173
########################################################
156174
# Dataset actions
157175
########################################################

0 commit comments

Comments
 (0)