pltr-cli 0.11.0__py3-none-any.whl → 0.13.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.
Files changed (46) hide show
  1. pltr/__init__.py +1 -1
  2. pltr/cli.py +40 -0
  3. pltr/commands/admin.py +565 -11
  4. pltr/commands/aip_agents.py +333 -0
  5. pltr/commands/connectivity.py +309 -1
  6. pltr/commands/cp.py +103 -0
  7. pltr/commands/dataset.py +104 -4
  8. pltr/commands/functions.py +503 -0
  9. pltr/commands/language_models.py +515 -0
  10. pltr/commands/mediasets.py +176 -0
  11. pltr/commands/models.py +362 -0
  12. pltr/commands/ontology.py +44 -13
  13. pltr/commands/orchestration.py +167 -11
  14. pltr/commands/project.py +231 -22
  15. pltr/commands/resource.py +416 -17
  16. pltr/commands/space.py +25 -303
  17. pltr/commands/sql.py +54 -7
  18. pltr/commands/streams.py +616 -0
  19. pltr/commands/third_party_applications.py +82 -0
  20. pltr/services/admin.py +331 -3
  21. pltr/services/aip_agents.py +147 -0
  22. pltr/services/base.py +104 -1
  23. pltr/services/connectivity.py +139 -0
  24. pltr/services/copy.py +391 -0
  25. pltr/services/dataset.py +77 -4
  26. pltr/services/folder.py +6 -1
  27. pltr/services/functions.py +223 -0
  28. pltr/services/language_models.py +281 -0
  29. pltr/services/mediasets.py +144 -9
  30. pltr/services/models.py +179 -0
  31. pltr/services/ontology.py +48 -1
  32. pltr/services/orchestration.py +133 -1
  33. pltr/services/project.py +213 -39
  34. pltr/services/resource.py +229 -60
  35. pltr/services/space.py +24 -175
  36. pltr/services/sql.py +44 -20
  37. pltr/services/streams.py +290 -0
  38. pltr/services/third_party_applications.py +53 -0
  39. pltr/utils/formatting.py +195 -1
  40. pltr/utils/pagination.py +325 -0
  41. {pltr_cli-0.11.0.dist-info → pltr_cli-0.13.0.dist-info}/METADATA +55 -4
  42. pltr_cli-0.13.0.dist-info/RECORD +70 -0
  43. {pltr_cli-0.11.0.dist-info → pltr_cli-0.13.0.dist-info}/WHEEL +1 -1
  44. pltr_cli-0.11.0.dist-info/RECORD +0 -55
  45. {pltr_cli-0.11.0.dist-info → pltr_cli-0.13.0.dist-info}/entry_points.txt +0 -0
  46. {pltr_cli-0.11.0.dist-info → pltr_cli-0.13.0.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,179 @@
1
+ """
2
+ Models service wrapper for Foundry SDK.
3
+ Provides access to ML model registry operations (model lifecycle, versioning, metadata).
4
+
5
+ Note: This is distinct from LanguageModels, which handles LLM chat/embeddings operations.
6
+ """
7
+
8
+ from typing import Any, Dict, Optional
9
+ from .base import BaseService
10
+
11
+
12
+ class ModelsService(BaseService):
13
+ """Service wrapper for Foundry Models operations."""
14
+
15
+ def _get_service(self) -> Any:
16
+ """Get the Foundry Models service."""
17
+ return self.client.models
18
+
19
+ # ===== Model Operations =====
20
+
21
+ def create_model(
22
+ self,
23
+ name: str,
24
+ parent_folder_rid: str,
25
+ preview: bool = False,
26
+ ) -> Dict[str, Any]:
27
+ """
28
+ Create a new ML model in the registry.
29
+
30
+ Args:
31
+ name: Model name
32
+ parent_folder_rid: Parent folder RID (e.g., ri.compass.main.folder.xxx)
33
+ preview: Enable preview mode (default: False)
34
+
35
+ Returns:
36
+ Model information dictionary containing:
37
+ - rid: Model resource identifier
38
+ - name: Model name
39
+ - parentFolderRid: Parent folder RID
40
+
41
+ Raises:
42
+ RuntimeError: If the operation fails
43
+
44
+ Example:
45
+ >>> service = ModelsService()
46
+ >>> model = service.create_model(
47
+ ... name="fraud-detector",
48
+ ... parent_folder_rid="ri.compass.main.folder.xxx"
49
+ ... )
50
+ """
51
+ try:
52
+ model = self.service.Model.create(
53
+ name=name,
54
+ parent_folder_rid=parent_folder_rid,
55
+ preview=preview,
56
+ )
57
+ return self._serialize_response(model)
58
+ except Exception as e:
59
+ raise RuntimeError(f"Failed to create model '{name}': {e}")
60
+
61
+ def get_model(
62
+ self,
63
+ model_rid: str,
64
+ preview: bool = False,
65
+ ) -> Dict[str, Any]:
66
+ """
67
+ Get information about a model.
68
+
69
+ Args:
70
+ model_rid: Model RID (e.g., ri.foundry.main.model.xxx)
71
+ preview: Enable preview mode (default: False)
72
+
73
+ Returns:
74
+ Model information dictionary
75
+
76
+ Raises:
77
+ RuntimeError: If the operation fails
78
+
79
+ Example:
80
+ >>> service = ModelsService()
81
+ >>> model = service.get_model(
82
+ ... model_rid="ri.foundry.main.model.abc123"
83
+ ... )
84
+ """
85
+ try:
86
+ model = self.service.Model.get(
87
+ model_rid=model_rid,
88
+ preview=preview,
89
+ )
90
+ return self._serialize_response(model)
91
+ except Exception as e:
92
+ raise RuntimeError(f"Failed to get model '{model_rid}': {e}")
93
+
94
+ # ===== ModelVersion Operations =====
95
+
96
+ def get_model_version(
97
+ self,
98
+ model_rid: str,
99
+ model_version_rid: str,
100
+ preview: bool = False,
101
+ ) -> Dict[str, Any]:
102
+ """
103
+ Get information about a specific model version.
104
+
105
+ Args:
106
+ model_rid: Model RID (e.g., ri.foundry.main.model.xxx)
107
+ model_version_rid: Version identifier (e.g., v1.0.0 or version RID)
108
+ preview: Enable preview mode (default: False)
109
+
110
+ Returns:
111
+ Model version information dictionary
112
+
113
+ Raises:
114
+ RuntimeError: If the operation fails
115
+
116
+ Example:
117
+ >>> service = ModelsService()
118
+ >>> version = service.get_model_version(
119
+ ... model_rid="ri.foundry.main.model.abc123",
120
+ ... model_version_rid="v1.0.0"
121
+ ... )
122
+ """
123
+ try:
124
+ version = self.service.ModelVersion.get(
125
+ model_rid=model_rid,
126
+ model_version_rid=model_version_rid,
127
+ preview=preview,
128
+ )
129
+ return self._serialize_response(version)
130
+ except Exception as e:
131
+ raise RuntimeError(
132
+ f"Failed to get model version '{model_version_rid}' for model '{model_rid}': {e}"
133
+ )
134
+
135
+ def list_model_versions(
136
+ self,
137
+ model_rid: str,
138
+ page_size: Optional[int] = None,
139
+ page_token: Optional[str] = None,
140
+ preview: bool = False,
141
+ ) -> Dict[str, Any]:
142
+ """
143
+ List all versions of a model with pagination support.
144
+
145
+ Args:
146
+ model_rid: Model RID (e.g., ri.foundry.main.model.xxx)
147
+ page_size: Maximum number of versions to return per page
148
+ page_token: Token for fetching next page of results
149
+ preview: Enable preview mode (default: False)
150
+
151
+ Returns:
152
+ Dictionary containing:
153
+ - data: List of model version information dictionaries
154
+ - nextPageToken: Token for next page (if available)
155
+
156
+ Raises:
157
+ RuntimeError: If the operation fails
158
+
159
+ Example:
160
+ >>> service = ModelsService()
161
+ >>> result = service.list_model_versions(
162
+ ... model_rid="ri.foundry.main.model.abc123",
163
+ ... page_size=50
164
+ ... )
165
+ >>> versions = result['data']
166
+ >>> next_token = result.get('nextPageToken')
167
+ """
168
+ try:
169
+ response = self.service.ModelVersion.list(
170
+ model_rid=model_rid,
171
+ page_size=page_size,
172
+ page_token=page_token,
173
+ preview=preview,
174
+ )
175
+ return self._serialize_response(response)
176
+ except Exception as e:
177
+ raise RuntimeError(
178
+ f"Failed to list model versions for model '{model_rid}': {e}"
179
+ )
pltr/services/ontology.py CHANGED
@@ -2,7 +2,10 @@
2
2
  Ontology service wrappers for Foundry SDK.
3
3
  """
4
4
 
5
- from typing import Any, Optional, Dict, List
5
+ from typing import Any, Callable, Dict, List, Optional
6
+
7
+ from ..config.settings import Settings
8
+ from ..utils.pagination import PaginationConfig, PaginationResult
6
9
  from .base import BaseService
7
10
 
8
11
 
@@ -165,6 +168,8 @@ class OntologyObjectService(BaseService):
165
168
  """
166
169
  List objects of a specific type.
167
170
 
171
+ DEPRECATED: Use list_objects_paginated() instead for better pagination support.
172
+
168
173
  Args:
169
174
  ontology_rid: Ontology Resource Identifier
170
175
  object_type: Object type API name
@@ -188,6 +193,48 @@ class OntologyObjectService(BaseService):
188
193
  except Exception as e:
189
194
  raise RuntimeError(f"Failed to list objects: {e}")
190
195
 
196
+ def list_objects_paginated(
197
+ self,
198
+ ontology_rid: str,
199
+ object_type: str,
200
+ config: PaginationConfig,
201
+ properties: Optional[List[str]] = None,
202
+ progress_callback: Optional[Callable[[int, int], None]] = None,
203
+ ) -> PaginationResult:
204
+ """
205
+ List objects with full pagination control.
206
+
207
+ Args:
208
+ ontology_rid: Ontology Resource Identifier
209
+ object_type: Object type API name
210
+ config: Pagination configuration
211
+ properties: List of properties to include
212
+ progress_callback: Optional progress callback
213
+
214
+ Returns:
215
+ PaginationResult with objects and metadata
216
+ """
217
+ try:
218
+ settings = Settings()
219
+
220
+ # Get iterator from SDK - ResourceIterator with next_page_token support
221
+ iterator = self.service.OntologyObject.list(
222
+ ontology_rid,
223
+ object_type,
224
+ page_size=config.page_size or settings.get("page_size", 20),
225
+ properties=properties,
226
+ )
227
+
228
+ # Use iterator pagination handler
229
+ result = self._paginate_iterator(iterator, config, progress_callback)
230
+
231
+ # Format objects
232
+ result.data = [self._format_object(obj) for obj in result.data]
233
+
234
+ return result
235
+ except Exception as e:
236
+ raise RuntimeError(f"Failed to list objects: {e}")
237
+
191
238
  def get_object(
192
239
  self,
193
240
  ontology_rid: str,
@@ -3,8 +3,10 @@ Orchestration service wrapper for Foundry SDK v2 API.
3
3
  Provides operations for managing builds, jobs, and schedules.
4
4
  """
5
5
 
6
- from typing import Any, Optional, Dict, List
6
+ from typing import Any, Callable, Dict, List, Optional
7
7
 
8
+ from ..config.settings import Settings
9
+ from ..utils.pagination import PaginationConfig, PaginationResult
8
10
  from .base import BaseService
9
11
 
10
12
 
@@ -134,6 +136,8 @@ class OrchestrationService(BaseService):
134
136
  """
135
137
  Search for builds.
136
138
 
139
+ DEPRECATED: Use search_builds_paginated() instead for better pagination support.
140
+
137
141
  Args:
138
142
  page_size: Number of results per page
139
143
  page_token: Token for pagination
@@ -155,6 +159,63 @@ class OrchestrationService(BaseService):
155
159
  except Exception as e:
156
160
  raise RuntimeError(f"Failed to search builds: {e}")
157
161
 
162
+ def search_builds_paginated(
163
+ self,
164
+ config: PaginationConfig,
165
+ progress_callback: Optional[Callable[[int, int], None]] = None,
166
+ **search_params,
167
+ ) -> PaginationResult:
168
+ """
169
+ Search for builds with full pagination control.
170
+
171
+ Args:
172
+ config: Pagination configuration
173
+ progress_callback: Optional progress callback
174
+ **search_params: Additional search parameters
175
+
176
+ Returns:
177
+ PaginationResult with builds and metadata
178
+ """
179
+ try:
180
+ settings = Settings()
181
+
182
+ def fetch_page(page_token: Optional[str]) -> Dict[str, Any]:
183
+ """Fetch a single page of builds."""
184
+ kwargs: Dict[str, Any] = {
185
+ "page_size": config.page_size or settings.get("page_size", 20),
186
+ }
187
+ if page_token:
188
+ kwargs["page_token"] = page_token
189
+ kwargs.update(search_params)
190
+
191
+ response = self.service.Build.search(**kwargs)
192
+ return self._format_builds_search_response(response)
193
+
194
+ return self._paginate_response(fetch_page, config, progress_callback)
195
+ except Exception as e:
196
+ raise RuntimeError(f"Failed to search builds: {e}")
197
+
198
+ def get_builds_batch(self, build_rids: List[str]) -> Dict[str, Any]:
199
+ """
200
+ Get multiple builds in batch.
201
+
202
+ Args:
203
+ build_rids: List of Build Resource Identifiers (max 100)
204
+
205
+ Returns:
206
+ Batch response with build information
207
+ """
208
+ if len(build_rids) > 100:
209
+ raise ValueError("Maximum batch size is 100 builds")
210
+
211
+ try:
212
+ # SDK expects list of {"rid": ...} objects for batch operations
213
+ body = [{"rid": rid} for rid in build_rids]
214
+ response = self.service.Build.get_batch(body)
215
+ return self._format_builds_batch_response(response)
216
+ except Exception as e:
217
+ raise RuntimeError(f"Failed to get builds batch: {e}")
218
+
158
219
  # Job operations
159
220
  def get_job(self, job_rid: str) -> Dict[str, Any]:
160
221
  """
@@ -353,6 +414,35 @@ class OrchestrationService(BaseService):
353
414
  except Exception as e:
354
415
  raise RuntimeError(f"Failed to replace schedule {schedule_rid}: {e}")
355
416
 
417
+ def get_schedule_runs(
418
+ self,
419
+ schedule_rid: str,
420
+ page_size: Optional[int] = None,
421
+ page_token: Optional[str] = None,
422
+ ) -> Dict[str, Any]:
423
+ """
424
+ Get recent execution runs for a schedule.
425
+
426
+ Args:
427
+ schedule_rid: Schedule Resource Identifier
428
+ page_size: Number of results per page
429
+ page_token: Token for pagination
430
+
431
+ Returns:
432
+ Runs list with pagination info
433
+ """
434
+ try:
435
+ kwargs: Dict[str, Any] = {"schedule_rid": schedule_rid}
436
+ if page_size is not None:
437
+ kwargs["page_size"] = page_size
438
+ if page_token is not None:
439
+ kwargs["page_token"] = page_token
440
+
441
+ response = self.service.Schedule.runs(**kwargs)
442
+ return self._format_schedule_runs_response(response)
443
+ except Exception as e:
444
+ raise RuntimeError(f"Failed to get runs for schedule {schedule_rid}: {e}")
445
+
356
446
  # Formatting methods
357
447
  def _format_build_info(self, build: Any) -> Dict[str, Any]:
358
448
  """Format build information for consistent output."""
@@ -455,3 +545,45 @@ class OrchestrationService(BaseService):
455
545
  result["jobs"].append(self._format_job_info(item.data))
456
546
 
457
547
  return result
548
+
549
+ def _format_builds_batch_response(self, response: Any) -> Dict[str, Any]:
550
+ """Format builds batch response."""
551
+ result: Dict[str, Any] = {"builds": []}
552
+
553
+ if hasattr(response, "data"):
554
+ for item in response.data:
555
+ if hasattr(item, "data"):
556
+ result["builds"].append(self._format_build_info(item.data))
557
+
558
+ return result
559
+
560
+ def _format_run_info(self, run: Any) -> Dict[str, Any]:
561
+ """Format schedule run information for consistent output."""
562
+ info = {}
563
+
564
+ for attr in [
565
+ "rid",
566
+ "schedule_rid",
567
+ "status",
568
+ "created_time",
569
+ "started_time",
570
+ "finished_time",
571
+ "build_rid",
572
+ "result",
573
+ ]:
574
+ if hasattr(run, attr):
575
+ info[attr] = getattr(run, attr)
576
+
577
+ return info
578
+
579
+ def _format_schedule_runs_response(self, response: Any) -> Dict[str, Any]:
580
+ """Format schedule runs response."""
581
+ result: Dict[str, Any] = {"runs": []}
582
+
583
+ if hasattr(response, "data"):
584
+ result["runs"] = [self._format_run_info(run) for run in response.data]
585
+
586
+ if hasattr(response, "next_page_token"):
587
+ result["next_page_token"] = response.next_page_token
588
+
589
+ return result