pltr-cli 0.4.0__py3-none-any.whl → 0.5.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pltr/__init__.py +1 -1
- pltr/cli.py +22 -0
- pltr/commands/connectivity.py +432 -0
- pltr/commands/dataset.py +577 -0
- pltr/commands/mediasets.py +422 -0
- pltr/commands/orchestration.py +642 -0
- pltr/commands/project.py +440 -0
- pltr/commands/resource.py +499 -0
- pltr/commands/resource_role.py +454 -0
- pltr/commands/space.py +662 -0
- pltr/services/connectivity.py +305 -0
- pltr/services/dataset.py +603 -10
- pltr/services/mediasets.py +293 -0
- pltr/services/orchestration.py +457 -0
- pltr/services/project.py +232 -0
- pltr/services/resource.py +289 -0
- pltr/services/resource_role.py +321 -0
- pltr/services/space.py +354 -0
- pltr/utils/formatting.py +745 -0
- pltr_cli-0.5.1.dist-info/METADATA +513 -0
- {pltr_cli-0.4.0.dist-info → pltr_cli-0.5.1.dist-info}/RECORD +24 -12
- pltr/services/dataset_full.py +0 -302
- pltr/services/dataset_v2.py +0 -128
- pltr_cli-0.4.0.dist-info/METADATA +0 -287
- {pltr_cli-0.4.0.dist-info → pltr_cli-0.5.1.dist-info}/WHEEL +0 -0
- {pltr_cli-0.4.0.dist-info → pltr_cli-0.5.1.dist-info}/entry_points.txt +0 -0
- {pltr_cli-0.4.0.dist-info → pltr_cli-0.5.1.dist-info}/licenses/LICENSE +0 -0
pltr/services/dataset_full.py
DELETED
|
@@ -1,302 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Dataset service wrapper for Foundry SDK.
|
|
3
|
-
"""
|
|
4
|
-
|
|
5
|
-
from typing import Any, Optional, List, Dict, Union
|
|
6
|
-
from pathlib import Path
|
|
7
|
-
|
|
8
|
-
from .base import BaseService
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class DatasetService(BaseService):
|
|
12
|
-
"""Service wrapper for Foundry dataset operations."""
|
|
13
|
-
|
|
14
|
-
def _get_service(self) -> Any:
|
|
15
|
-
"""Get the Foundry datasets service."""
|
|
16
|
-
return self.client.datasets
|
|
17
|
-
|
|
18
|
-
# list_datasets method removed - not supported by foundry-platform-sdk v1.27.0
|
|
19
|
-
|
|
20
|
-
def get_dataset(self, dataset_rid: str) -> Dict[str, Any]:
|
|
21
|
-
"""
|
|
22
|
-
Get information about a specific dataset.
|
|
23
|
-
|
|
24
|
-
Args:
|
|
25
|
-
dataset_rid: Dataset Resource Identifier
|
|
26
|
-
|
|
27
|
-
Returns:
|
|
28
|
-
Dataset information dictionary
|
|
29
|
-
"""
|
|
30
|
-
try:
|
|
31
|
-
# Use the v2 API's Dataset.get method
|
|
32
|
-
dataset = self.service.Dataset.get(dataset_rid)
|
|
33
|
-
return self._format_dataset_info(dataset)
|
|
34
|
-
except Exception as e:
|
|
35
|
-
raise RuntimeError(f"Failed to get dataset {dataset_rid}: {e}")
|
|
36
|
-
|
|
37
|
-
def get_schema(self, dataset_rid: str) -> Dict[str, Any]:
|
|
38
|
-
"""
|
|
39
|
-
Get dataset schema.
|
|
40
|
-
|
|
41
|
-
Args:
|
|
42
|
-
dataset_rid: Dataset Resource Identifier
|
|
43
|
-
|
|
44
|
-
Returns:
|
|
45
|
-
Schema information
|
|
46
|
-
"""
|
|
47
|
-
try:
|
|
48
|
-
schema = self.service.Dataset.get_schema(dataset_rid)
|
|
49
|
-
return {
|
|
50
|
-
"dataset_rid": dataset_rid,
|
|
51
|
-
"schema": schema,
|
|
52
|
-
"type": str(type(schema)),
|
|
53
|
-
"status": "Schema retrieved successfully",
|
|
54
|
-
}
|
|
55
|
-
except Exception as e:
|
|
56
|
-
raise RuntimeError(f"Failed to get schema for dataset {dataset_rid}: {e}")
|
|
57
|
-
|
|
58
|
-
def create_dataset(
|
|
59
|
-
self, name: str, parent_folder_rid: Optional[str] = None
|
|
60
|
-
) -> Dict[str, Any]:
|
|
61
|
-
"""
|
|
62
|
-
Create a new dataset.
|
|
63
|
-
|
|
64
|
-
Args:
|
|
65
|
-
name: Dataset name
|
|
66
|
-
parent_folder_rid: Parent folder RID (optional)
|
|
67
|
-
|
|
68
|
-
Returns:
|
|
69
|
-
Created dataset information
|
|
70
|
-
"""
|
|
71
|
-
try:
|
|
72
|
-
dataset = self.service.create_dataset(
|
|
73
|
-
name=name, parent_folder_rid=parent_folder_rid
|
|
74
|
-
)
|
|
75
|
-
return self._format_dataset_info(dataset)
|
|
76
|
-
except Exception as e:
|
|
77
|
-
raise RuntimeError(f"Failed to create dataset '{name}': {e}")
|
|
78
|
-
|
|
79
|
-
def delete_dataset(self, dataset_rid: str) -> bool:
|
|
80
|
-
"""
|
|
81
|
-
Delete a dataset.
|
|
82
|
-
|
|
83
|
-
Args:
|
|
84
|
-
dataset_rid: Dataset Resource Identifier
|
|
85
|
-
|
|
86
|
-
Returns:
|
|
87
|
-
True if deletion was successful
|
|
88
|
-
"""
|
|
89
|
-
try:
|
|
90
|
-
self.service.delete_dataset(dataset_rid)
|
|
91
|
-
return True
|
|
92
|
-
except Exception as e:
|
|
93
|
-
raise RuntimeError(f"Failed to delete dataset {dataset_rid}: {e}")
|
|
94
|
-
|
|
95
|
-
def upload_file(
|
|
96
|
-
self,
|
|
97
|
-
dataset_rid: str,
|
|
98
|
-
file_path: Union[str, Path],
|
|
99
|
-
branch: str = "master",
|
|
100
|
-
transaction_rid: Optional[str] = None,
|
|
101
|
-
) -> Dict[str, Any]:
|
|
102
|
-
"""
|
|
103
|
-
Upload a file to a dataset.
|
|
104
|
-
|
|
105
|
-
Args:
|
|
106
|
-
dataset_rid: Dataset Resource Identifier
|
|
107
|
-
file_path: Path to file to upload
|
|
108
|
-
branch: Dataset branch name
|
|
109
|
-
transaction_rid: Transaction RID (optional)
|
|
110
|
-
|
|
111
|
-
Returns:
|
|
112
|
-
Upload result information
|
|
113
|
-
"""
|
|
114
|
-
file_path = Path(file_path)
|
|
115
|
-
if not file_path.exists():
|
|
116
|
-
raise FileNotFoundError(f"File not found: {file_path}")
|
|
117
|
-
|
|
118
|
-
try:
|
|
119
|
-
with open(file_path, "rb") as f:
|
|
120
|
-
result = self.service.upload_file(
|
|
121
|
-
dataset_rid=dataset_rid,
|
|
122
|
-
file_path=file_path.name,
|
|
123
|
-
file_data=f,
|
|
124
|
-
branch=branch,
|
|
125
|
-
transaction_rid=transaction_rid,
|
|
126
|
-
)
|
|
127
|
-
|
|
128
|
-
return {
|
|
129
|
-
"dataset_rid": dataset_rid,
|
|
130
|
-
"file_path": str(file_path),
|
|
131
|
-
"branch": branch,
|
|
132
|
-
"size_bytes": file_path.stat().st_size,
|
|
133
|
-
"uploaded": True,
|
|
134
|
-
"transaction_rid": getattr(result, "transaction_rid", transaction_rid),
|
|
135
|
-
}
|
|
136
|
-
except Exception as e:
|
|
137
|
-
raise RuntimeError(
|
|
138
|
-
f"Failed to upload file {file_path} to dataset {dataset_rid}: {e}"
|
|
139
|
-
)
|
|
140
|
-
|
|
141
|
-
def download_file(
|
|
142
|
-
self,
|
|
143
|
-
dataset_rid: str,
|
|
144
|
-
file_path: str,
|
|
145
|
-
output_path: Union[str, Path],
|
|
146
|
-
branch: str = "master",
|
|
147
|
-
) -> Dict[str, Any]:
|
|
148
|
-
"""
|
|
149
|
-
Download a file from a dataset.
|
|
150
|
-
|
|
151
|
-
Args:
|
|
152
|
-
dataset_rid: Dataset Resource Identifier
|
|
153
|
-
file_path: Path of file within dataset
|
|
154
|
-
output_path: Local path to save the downloaded file
|
|
155
|
-
branch: Dataset branch name
|
|
156
|
-
|
|
157
|
-
Returns:
|
|
158
|
-
Download result information
|
|
159
|
-
"""
|
|
160
|
-
output_path = Path(output_path)
|
|
161
|
-
|
|
162
|
-
try:
|
|
163
|
-
# Ensure output directory exists
|
|
164
|
-
output_path.parent.mkdir(parents=True, exist_ok=True)
|
|
165
|
-
|
|
166
|
-
file_content = self.service.download_file(
|
|
167
|
-
dataset_rid=dataset_rid, file_path=file_path, branch=branch
|
|
168
|
-
)
|
|
169
|
-
|
|
170
|
-
# Write file content to disk
|
|
171
|
-
with open(output_path, "wb") as f:
|
|
172
|
-
if hasattr(file_content, "read"):
|
|
173
|
-
# If it's a stream
|
|
174
|
-
f.write(file_content.read())
|
|
175
|
-
else:
|
|
176
|
-
# If it's bytes
|
|
177
|
-
f.write(file_content)
|
|
178
|
-
|
|
179
|
-
return {
|
|
180
|
-
"dataset_rid": dataset_rid,
|
|
181
|
-
"file_path": file_path,
|
|
182
|
-
"output_path": str(output_path),
|
|
183
|
-
"branch": branch,
|
|
184
|
-
"size_bytes": output_path.stat().st_size,
|
|
185
|
-
"downloaded": True,
|
|
186
|
-
}
|
|
187
|
-
except Exception as e:
|
|
188
|
-
raise RuntimeError(
|
|
189
|
-
f"Failed to download file {file_path} from dataset {dataset_rid}: {e}"
|
|
190
|
-
)
|
|
191
|
-
|
|
192
|
-
def list_files(
|
|
193
|
-
self, dataset_rid: str, branch: str = "master"
|
|
194
|
-
) -> List[Dict[str, Any]]:
|
|
195
|
-
"""
|
|
196
|
-
List files in a dataset.
|
|
197
|
-
|
|
198
|
-
Args:
|
|
199
|
-
dataset_rid: Dataset Resource Identifier
|
|
200
|
-
branch: Dataset branch name
|
|
201
|
-
|
|
202
|
-
Returns:
|
|
203
|
-
List of file information dictionaries
|
|
204
|
-
"""
|
|
205
|
-
try:
|
|
206
|
-
files = self.service.list_files(dataset_rid=dataset_rid, branch=branch)
|
|
207
|
-
|
|
208
|
-
return [
|
|
209
|
-
{
|
|
210
|
-
"path": file.path,
|
|
211
|
-
"size_bytes": getattr(file, "size_bytes", None),
|
|
212
|
-
"last_modified": getattr(file, "last_modified", None),
|
|
213
|
-
"transaction_rid": getattr(file, "transaction_rid", None),
|
|
214
|
-
}
|
|
215
|
-
for file in files
|
|
216
|
-
]
|
|
217
|
-
except Exception as e:
|
|
218
|
-
raise RuntimeError(f"Failed to list files in dataset {dataset_rid}: {e}")
|
|
219
|
-
|
|
220
|
-
def get_branches(self, dataset_rid: str) -> List[Dict[str, Any]]:
|
|
221
|
-
"""
|
|
222
|
-
Get list of branches for a dataset.
|
|
223
|
-
|
|
224
|
-
Args:
|
|
225
|
-
dataset_rid: Dataset Resource Identifier
|
|
226
|
-
|
|
227
|
-
Returns:
|
|
228
|
-
List of branch information dictionaries
|
|
229
|
-
"""
|
|
230
|
-
try:
|
|
231
|
-
branches = self.service.list_branches(dataset_rid=dataset_rid)
|
|
232
|
-
|
|
233
|
-
return [
|
|
234
|
-
{
|
|
235
|
-
"name": branch.name,
|
|
236
|
-
"transaction_rid": getattr(branch, "transaction_rid", None),
|
|
237
|
-
"created_time": getattr(branch, "created_time", None),
|
|
238
|
-
"created_by": getattr(branch, "created_by", None),
|
|
239
|
-
}
|
|
240
|
-
for branch in branches
|
|
241
|
-
]
|
|
242
|
-
except Exception as e:
|
|
243
|
-
raise RuntimeError(f"Failed to get branches for dataset {dataset_rid}: {e}")
|
|
244
|
-
|
|
245
|
-
def create_branch(
|
|
246
|
-
self, dataset_rid: str, branch_name: str, parent_branch: str = "master"
|
|
247
|
-
) -> Dict[str, Any]:
|
|
248
|
-
"""
|
|
249
|
-
Create a new branch for a dataset.
|
|
250
|
-
|
|
251
|
-
Args:
|
|
252
|
-
dataset_rid: Dataset Resource Identifier
|
|
253
|
-
branch_name: Name for the new branch
|
|
254
|
-
parent_branch: Parent branch to branch from
|
|
255
|
-
|
|
256
|
-
Returns:
|
|
257
|
-
Created branch information
|
|
258
|
-
"""
|
|
259
|
-
try:
|
|
260
|
-
branch = self.service.create_branch(
|
|
261
|
-
dataset_rid=dataset_rid,
|
|
262
|
-
branch_name=branch_name,
|
|
263
|
-
parent_branch=parent_branch,
|
|
264
|
-
)
|
|
265
|
-
|
|
266
|
-
return {
|
|
267
|
-
"name": branch.name,
|
|
268
|
-
"dataset_rid": dataset_rid,
|
|
269
|
-
"parent_branch": parent_branch,
|
|
270
|
-
"transaction_rid": getattr(branch, "transaction_rid", None),
|
|
271
|
-
}
|
|
272
|
-
except Exception as e:
|
|
273
|
-
raise RuntimeError(
|
|
274
|
-
f"Failed to create branch '{branch_name}' for dataset {dataset_rid}: {e}"
|
|
275
|
-
)
|
|
276
|
-
|
|
277
|
-
def _format_dataset_info(self, dataset: Any) -> Dict[str, Any]:
|
|
278
|
-
"""
|
|
279
|
-
Format dataset information for consistent output.
|
|
280
|
-
|
|
281
|
-
Args:
|
|
282
|
-
dataset: Dataset object from Foundry SDK
|
|
283
|
-
|
|
284
|
-
Returns:
|
|
285
|
-
Formatted dataset information dictionary
|
|
286
|
-
"""
|
|
287
|
-
# The v2 Dataset object has different attributes
|
|
288
|
-
return {
|
|
289
|
-
"rid": getattr(dataset, "rid", "unknown"),
|
|
290
|
-
"name": getattr(dataset, "name", "Unknown"),
|
|
291
|
-
"description": getattr(dataset, "description", ""),
|
|
292
|
-
"path": getattr(dataset, "path", None),
|
|
293
|
-
"created": getattr(dataset, "created", None),
|
|
294
|
-
"modified": getattr(dataset, "modified", None),
|
|
295
|
-
# Try to get additional attributes that might exist
|
|
296
|
-
"created_time": getattr(dataset, "created_time", None),
|
|
297
|
-
"created_by": getattr(dataset, "created_by", None),
|
|
298
|
-
"last_modified": getattr(dataset, "last_modified", None),
|
|
299
|
-
"size_bytes": getattr(dataset, "size_bytes", None),
|
|
300
|
-
"schema_id": getattr(dataset, "schema_id", None),
|
|
301
|
-
"parent_folder_rid": getattr(dataset, "parent_folder_rid", None),
|
|
302
|
-
}
|
pltr/services/dataset_v2.py
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Dataset service wrapper for Foundry SDK v2 API.
|
|
3
|
-
This is a simplified version that works with the actual foundry_sdk API.
|
|
4
|
-
"""
|
|
5
|
-
|
|
6
|
-
from typing import Any, Optional, Dict
|
|
7
|
-
|
|
8
|
-
from .base import BaseService
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class DatasetServiceV2(BaseService):
|
|
12
|
-
"""Service wrapper for Foundry dataset operations using v2 API."""
|
|
13
|
-
|
|
14
|
-
def _get_service(self) -> Any:
|
|
15
|
-
"""Get the Foundry datasets service."""
|
|
16
|
-
return self.client.datasets
|
|
17
|
-
|
|
18
|
-
def get_dataset(self, dataset_rid: str) -> Dict[str, Any]:
|
|
19
|
-
"""
|
|
20
|
-
Get information about a specific dataset.
|
|
21
|
-
|
|
22
|
-
Args:
|
|
23
|
-
dataset_rid: Dataset Resource Identifier
|
|
24
|
-
|
|
25
|
-
Returns:
|
|
26
|
-
Dataset information dictionary
|
|
27
|
-
"""
|
|
28
|
-
try:
|
|
29
|
-
# The v2 API returns a Dataset object
|
|
30
|
-
dataset = self.service.Dataset.get(dataset_rid)
|
|
31
|
-
|
|
32
|
-
# Format the response
|
|
33
|
-
return {
|
|
34
|
-
"rid": dataset_rid,
|
|
35
|
-
"name": getattr(dataset, "name", "Unknown"),
|
|
36
|
-
"description": getattr(dataset, "description", ""),
|
|
37
|
-
"path": getattr(dataset, "path", ""),
|
|
38
|
-
"created": getattr(dataset, "created_time", None),
|
|
39
|
-
"modified": getattr(dataset, "modified_time", None),
|
|
40
|
-
# The actual attributes available depend on the SDK version
|
|
41
|
-
"status": "Retrieved successfully",
|
|
42
|
-
}
|
|
43
|
-
except Exception as e:
|
|
44
|
-
raise RuntimeError(f"Failed to get dataset {dataset_rid}: {e}")
|
|
45
|
-
|
|
46
|
-
def create_dataset(
|
|
47
|
-
self, name: str, parent_folder_rid: Optional[str] = None
|
|
48
|
-
) -> Dict[str, Any]:
|
|
49
|
-
"""
|
|
50
|
-
Create a new dataset.
|
|
51
|
-
|
|
52
|
-
Args:
|
|
53
|
-
name: Dataset name
|
|
54
|
-
parent_folder_rid: Parent folder RID (optional)
|
|
55
|
-
|
|
56
|
-
Returns:
|
|
57
|
-
Created dataset information
|
|
58
|
-
"""
|
|
59
|
-
try:
|
|
60
|
-
# The create method parameters depend on the SDK version
|
|
61
|
-
dataset = self.service.Dataset.create(
|
|
62
|
-
name=name, parent_folder_rid=parent_folder_rid
|
|
63
|
-
)
|
|
64
|
-
|
|
65
|
-
return {
|
|
66
|
-
"rid": getattr(dataset, "rid", "unknown"),
|
|
67
|
-
"name": name,
|
|
68
|
-
"parent_folder_rid": parent_folder_rid,
|
|
69
|
-
"status": "Created successfully",
|
|
70
|
-
}
|
|
71
|
-
except Exception as e:
|
|
72
|
-
raise RuntimeError(f"Failed to create dataset '{name}': {e}")
|
|
73
|
-
|
|
74
|
-
def read_table(self, dataset_rid: str, format: str = "arrow") -> Any:
|
|
75
|
-
"""
|
|
76
|
-
Read dataset as a table.
|
|
77
|
-
|
|
78
|
-
Args:
|
|
79
|
-
dataset_rid: Dataset Resource Identifier
|
|
80
|
-
format: Output format (arrow, pandas, etc.)
|
|
81
|
-
|
|
82
|
-
Returns:
|
|
83
|
-
Table data in specified format
|
|
84
|
-
"""
|
|
85
|
-
try:
|
|
86
|
-
return self.service.Dataset.read_table(dataset_rid, format=format)
|
|
87
|
-
except Exception as e:
|
|
88
|
-
raise RuntimeError(f"Failed to read dataset {dataset_rid}: {e}")
|
|
89
|
-
|
|
90
|
-
def get_schema(self, dataset_rid: str) -> Dict[str, Any]:
|
|
91
|
-
"""
|
|
92
|
-
Get dataset schema.
|
|
93
|
-
|
|
94
|
-
Args:
|
|
95
|
-
dataset_rid: Dataset Resource Identifier
|
|
96
|
-
|
|
97
|
-
Returns:
|
|
98
|
-
Schema information
|
|
99
|
-
"""
|
|
100
|
-
try:
|
|
101
|
-
schema = self.service.Dataset.get_schema(dataset_rid)
|
|
102
|
-
|
|
103
|
-
# Format schema for display
|
|
104
|
-
return {
|
|
105
|
-
"dataset_rid": dataset_rid,
|
|
106
|
-
"schema": schema,
|
|
107
|
-
"status": "Schema retrieved successfully",
|
|
108
|
-
}
|
|
109
|
-
except Exception as e:
|
|
110
|
-
raise RuntimeError(f"Failed to get schema for dataset {dataset_rid}: {e}")
|
|
111
|
-
|
|
112
|
-
def list_datasets(self, limit: Optional[int] = None) -> list:
|
|
113
|
-
"""
|
|
114
|
-
List datasets - NOT SUPPORTED BY SDK v2.
|
|
115
|
-
|
|
116
|
-
The foundry_sdk v2 API doesn't provide a list_datasets method.
|
|
117
|
-
Dataset operations are RID-based. You need to know the dataset RID
|
|
118
|
-
to interact with it.
|
|
119
|
-
|
|
120
|
-
Raises:
|
|
121
|
-
NotImplementedError: This operation is not supported by the SDK
|
|
122
|
-
"""
|
|
123
|
-
raise NotImplementedError(
|
|
124
|
-
"Dataset listing is not supported by foundry_sdk v2. "
|
|
125
|
-
"The SDK requires knowing dataset RIDs in advance. "
|
|
126
|
-
"Consider using the Foundry web interface to find dataset RIDs, "
|
|
127
|
-
"or contact your Foundry administrator for dataset information."
|
|
128
|
-
)
|