pltr-cli 0.3.0__py3-none-any.whl → 0.5.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pltr-cli
3
- Version: 0.3.0
3
+ Version: 0.5.0
4
4
  Summary: Command-line interface for Palantir Foundry APIs
5
5
  Project-URL: Homepage, https://github.com/anjor/pltr-cli
6
6
  Project-URL: Repository, https://github.com/anjor/pltr-cli
@@ -37,7 +37,7 @@ Description-Content-Type: text/markdown
37
37
 
38
38
  # pltr-cli
39
39
 
40
- A comprehensive command-line interface for Palantir Foundry APIs, providing 65+ commands for data analysis, ontology operations, SQL queries, and administrative tasks.
40
+ A comprehensive command-line interface for Palantir Foundry APIs, providing 80+ commands for data analysis, dataset management, ontology operations, orchestration, SQL queries, folder management, and administrative tasks.
41
41
 
42
42
  ## Overview
43
43
 
@@ -46,8 +46,11 @@ A comprehensive command-line interface for Palantir Foundry APIs, providing 65+
46
46
  ## ✨ Key Features
47
47
 
48
48
  - 🔐 **Secure Authentication**: Token and OAuth2 support with encrypted credential storage
49
- - 📊 **Dataset Operations**: Get dataset information and create new datasets (RID-based API)
49
+ - 📊 **Dataset Operations**: Complete dataset management with branches, files, transactions, and views (RID-based API)
50
+ - 📁 **Folder Management**: Create, explore, and manage Foundry filesystem structure
50
51
  - 🎯 **Comprehensive Ontology Access**: 13 commands for objects, actions, and queries
52
+ - 🏗️ **Orchestration Management**: Create, manage, and monitor builds, jobs, and schedules
53
+ - 🎬 **MediaSets Operations**: Upload, download, and manage media content with transaction support
51
54
  - 📝 **Full SQL Support**: Execute, submit, monitor, and export query results
52
55
  - 👥 **Admin Operations**: User, group, role, and organization management (16 commands)
53
56
  - 💻 **Interactive Shell**: REPL mode with tab completion and command history
@@ -109,9 +112,23 @@ pltr admin user current
109
112
  # List available ontologies
110
113
  pltr ontology list
111
114
 
115
+ # Search for builds
116
+ pltr orchestration builds search
117
+
118
+ # Create a new folder
119
+ pltr folder create "My Project"
120
+
121
+ # List root folder contents
122
+ pltr folder list ri.compass.main.folder.0
123
+
112
124
  # Execute a simple SQL query
113
125
  pltr sql execute "SELECT 1 as test"
114
126
 
127
+ # Explore dataset operations (requires dataset RID)
128
+ pltr dataset get ri.foundry.main.dataset.abc123
129
+ pltr dataset branches list ri.foundry.main.dataset.abc123
130
+ pltr dataset files list ri.foundry.main.dataset.abc123
131
+
115
132
  # Start interactive mode for exploration
116
133
  pltr shell
