Skip to content

Commit 37ebaec

Browse files
Major version the FoundryClient (#15)
Co-authored-by: svc-changelog <svc-changelog@palantir.com>
1 parent 8c90b47 commit 37ebaec

File tree

4,513 files changed

+96834
-52029
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

4,513 files changed

+96834
-52029
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
**/__pycache__
22
*.pyc
3+
tmp

Makefile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
.PHONY: reset test
2+
3+
spec:
4+
@echo === Generating the spec ===
5+
@./scripts/generate_spec.sh
6+
7+
sdk:
8+
@echo === Generating the SDK ===
9+
@./scripts/generate_sdk.sh
10+
11+
test:
12+
@echo === Testing the SDK ===
13+
@python -m pytest test
14+
15+
format:
16+
@echo
17+
@echo === Formatting the Generator ===
18+
@isort foundry test --profile black --multi-line NOQA -sl --project foundry
19+
@python -m black foundry test
20+
21+
lint:
22+
@echo === Linting the SDK ===
23+
@python -m pyright foundry
24+
25+
reset:
26+
@echo === Resetting the git state ===
27+
git checkout HEAD -- .

README.md

Lines changed: 1707 additions & 910 deletions
Large diffs are not rendered by default.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
### Manipulate a Dataset within a Transaction
2+
3+
```python
4+
import foundry
5+
6+
foundry_client = foundry.FoundryV1Client(auth=foundry.UserTokenAuth(...), hostname="example.palantirfoundry.com")
7+
8+
transaction = foundry_client.datasets.Dataset.Transaction.create(
9+
dataset_rid="...",
10+
create_transaction_request={},
11+
)
12+
13+
with open("my/path/to/file.txt", 'rb') as f:
14+
foundry_client.datasets.Dataset.File.upload(
15+
body=f.read(),
16+
dataset_rid="....",
17+
file_path="...",
18+
transaction_rid=transaction.rid,
19+
)
20+
21+
foundry_client.datasets.Dataset.Transaction.commit(dataset_rid="...", transaction_rid=transaction.rid)
22+
```
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
### Read the contents of a file from a dataset (by exploration / listing)
2+
3+
```python
4+
import foundry
5+
6+
foundry_client = foundry.FoundryV1Client(auth=foundry.UserTokenAuth(...), hostname="example.palantirfoundry.com")
7+
8+
result = foundry_client.datasets.Dataset.File.list(dataset_rid="...")
9+
10+
if result.data:
11+
file_path = result.data[0].path
12+
13+
print(foundry_client.datasets.Dataset.File.read(
14+
dataset_rid="...", file_path=file_path
15+
))
16+
```
17+
18+
```
19+
b'Hello!'
20+
```
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
### Read a Foundry Dataset as a CSV
2+
3+
```python
4+
import foundry
5+
from foundry.models import TableExportFormat
6+
from foundry import PalantirRPCException
7+
8+
foundry_client = foundry.FoundryV1Client(auth=foundry.UserTokenAuth(...), hostname="example.palantirfoundry.com")
9+
10+
try:
11+
api_response = foundry_client.datasets.Dataset.read(
12+
dataset_rid="...", format="CSV", columns=[...]
13+
)
14+
15+
with open("my_table.csv", "wb") as f:
16+
f.write(api_response)
17+
except PalantirRPCException as e:
18+
print("PalantirRPCException when calling DatasetsApiServiceApi -> read: %s\n" % e)
19+
```
20+
21+
### Read a Foundry Dataset into a Pandas DataFrame
22+
23+
> [!IMPORTANT]
24+
> For this example to work, you will need to have `pyarrow` installed in your Python environment.
25+
26+
```python
27+
import foundry
28+
from foundry.models import TableExportFormat
29+
from foundry import PalantirRPCException
30+
import pyarrow as pa
31+
32+
foundry_client = foundry.FoundryV1Client(auth=foundry.UserTokenAuth(...), hostname="example.palantirfoundry.com")
33+
34+
try:
35+
api_response = foundry_client.datasets.Dataset.read(dataset_rid="...", format="ARROW", columns=[...])
36+
df = pa.ipc.open_stream(api_response).read_all().to_pandas()
37+
print(df)
38+
except Exception as e:
39+
print("Exception when calling DatasetsApiServiceApi -> read: %s\n" % e)
40+
```
41+
42+
```
43+
id word length double boolean
44+
0 0 A 1.0 11.878200 1
45+
1 1 a 1.0 11.578800 0
46+
2 2 aa 2.0 15.738500 1
47+
3 3 aal 3.0 6.643900 0
48+
4 4 aalii 5.0 2.017730 1
49+
... ... ... ... ... ...
50+
235881 235881 zythem 6.0 19.427400 1
51+
235882 235882 Zythia 6.0 14.397100 1
52+
235883 235883 zythum 6.0 3.385820 0
53+
235884 235884 Zyzomys 7.0 6.208830 1
54+
235885 235885 Zyzzogeton 10.0 0.947821 0
55+
56+
[235886 rows x 5 columns]
57+
```
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
### Manipulate a Dataset within a Transaction
2+
3+
```python
4+
import foundry
5+
6+
foundry_client = foundry.FoundryV2Client(auth=foundry.UserTokenAuth(...), hostname="example.palantirfoundry.com")
7+
8+
transaction = foundry_client.datasets.Dataset.Transaction.create(
9+
dataset_rid="...",
10+
create_transaction_request={},
11+
)
12+
13+
with open("my/path/to/file.txt", 'rb') as f:
14+
foundry_client.datasets.Dataset.File.upload(
15+
body=f.read(),
16+
dataset_rid="....",
17+
file_path="...",
18+
transaction_rid=transaction.rid,
19+
)
20+
21+
foundry_client.datasets.Dataset.Transaction.commit(dataset_rid="...", transaction_rid=transaction.rid)
22+
```

changelog/@unreleased/pr-14.v2.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
type: improvement
2+
improvement:
3+
description: Add generation scripts
4+
links:
5+
- https://github.com/palantir/foundry-platform-python/pull/14

config.json

Lines changed: 99 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -5,67 +5,105 @@
55
"userHeader": "python-foundry-platform-sdk",
66
"description": "The official Python library for the Foundry API",
77
"extraDocsDir": "assets/docs_examples",
8-
"openApiSpecPath": "tmp/specs/openapi.yml",
9-
"testsDir": "test",
8+
"openApiSpecPath": "tmp/api-definition.yml",
109
"exampleOperationName": "createBranch",
11-
"additionalRelationships": [
12-
[
13-
"Datasets",
14-
"Dataset",
15-
"Branch"
16-
],
17-
[
18-
"Datasets",
19-
"Dataset",
20-
"File"
21-
],
22-
[
23-
"Datasets",
24-
"Dataset",
25-
"Transaction"
26-
],
27-
[
28-
"Ontologies",
29-
"Ontology",
30-
"ActionType"
31-
],
32-
[
33-
"Ontologies",
34-
"Ontology",
35-
"ObjectType"
36-
],
37-
[
38-
"Ontologies",
39-
"Ontology",
40-
"QueryType"
41-
]
42-
],
43-
"namespaces": {
44-
"Datasets": true,
45-
"Admin": true,
46-
"OntologiesV2": [
47-
"listOntologiesV2",
48-
"getOntologyV2",
49-
"listActionTypesV2",
50-
"getActionTypeV2",
51-
"getOntologyFullMetadata",
52-
"listDeployments",
53-
"getDeployment",
54-
"listObjectTypesV2",
55-
"getObjectTypeV2",
56-
"listOutgoingLinkTypesV2",
57-
"getOutgoingLinkTypeV2",
58-
"listQueryTypesV2",
59-
"getQueryTypeV2"
60-
],
61-
"Orchestration": true
62-
},
63-
"namespaceRenames": {
64-
"OntologiesV2": "Ontologies"
65-
},
66-
"resourceRenames": {
67-
"OntologyV2": "Ontology",
68-
"ActionTypeV2": "ActionType",
69-
"ObjectTypeV2": "ObjectType"
10+
"majorVersionConfigs": {
11+
"v1": {
12+
"additionalRelationships": [
13+
[
14+
"Datasets",
15+
"Dataset",
16+
"Branch"
17+
],
18+
[
19+
"Datasets",
20+
"Dataset",
21+
"File"
22+
],
23+
[
24+
"Datasets",
25+
"Dataset",
26+
"Transaction"
27+
],
28+
[
29+
"Ontologies",
30+
"Ontology",
31+
"ActionType"
32+
],
33+
[
34+
"Ontologies",
35+
"Ontology",
36+
"ObjectType"
37+
],
38+
[
39+
"Ontologies",
40+
"Ontology",
41+
"QueryType"
42+
]
43+
],
44+
"namespaces": {
45+
"Datasets": true,
46+
"Ontologies": [
47+
"listOntologies",
48+
"getOntology",
49+
"listActionTypes",
50+
"getActionType",
51+
"getOntologyFullMetadata",
52+
"listObjectTypes",
53+
"getObjectType",
54+
"listOutgoingLinkTypes",
55+
"getOutgoingLinkType",
56+
"listQueryTypes",
57+
"getQueryType"
58+
]
59+
}
60+
},
61+
"v2": {
62+
"additionalRelationships": [
63+
[
64+
"Ontologies",
65+
"Ontology",
66+
"ActionType"
67+
],
68+
[
69+
"Ontologies",
70+
"Ontology",
71+
"ObjectType"
72+
],
73+
[
74+
"Ontologies",
75+
"Ontology",
76+
"QueryType"
77+
]
78+
],
79+
"namespaces": {
80+
"Datasets": true,
81+
"Admin": true,
82+
"OntologiesV2": [
83+
"listOntologiesV2",
84+
"getOntologyV2",
85+
"listActionTypesV2",
86+
"getActionTypeV2",
87+
"getOntologyFullMetadata",
88+
"listDeployments",
89+
"getDeployment",
90+
"listObjectTypesV2",
91+
"getObjectTypeV2",
92+
"listOutgoingLinkTypesV2",
93+
"getOutgoingLinkTypeV2",
94+
"listQueryTypesV2",
95+
"getQueryTypeV2"
96+
],
97+
"Orchestration": true
98+
},
99+
"namespaceRenames": {
100+
"OntologiesV2": "Ontologies"
101+
},
102+
"resourceRenames": {
103+
"OntologyV2": "Ontology",
104+
"ActionTypeV2": "ActionType",
105+
"ObjectTypeV2": "ObjectType"
106+
}
107+
}
70108
}
71109
}

docs/models/AbortOnFailure.md

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)