|
2 | 2 | from ..utils import DataikuUTF8CSVReader |
3 | 3 | from ..utils import DataikuStreamedHttpUTF8CSVReader |
4 | 4 | import json |
| 5 | +from .future import DSSFuture |
5 | 6 | from .metrics import ComputedMetrics |
6 | 7 | from .discussion import DSSObjectDiscussions |
7 | 8 |
|
@@ -152,6 +153,23 @@ def clear(self, partitions=None): |
152 | 153 | "DELETE", "/projects/%s/datasets/%s/data" % (self.project_key, self.dataset_name), |
153 | 154 | params={"partitions" : partitions}) |
154 | 155 |
|
| 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 | + |
155 | 173 | ######################################################## |
156 | 174 | # Dataset actions |
157 | 175 | ######################################################## |
|
0 commit comments