117
134
  ```
@@ -133,7 +150,7 @@ pltr-cli provides comprehensive documentation to help you get the most out of th
133
150
  ### 📖 User Guides
134
151
  - **[Quick Start Guide](docs/user-guide/quick-start.md)** - Get up and running in 5 minutes
135
152
  - **[Authentication Setup](docs/user-guide/authentication.md)** - Complete guide to token and OAuth2 setup
136
- - **[Command Reference](docs/user-guide/commands.md)** - Complete reference for all 65+ commands
153
+ - **[Command Reference](docs/user-guide/commands.md)** - Complete reference for all 70+ commands
137
154
  - **[Common Workflows](docs/user-guide/workflows.md)** - Real-world data analysis patterns
138
155
  - **[Troubleshooting](docs/user-guide/troubleshooting.md)** - Solutions to common issues
139
156
 
@@ -154,6 +171,16 @@ pltr sql execute "SELECT * FROM table" # Run SQL queries
154
171
  pltr ontology list # List ontologies
155
172
  pltr dataset get <rid> # Get dataset info
156
173
 
174
+ # Orchestration
175
+ pltr orchestration builds search # Search builds
176
+ pltr orchestration jobs get <job-rid> # Get job details
177
+ pltr orchestration schedules create # Create schedule
178
+
179
+ # MediaSets
180
+ pltr media-sets get <set-rid> <item-rid> # Get media item info
181
+ pltr media-sets upload <set-rid> file.jpg "/path/file.jpg" <txn-id> # Upload media
182
+ pltr media-sets download <set-rid> <item-rid> output.jpg # Download media
183
+
157
184
  # Administrative
158
185
  pltr admin user current # Current user info
159
186
  pltr admin user list # List users
@@ -167,6 +194,113 @@ pltr completion install # Enable tab completion
167
194
 
168
195
  For the complete command reference with examples, see **[Command Reference](docs/user-guide/commands.md)**.
169
196
 
197
+ ### 🏗️ Orchestration Commands
198
+
199
+ pltr-cli provides comprehensive support for Foundry's Orchestration module:
200
+
201
+ #### Build Management
202
+ ```bash
203
+ # Search for builds
204
+ pltr orchestration builds search
205
+
206
+ # Get build details
207
+ pltr orchestration builds get ri.orchestration.main.build.12345
208
+
209
+ # Create a new build
210
+ pltr orchestration builds create '{"dataset_rid": "ri.foundry.main.dataset.abc"}' --branch main
211
+
212
+ # Cancel a running build
213
+ pltr orchestration builds cancel ri.orchestration.main.build.12345
214
+
215
+ # List jobs in a build
216
+ pltr orchestration builds jobs ri.orchestration.main.build.12345
217
+ ```
218
+
219
+ #### Job Management
220
+ ```bash
221
+ # Get job details
222
+ pltr orchestration jobs get ri.orchestration.main.job.12345
223
+
224
+ # Get multiple jobs in batch
225
+ pltr orchestration jobs get-batch "rid1,rid2,rid3"
226
+ ```
227
+
228
+ #### Schedule Management
229
+ ```bash
230
+ # Get schedule information
231
+ pltr orchestration schedules get ri.orchestration.main.schedule.12345
232
+
233
+ # Create a new schedule
234
+ pltr orchestration schedules create '{"type": "BUILD", "target": "dataset-rid"}' \
235
+ --name "Daily Build" --description "Automated daily build"
236
+
237
+ # Pause/unpause schedules
238
+ pltr orchestration schedules pause ri.orchestration.main.schedule.12345
239
+ pltr orchestration schedules unpause ri.orchestration.main.schedule.12345
240
+
241
+ # Execute schedule immediately
242
+ pltr orchestration schedules run ri.orchestration.main.schedule.12345
243
+
244
+ # Delete a schedule
245
+ pltr orchestration schedules delete ri.orchestration.main.schedule.12345 --yes
246
+ ```
247
+
248
+ **All orchestration commands support:**
249
+ - Multiple output formats (table, JSON, CSV)
250
+ - File output (`--output filename`)
251
+ - Profile selection (`--profile production`)
252
+ - Preview mode for schedules (`--preview`)
253
+
254
+ ### 🎬 MediaSets Commands
255
+
256
+ pltr-cli provides full support for Foundry's MediaSets module for managing media content:
257
+
258
+ #### Media Item Operations
259
+ ```bash
260
+ # Get media item information
261
+ pltr media-sets get ri.mediasets.main.media-set.abc ri.mediasets.main.media-item.123
262
+
263
+ # Get media item RID by path
264
+ pltr media-sets get-by-path ri.mediasets.main.media-set.abc "/images/photo.jpg"
265
+
266
+ # Get a reference for embedding
267
+ pltr media-sets reference ri.mediasets.main.media-set.abc ri.mediasets.main.media-item.123
268
+ ```
269
+
270
+ #### Transaction Management
271
+ ```bash
272
+ # Create a new upload transaction
273
+ pltr media-sets create ri.mediasets.main.media-set.abc --branch main
274
+
275
+ # Commit transaction (makes uploads available)
276
+ pltr media-sets commit ri.mediasets.main.media-set.abc transaction-id-12345
277
+
278
+ # Abort transaction (deletes uploads)
279
+ pltr media-sets abort ri.mediasets.main.media-set.abc transaction-id-12345 --yes
280
+ ```
281
+
282
+ #### Upload and Download
283
+ ```bash
284
+ # Upload a file to media set
285
+ pltr media-sets upload ri.mediasets.main.media-set.abc \
286
+ /local/path/image.jpg "/media/images/image.jpg" transaction-id-12345
287
+
288
+ # Download media item (processed version)
289
+ pltr media-sets download ri.mediasets.main.media-set.abc \
290
+ ri.mediasets.main.media-item.123 /local/download/image.jpg
291
+
292
+ # Download original version
293
+ pltr media-sets download ri.mediasets.main.media-set.abc \
294
+ ri.mediasets.main.media-item.123 /local/download/original.jpg --original
295
+ ```
296
+
297
+ **All MediaSets commands support:**
298
+ - Multiple output formats (table, JSON, CSV)
299
+ - File output (`--output filename`)
300
+ - Profile selection (`--profile production`)
301
+ - Preview mode (`--preview`)
302
+ - Transaction-based upload workflow
303
+
170
304
  ## ⚙️ Configuration
171
305
 
172
306
  pltr-cli stores configuration securely using industry best practices:
@@ -237,7 +371,7 @@ See **[API Wrapper Documentation](docs/api/wrapper.md)** for detailed architectu
237
371
 
238
372
  pltr-cli is **production-ready** with comprehensive features:
239
373
 
240
- - ✅ **65+ Commands** across 8 command groups
374
+ - ✅ **80+ Commands** across 10 command groups
241
375
  - ✅ **273 Unit Tests** with 67% code coverage
242
376
  - ✅ **Published on PyPI** with automated releases
243
377
  - ✅ **Cross-Platform** support (Windows, macOS, Linux)
@@ -1,6 +1,6 @@
1
1
  pltr/__init__.py,sha256=kUR5RAFc7HCeiqdlX36dZOHkUI5wI6V_43RpEcD8b-0,22
2
2
  pltr/__main__.py,sha256=HWJ49UoAYBQCf8kjuySPmBTuUjTZrOx-y6PzMTyS1KE,879
3
- pltr/cli.py,sha256=Kb9237LDITTX1VU-X-O5eKn8dXKI0R28HokYXGGklNU,1879
3
+ pltr/cli.py,sha256=EIW67XC8-AttN6S2OUxaxEC2trYDxaHVy8j18G92EzU,2191
4
4
  pltr/auth/__init__.py,sha256=G0V-Rh25FaJsH2nhrf146XQQG_ApdbyPJNuHJC25kgk,38
5
5
  pltr/auth/base.py,sha256=LvmCwS7A0q0CITcym8udPzdACL52_jSGusiaeCTOaE8,981
6
6
  pltr/auth/manager.py,sha256=ZqlGefr1a8MGx0g7kkQhpmiuVp0XTg3f43yMBCk-IRo,4305
@@ -12,8 +12,11 @@ pltr/commands/admin.py,sha256=foscSO-QuH6uggUR5Rmv9pTqGjEXTUzpmMFj2-8hEJs,17065
12
12
  pltr/commands/alias.py,sha256=r9xMsQNrGvaixSlspzoO2IXQ44LFXuZM4itt8vC0dRc,6862
13
13
  pltr/commands/completion.py,sha256=YTxaRL4-rDs5n7aXf3ogFsxbHVJUBo_HiBbd0fbBPZ0,10870
14
14
  pltr/commands/configure.py,sha256=oYj-VlOEj3MDwtB2RC4bYOYzI_sXTanPnz7y1GmMTqY,4800
15
- pltr/commands/dataset.py,sha256=BCYfaBpLji5wasOiH_jOqO-JC9ScfJhodox9kl9W2Cw,3609
15
+ pltr/commands/dataset.py,sha256=3QWqClosXna7cpUxOQ93mNIYTAoHMReeePCdzY44lEk,14112
16
+ pltr/commands/folder.py,sha256=IAPPA3Smk1IWqThneEtZ08Zp79vDKVUabSkL_nDvUWk,10679
17
+ pltr/commands/mediasets.py,sha256=FXq7OtYU9wLgUxQFcS_fkA4i_CozGnsYKxh8GOSI0ok,15342
16
18
  pltr/commands/ontology.py,sha256=zUgSrmv8xi26SQK7GsM3qusgR9Wuka0GyzE7L8DkduE,18317
19
+ pltr/commands/orchestration.py,sha256=4gq5nb43bU0Ub3iaKV-EgXT_ka8ilwdyxY_9M5iS84s,21958
17
20
  pltr/commands/shell.py,sha256=QLF7TEGpaau9i0A9s3VjnegvtHde-SLRqI4suJFT4WI,3622
18
21
  pltr/commands/sql.py,sha256=wol0Rlvi_RplCFbOg4LCa3VXsOqmRZdFFVv7V6iVkh8,12602
19
22
  pltr/commands/verify.py,sha256=n8LWhbfGieYa-a5_l3MxqkYbdpyVf8-i0FQIL__AaPA,6650
@@ -24,18 +27,19 @@ pltr/config/settings.py,sha256=bfIiosPqH_W73TOHS71DvgZdAHka4fJDopU1SvBRFuQ,2908
24
27
  pltr/services/__init__.py,sha256=zQpgrqPdAkZI-nobi33mctU2-iGNgazzvjBVY8YRbSQ,101
25
28
  pltr/services/admin.py,sha256=8FjExmDeIKeVqkAxM83SVvpp_pH9W-Q33cgVs6BHxLQ,9957
26
29
  pltr/services/base.py,sha256=R2G781FI-sXtjUyLd91bVnmLb4cYZI3G8U5ndR9NLA4,1593
27
- pltr/services/dataset.py,sha256=W3zoh-9YIJ6HBsDijejVEngKvpudFoZinYtHDmAXCOc,2785
28
- pltr/services/dataset_full.py,sha256=FyMiwOSyX1cUrYXaK0T_1iq5G_X0e5iZTibJHuEmMeE,9869
29
- pltr/services/dataset_v2.py,sha256=_uhcVJ91w_Y07glceqHceccAwPWr6q1TWSIqcP1FU8I,4259
30
+ pltr/services/dataset.py,sha256=cjl3aUhFcmWz_4ED8_h-Fl4Ym8ZMuA0dolOh89M7ufc,15412
31
+ pltr/services/folder.py,sha256=mWElyvn-wXPB5sv8Ik_dLeW5JM6jZg3g9KKBk6UcrlQ,5389
32
+ pltr/services/mediasets.py,sha256=HgHNFWoG9r-5xupANVOxHg_h5EKsBDl6PsO8hwdbm28,9854
30
33
  pltr/services/ontology.py,sha256=iW7qRK8ptlw-u4eAwLNC-mdzLoLZzh7SRqJyok2c3GU,14883
34
+ pltr/services/orchestration.py,sha256=t5RNC0BoKcqeYKJQ5AQAyyO_dIYCHxiHV177JVSszhM,14729
31
35
  pltr/services/sql.py,sha256=19cscjlzN8WE1s8_ctiRcrOvMzCfmWRj49vjJ8Gs5Q4,11286
32
36
  pltr/utils/__init__.py,sha256=DF7TigL1XbKVGM5VjgU8_8AGIszofkdO80oCzLGGnTE,38
33
37
  pltr/utils/alias_resolver.py,sha256=DIF7P1UnUU8kqocJfIDEWjYq4s8_0KfqRZBbECeZEh8,1539
34
38
  pltr/utils/completion.py,sha256=bjeqjleEfB2YcQFpcxvF0GoQ763F6KBbULSZC4FWY_g,4980
35
- pltr/utils/formatting.py,sha256=Ptv7obiB7uWNf5YTiY4rUAKmabO5UGnwLocSfLplrZ0,18552
39
+ pltr/utils/formatting.py,sha256=uI8pkcWsO15kSH3xiOU9WxHCVfiWADEi-W1ldiXsCRY,40383
36
40
  pltr/utils/progress.py,sha256=BKYbiLO61uhQbibabU7pxvvbAWMRLRmqk4pZldBQK_g,9053
37
- pltr_cli-0.3.0.dist-info/METADATA,sha256=BVT_zd9ZrK811JeMXPR_IX1S3-ahE3lhk6q2QiNdbFA,8864
38
- pltr_cli-0.3.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
39
- pltr_cli-0.3.0.dist-info/entry_points.txt,sha256=8tvEcW04kA_oAE2Dwwu-Og9efjl4ESJvs4AzlP2KBdQ,38
40
- pltr_cli-0.3.0.dist-info/licenses/LICENSE,sha256=6VUFd_ytnOBD2O1tmkKrA-smigi9QEhYr_tge4h4z8Y,1070
41
- pltr_cli-0.3.0.dist-info/RECORD,,
41
+ pltr_cli-0.5.0.dist-info/METADATA,sha256=TNVMhHGMRkuRcWfds_6y4B9h6vDSkBRMr9Gt-IeYvks,13356
42
+ pltr_cli-0.5.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
43
+ pltr_cli-0.5.0.dist-info/entry_points.txt,sha256=8tvEcW04kA_oAE2Dwwu-Og9efjl4ESJvs4AzlP2KBdQ,38
44
+ pltr_cli-0.5.0.dist-info/licenses/LICENSE,sha256=6VUFd_ytnOBD2O1tmkKrA-smigi9QEhYr_tge4h4z8Y,1070
45
+ pltr_cli-0.5.0.dist-info/RECORD,,
@@ -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
- }
@@ -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
- )