pltr-cli 0.8.0__py3-none-any.whl → 0.9.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/commands/dataset.py +55 -2
- pltr/services/base.py +68 -1
- pltr/services/dataset.py +55 -0
- {pltr_cli-0.8.0.dist-info → pltr_cli-0.9.1.dist-info}/METADATA +1 -1
- {pltr_cli-0.8.0.dist-info → pltr_cli-0.9.1.dist-info}/RECORD +9 -9
- {pltr_cli-0.8.0.dist-info → pltr_cli-0.9.1.dist-info}/WHEEL +0 -0
- {pltr_cli-0.8.0.dist-info → pltr_cli-0.9.1.dist-info}/entry_points.txt +0 -0
- {pltr_cli-0.8.0.dist-info → pltr_cli-0.9.1.dist-info}/licenses/LICENSE +0 -0
pltr/__init__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.
|
|
1
|
+
__version__ = "0.9.1"
|
pltr/commands/dataset.py
CHANGED
|
@@ -93,11 +93,17 @@ def get_schema(
|
|
|
93
93
|
None, "--output", "-o", help="Output file path"
|
|
94
94
|
),
|
|
95
95
|
):
|
|
96
|
-
"""Get the schema of a dataset."""
|
|
96
|
+
"""Get the schema of a dataset (requires API preview access)."""
|
|
97
97
|
try:
|
|
98
98
|
cache_rid(dataset_rid)
|
|
99
99
|
service = DatasetService(profile=profile)
|
|
100
100
|
|
|
101
|
+
formatter.print_warning(
|
|
102
|
+
"Note: This command requires API preview access. "
|
|
103
|
+
"If you encounter an 'ApiFeaturePreviewUsageOnly' error, "
|
|
104
|
+
"use 'pltr dataset schema apply' instead to infer/apply schema."
|
|
105
|
+
)
|
|
106
|
+
|
|
101
107
|
with SpinnerProgressTracker().track_spinner(
|
|
102
108
|
f"Fetching schema for {dataset_rid}..."
|
|
103
109
|
):
|
|
@@ -120,7 +126,54 @@ def get_schema(
|
|
|
120
126
|
formatter.print_error(f"Authentication error: {e}")
|
|
121
127
|
raise typer.Exit(1)
|
|
122
128
|
except Exception as e:
|
|
123
|
-
|
|
129
|
+
if "ApiFeaturePreviewUsageOnly" in str(e):
|
|
130
|
+
formatter.print_error(
|
|
131
|
+
"This command requires API preview access. "
|
|
132
|
+
"Please use 'pltr dataset schema apply' instead."
|
|
133
|
+
)
|
|
134
|
+
else:
|
|
135
|
+
formatter.print_error(f"Failed to get schema: {e}")
|
|
136
|
+
raise typer.Exit(1)
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
@schema_app.command("apply")
|
|
140
|
+
def apply_schema(
|
|
141
|
+
dataset_rid: str = typer.Argument(
|
|
142
|
+
..., help="Dataset Resource Identifier", autocompletion=complete_rid
|
|
143
|
+
),
|
|
144
|
+
branch: str = typer.Option("master", "--branch", "-b", help="Dataset branch name"),
|
|
145
|
+
profile: Optional[str] = typer.Option(
|
|
146
|
+
None, "--profile", "-p", help="Profile name", autocompletion=complete_profile
|
|
147
|
+
),
|
|
148
|
+
format: str = typer.Option(
|
|
149
|
+
"table",
|
|
150
|
+
"--format",
|
|
151
|
+
"-f",
|
|
152
|
+
help="Output format (table, json, csv)",
|
|
153
|
+
autocompletion=complete_output_format,
|
|
154
|
+
),
|
|
155
|
+
):
|
|
156
|
+
"""Apply/infer schema for a dataset."""
|
|
157
|
+
try:
|
|
158
|
+
cache_rid(dataset_rid)
|
|
159
|
+
service = DatasetService(profile=profile)
|
|
160
|
+
|
|
161
|
+
with SpinnerProgressTracker().track_spinner(
|
|
162
|
+
f"Applying schema to dataset {dataset_rid} on branch '{branch}'..."
|
|
163
|
+
):
|
|
164
|
+
result = service.apply_schema(dataset_rid, branch)
|
|
165
|
+
|
|
166
|
+
formatter.print_success(f"Schema applied successfully to branch '{branch}'")
|
|
167
|
+
|
|
168
|
+
# Display result if available
|
|
169
|
+
if result.get("result"):
|
|
170
|
+
formatter._format_json(result.get("result"))
|
|
171
|
+
|
|
172
|
+
except (ProfileNotFoundError, MissingCredentialsError) as e:
|
|
173
|
+
formatter.print_error(f"Authentication error: {e}")
|
|
174
|
+
raise typer.Exit(1)
|
|
175
|
+
except Exception as e:
|
|
176
|
+
formatter.print_error(f"Failed to apply schema: {e}")
|
|
124
177
|
raise typer.Exit(1)
|
|
125
178
|
|
|
126
179
|
|
pltr/services/base.py
CHANGED
|
@@ -2,10 +2,13 @@
|
|
|
2
2
|
Base service class for Foundry API wrappers.
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
-
from typing import Any, Optional
|
|
5
|
+
from typing import Any, Optional, Dict
|
|
6
6
|
from abc import ABC, abstractmethod
|
|
7
|
+
import requests
|
|
7
8
|
|
|
8
9
|
from ..auth.manager import AuthManager
|
|
10
|
+
from ..auth.storage import CredentialStorage
|
|
11
|
+
from ..config.profiles import ProfileManager
|
|
9
12
|
|
|
10
13
|
|
|
11
14
|
class BaseService(ABC):
|
|
@@ -60,3 +63,67 @@ class BaseService(ABC):
|
|
|
60
63
|
Configured service instance
|
|
61
64
|
"""
|
|
62
65
|
return self._get_service()
|
|
66
|
+
|
|
67
|
+
def _make_request(
|
|
68
|
+
self,
|
|
69
|
+
method: str,
|
|
70
|
+
endpoint: str,
|
|
71
|
+
data: Optional[Dict] = None,
|
|
72
|
+
json_data: Optional[Dict] = None,
|
|
73
|
+
headers: Optional[Dict] = None,
|
|
74
|
+
) -> requests.Response:
|
|
75
|
+
"""
|
|
76
|
+
Make a direct HTTP request to Foundry API.
|
|
77
|
+
|
|
78
|
+
Args:
|
|
79
|
+
method: HTTP method (GET, POST, PUT, DELETE)
|
|
80
|
+
endpoint: API endpoint path (e.g., '/foundry-schema-inference/api/...')
|
|
81
|
+
data: Form data to send
|
|
82
|
+
json_data: JSON data to send
|
|
83
|
+
headers: Additional headers
|
|
84
|
+
|
|
85
|
+
Returns:
|
|
86
|
+
Response object
|
|
87
|
+
|
|
88
|
+
Raises:
|
|
89
|
+
requests.HTTPError: If request fails
|
|
90
|
+
"""
|
|
91
|
+
# Get credentials for authentication
|
|
92
|
+
storage = CredentialStorage()
|
|
93
|
+
profile_manager = ProfileManager()
|
|
94
|
+
profile_name = self.profile or profile_manager.get_active_profile()
|
|
95
|
+
if not profile_name:
|
|
96
|
+
from ..auth.base import ProfileNotFoundError
|
|
97
|
+
|
|
98
|
+
raise ProfileNotFoundError(
|
|
99
|
+
"No profile specified and no default profile configured. "
|
|
100
|
+
"Run 'pltr configure configure' to set up authentication."
|
|
101
|
+
)
|
|
102
|
+
credentials = storage.get_profile(profile_name)
|
|
103
|
+
|
|
104
|
+
# Build full URL
|
|
105
|
+
host = credentials.get("host", "").rstrip("/")
|
|
106
|
+
url = f"{host}{endpoint}"
|
|
107
|
+
|
|
108
|
+
# Set up headers with authentication
|
|
109
|
+
request_headers = {
|
|
110
|
+
"Authorization": f"Bearer {credentials.get('token')}",
|
|
111
|
+
"Content-Type": "application/json",
|
|
112
|
+
"Accept": "application/json",
|
|
113
|
+
}
|
|
114
|
+
if headers:
|
|
115
|
+
request_headers.update(headers)
|
|
116
|
+
|
|
117
|
+
# Make the request
|
|
118
|
+
response = requests.request(
|
|
119
|
+
method=method,
|
|
120
|
+
url=url,
|
|
121
|
+
data=data,
|
|
122
|
+
json=json_data,
|
|
123
|
+
headers=request_headers,
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
# Raise an error for bad status codes
|
|
127
|
+
response.raise_for_status()
|
|
128
|
+
|
|
129
|
+
return response
|
pltr/services/dataset.py
CHANGED
|
@@ -56,6 +56,61 @@ class DatasetService(BaseService):
|
|
|
56
56
|
except Exception as e:
|
|
57
57
|
raise RuntimeError(f"Failed to get schema for dataset {dataset_rid}: {e}")
|
|
58
58
|
|
|
59
|
+
def apply_schema(self, dataset_rid: str, branch: str = "master") -> Dict[str, Any]:
|
|
60
|
+
"""
|
|
61
|
+
Apply/infer schema for a dataset using both schema inference and metadata APIs.
|
|
62
|
+
|
|
63
|
+
This method performs two sequential API calls:
|
|
64
|
+
1. Schema inference to infer the dataset schema
|
|
65
|
+
2. Schema application to apply the inferred schema to the dataset
|
|
66
|
+
|
|
67
|
+
Args:
|
|
68
|
+
dataset_rid: Dataset Resource Identifier
|
|
69
|
+
branch: Dataset branch name (default: "master")
|
|
70
|
+
|
|
71
|
+
Returns:
|
|
72
|
+
Schema application result including transaction and version information
|
|
73
|
+
"""
|
|
74
|
+
try:
|
|
75
|
+
# Step 1: Call schema inference API to infer the schema
|
|
76
|
+
inference_endpoint = f"/foundry-schema-inference/api/datasets/{dataset_rid}/branches/{branch}/schema"
|
|
77
|
+
inference_response = self._make_request(
|
|
78
|
+
"POST", inference_endpoint, json_data={}
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
# Parse the inference response
|
|
82
|
+
inference_result = (
|
|
83
|
+
inference_response.json() if inference_response.text else {}
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
# Extract the foundry schema from the inference result
|
|
87
|
+
foundry_schema = inference_result.get("data", {}).get("foundrySchema")
|
|
88
|
+
if not foundry_schema:
|
|
89
|
+
raise RuntimeError(
|
|
90
|
+
"Schema inference failed: No foundrySchema found in response"
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
# Step 2: Call foundry-metadata API to apply the schema
|
|
94
|
+
metadata_endpoint = f"/foundry-metadata/api/schemas/datasets/{dataset_rid}/branches/{branch}"
|
|
95
|
+
metadata_response = self._make_request(
|
|
96
|
+
"POST", metadata_endpoint, json_data=foundry_schema
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
# Parse the metadata response
|
|
100
|
+
metadata_result = metadata_response.json() if metadata_response.text else {}
|
|
101
|
+
|
|
102
|
+
return {
|
|
103
|
+
"dataset_rid": dataset_rid,
|
|
104
|
+
"branch": branch,
|
|
105
|
+
"status": "Schema applied successfully",
|
|
106
|
+
"inference_result": inference_result,
|
|
107
|
+
"application_result": metadata_result,
|
|
108
|
+
"transaction_rid": metadata_result.get("transactionRid"),
|
|
109
|
+
"version_id": metadata_result.get("versionId"),
|
|
110
|
+
}
|
|
111
|
+
except Exception as e:
|
|
112
|
+
raise RuntimeError(f"Failed to apply schema for dataset {dataset_rid}: {e}")
|
|
113
|
+
|
|
59
114
|
def put_schema(
|
|
60
115
|
self,
|
|
61
116
|
dataset_rid: str,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
pltr/__init__.py,sha256=
|
|
1
|
+
pltr/__init__.py,sha256=UwJXM8JY2T3tE2id0K2k_lEaVThbRTrGO1mNibyzIz8,22
|
|
2
2
|
pltr/__main__.py,sha256=HWJ49UoAYBQCf8kjuySPmBTuUjTZrOx-y6PzMTyS1KE,879
|
|
3
3
|
pltr/cli.py,sha256=DikRsWsU7QWvRWHgB6wZIct916ebWyaub7PlAjKJXws,2664
|
|
4
4
|
pltr/auth/__init__.py,sha256=G0V-Rh25FaJsH2nhrf146XQQG_ApdbyPJNuHJC25kgk,38
|
|
@@ -13,7 +13,7 @@ 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
15
|
pltr/commands/connectivity.py,sha256=m8_BYwHij_5IbrYFTU_SYYtbqLCjxA8VIQpbdlWJqHs,14758
|
|
16
|
-
pltr/commands/dataset.py,sha256=
|
|
16
|
+
pltr/commands/dataset.py,sha256=zuYtBXAGcfRjxE7cP9Hsz2tqSlsdNzdIflGKwytHbVI,53346
|
|
17
17
|
pltr/commands/folder.py,sha256=IAPPA3Smk1IWqThneEtZ08Zp79vDKVUabSkL_nDvUWk,10679
|
|
18
18
|
pltr/commands/mediasets.py,sha256=FXq7OtYU9wLgUxQFcS_fkA4i_CozGnsYKxh8GOSI0ok,15342
|
|
19
19
|
pltr/commands/ontology.py,sha256=zUgSrmv8xi26SQK7GsM3qusgR9Wuka0GyzE7L8DkduE,18317
|
|
@@ -31,9 +31,9 @@ pltr/config/profiles.py,sha256=XMUIp6Ez5LNC6rGXZe2JLH7IKepXhARtuc8ASUA9FYA,3431
|
|
|
31
31
|
pltr/config/settings.py,sha256=bfIiosPqH_W73TOHS71DvgZdAHka4fJDopU1SvBRFuQ,2908
|
|
32
32
|
pltr/services/__init__.py,sha256=zQpgrqPdAkZI-nobi33mctU2-iGNgazzvjBVY8YRbSQ,101
|
|
33
33
|
pltr/services/admin.py,sha256=8FjExmDeIKeVqkAxM83SVvpp_pH9W-Q33cgVs6BHxLQ,9957
|
|
34
|
-
pltr/services/base.py,sha256=
|
|
34
|
+
pltr/services/base.py,sha256=JF9cyYf7njZuj1ldOLdgzIDhJjOfazBvXPNR-gKVnMY,3682
|
|
35
35
|
pltr/services/connectivity.py,sha256=34kazXhue5gNi1_2s2R5Ma4VQe6jP25CO-ztiPhCeZw,10548
|
|
36
|
-
pltr/services/dataset.py,sha256=
|
|
36
|
+
pltr/services/dataset.py,sha256=LFoK8otJ_MYqH0x5rcmNyIi5X0zr_Q8KP-zG9reArPA,45027
|
|
37
37
|
pltr/services/folder.py,sha256=mWElyvn-wXPB5sv8Ik_dLeW5JM6jZg3g9KKBk6UcrlQ,5389
|
|
38
38
|
pltr/services/mediasets.py,sha256=HgHNFWoG9r-5xupANVOxHg_h5EKsBDl6PsO8hwdbm28,9854
|
|
39
39
|
pltr/services/ontology.py,sha256=iW7qRK8ptlw-u4eAwLNC-mdzLoLZzh7SRqJyok2c3GU,14883
|
|
@@ -48,8 +48,8 @@ pltr/utils/alias_resolver.py,sha256=DIF7P1UnUU8kqocJfIDEWjYq4s8_0KfqRZBbECeZEh8,
|
|
|
48
48
|
pltr/utils/completion.py,sha256=bjeqjleEfB2YcQFpcxvF0GoQ763F6KBbULSZC4FWY_g,4980
|
|
49
49
|
pltr/utils/formatting.py,sha256=38g3G2T5WUFKCCKo42NIBR8_Rdl4pp0ytCEZURoV3l4,50275
|
|
50
50
|
pltr/utils/progress.py,sha256=BKYbiLO61uhQbibabU7pxvvbAWMRLRmqk4pZldBQK_g,9053
|
|
51
|
-
pltr_cli-0.
|
|
52
|
-
pltr_cli-0.
|
|
53
|
-
pltr_cli-0.
|
|
54
|
-
pltr_cli-0.
|
|
55
|
-
pltr_cli-0.
|
|
51
|
+
pltr_cli-0.9.1.dist-info/METADATA,sha256=xxIsV9YwPwzv799EzrHcDAqM44xCBmnHREtfy6E-0ek,17714
|
|
52
|
+
pltr_cli-0.9.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
53
|
+
pltr_cli-0.9.1.dist-info/entry_points.txt,sha256=8tvEcW04kA_oAE2Dwwu-Og9efjl4ESJvs4AzlP2KBdQ,38
|
|
54
|
+
pltr_cli-0.9.1.dist-info/licenses/LICENSE,sha256=6VUFd_ytnOBD2O1tmkKrA-smigi9QEhYr_tge4h4z8Y,1070
|
|
55
|
+
pltr_cli-0.9.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|