Skip to content

Commit 002df7a

Browse files
committed
Sync contents
1 parent 1f47eb1 commit 002df7a

File tree

151 files changed

+20961
-1
lines changed

Some content is hidden

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

151 files changed

+20961
-1
lines changed

.devcontainer/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
ARG VARIANT="3.9"
2+
FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}
3+
4+
USER vscode
5+
6+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
7+
8+
RUN echo "[[ -d .venv ]] && source .venv/bin/activate || export PATH=\$PATH" >> /home/vscode/.bashrc

.devcontainer/devcontainer.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/debian
3+
{
4+
"name": "Debian",
5+
"build": {
6+
"dockerfile": "Dockerfile",
7+
"context": ".."
8+
},
9+
10+
"postStartCommand": "uv sync --all-extras",
11+
12+
"customizations": {
13+
"vscode": {
14+
"extensions": [
15+
"ms-python.python"
16+
],
17+
"settings": {
18+
"terminal.integrated.shell.linux": "/bin/bash",
19+
"python.pythonPath": ".venv/bin/python",
20+
"python.defaultInterpreterPath": ".venv/bin/python",
21+
"python.typeChecking": "basic",
22+
"terminal.integrated.env.linux": {
23+
"PATH": "${env:PATH}"
24+
}
25+
}
26+
}
27+
},
28+
"features": {
29+
"ghcr.io/devcontainers/features/node:1": {}
30+
}
31+
32+
// Features to add to the dev container. More info: https://containers.dev/features.
33+
// "features": {},
34+
35+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
36+
// "forwardPorts": [],
37+
38+
// Configure tool-specific properties.
39+
// "customizations": {},
40+
41+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
42+
// "remoteUser": "root"
43+
}

.github/workflows/ci.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: CI
2+
on:
3+
push:
4+
branches-ignore:
5+
- 'generated'
6+
- 'codegen/**'
7+
- 'integrated/**'
8+
- 'stl-preview-head/**'
9+
- 'stl-preview-base/**'
10+
pull_request:
11+
branches-ignore:
12+
- 'stl-preview-head/**'
13+
- 'stl-preview-base/**'
14+
15+
jobs:
16+
lint:
17+
timeout-minutes: 10
18+
name: lint
19+
runs-on: ${{ github.repository == 'stainless-sdks/tinker-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
20+
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v5
26+
with:
27+
version: '0.5.23'
28+
29+
- name: Install dependencies
30+
run: uv sync --all-extras
31+
32+
- name: Run lints
33+
run: ./scripts/lint
34+
35+
build:
36+
if: github.repository == 'stainless-sdks/tinker-python' && (github.event_name == 'push' || github.event.pull_request.head.repo.fork)
37+
timeout-minutes: 10
38+
name: build
39+
permissions:
40+
contents: read
41+
id-token: write
42+
runs-on: depot-ubuntu-24.04
43+
steps:
44+
- uses: actions/checkout@v4
45+
46+
- name: Install uv
47+
uses: astral-sh/setup-uv@v5
48+
with:
49+
version: '0.5.23'
50+
51+
- name: Install dependencies
52+
run: uv sync --all-extras
53+
54+
- name: Run build
55+
run: uv build
56+
57+
- name: Get GitHub OIDC Token
58+
id: github-oidc
59+
uses: actions/github-script@v6
60+
with:
61+
script: core.setOutput('github_token', await core.getIDToken());
62+
63+
- name: Upload tarball
64+
env:
65+
URL: https://pkg.stainless.com/s
66+
AUTH: ${{ steps.github-oidc.outputs.github_token }}
67+
SHA: ${{ github.sha }}
68+
run: ./scripts/utils/upload-artifact.sh
69+
70+
test:
71+
timeout-minutes: 10
72+
name: test
73+
runs-on: ${{ github.repository == 'stainless-sdks/tinker-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
74+
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
75+
steps:
76+
- uses: actions/checkout@v4
77+
78+
- name: Install uv
79+
uses: astral-sh/setup-uv@v5
80+
with:
81+
version: '0.5.23'
82+
83+
- name: Bootstrap
84+
run: ./scripts/bootstrap
85+
86+
- name: Run tests
87+
run: ./scripts/test

.gitrepo

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
; DO NOT EDIT (unless you know what you are doing)
2+
;
3+
; This subdirectory is a git "subrepo", and this file is maintained by the
4+
; git-subrepo command. See https://github.com/ingydotnet/git-subrepo#readme
5+
;
6+
[subrepo]
7+
remote = [email protected]:stainless-sdks/tinker-python.git
8+
branch = main
9+
commit = b6e5678bc0220fde1463f8acbe122fcdb23cc8d5
10+
parent = f3a2d340a14109e8e64a6cedea1d62e744104ea6
11+
method = merge
12+
cmdver = 0.4.9

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.9.18

.ruff.toml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
line-length = 100
2+
include = ["src/tinker_public/lib/**/*.py"]
3+
exclude = []
4+
force-exclude = true
5+
6+
[lint]
7+
8+
# Same as monorepo but removed UP007
9+
select = [
10+
# https://docs.astral.sh/ruff/rules
11+
# pyflakes, pycodestyle, isort
12+
"B905", # zip-without-explicit-strict
13+
"F",
14+
"E",
15+
"W",
16+
"I001",
17+
18+
"PIE804", # unnecessary-dict-kwargs
19+
"PIE800", # unnecessary-spread
20+
"PIE796", # non-unique-enums
21+
"PIE794", # duplicate-class-field-definition
22+
"PIE807", # reimplemented-container-builtin
23+
"PIE810", #multiple-starts-ends-with
24+
25+
"FLY002",
26+
"COM818",
27+
"SIM",
28+
"Q000",
29+
30+
#"UP007", # Use X | Y for type annotations
31+
# Going to leave these 2 commented out for now as they play interestingly with chz.
32+
# We could consider using them though!
33+
# "TC001", # typing-only-first-party-import
34+
# "TC002", # typing-only-third-party-import
35+
"TC004", # runtime-import-in-type-checking-block
36+
"TC005", # empty-type-checking-block
37+
]
38+
ignore = ["E501", "SIM108", "SIM117"]
39+
unfixable = ["B905"]
40+
extend-safe-fixes = ["TC004", "TC005"]

.stats.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
configured_endpoints: 13
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/thinking-machines%2Ftinker-80db8c2a208e53eb68b2c3139b5949cc67074eb876888fe6993b2d3e1c81b3f4.yml
3+
openapi_spec_hash: 3a9c00c0cdb57024426f272bd131a83e
4+
config_hash: 0b0406fd322c4dc46bf3de5b7dbb895e

Brewfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
brew "uv"
2+

CONTRIBUTING.md

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
## Setting up the environment
2+
3+
### With `uv`
4+
5+
We use [uv](https://docs.astral.sh/uv/) to manage dependencies because it will automatically provision a Python environment with the expected Python version. To set it up, run:
6+
7+
```sh
8+
$ ./scripts/bootstrap
9+
```
10+
11+
Or [install uv manually](https://docs.astral.sh/uv/getting-started/installation/) and run:
12+
13+
```sh
14+
$ uv sync --all-extras
15+
```
16+
17+
You can then run scripts using `uv run python script.py` or by manually activating the virtual environment:
18+
19+
```sh
20+
# manually activate - https://docs.python.org/3/library/venv.html#how-venvs-work
21+
$ source .venv/bin/activate
22+
23+
# now you can omit the `uv run` prefix
24+
$ python script.py
25+
```
26+
27+
### Without `uv`
28+
29+
Alternatively if you don't want to install `uv`, you can stick with the standard `pip` setup by ensuring you have the Python version specified in `.python-version`, create a virtual environment however you desire and then install dependencies using this command:
30+
31+
```sh
32+
$ pip install -r requirements-dev.lock
33+
```
34+
35+
## Modifying/Adding code
36+
37+
Most of the SDK is generated code. Modifications to code will be persisted between generations, but may
38+
result in merge conflicts between manual patches and changes from the generator. The generator will never
39+
modify the contents of the `src/tinker_public/lib/` and `examples/` directories.
40+
41+
## Adding and running examples
42+
43+
All files in the `examples/` directory are not modified by the generator and can be freely edited or added to.
44+
45+
```py
46+
# add an example to examples/<your-example>.py
47+
48+
#!/usr/bin/env -S uv run python
49+
50+
```
51+
52+
```sh
53+
$ chmod +x examples/<your-example>.py
54+
# run the example against your api
55+
$ ./examples/<your-example>.py
56+
```
57+
58+
## Using the repository from source
59+
60+
If you’d like to use the repository from source, you can either install from git or link to a cloned repository:
61+
62+
To install via git:
63+
64+
```sh
65+
$ pip install git+ssh://[email protected]/stainless-sdks/tinker-python.git
66+
```
67+
68+
Alternatively, you can build from source and install the wheel file:
69+
70+
Building this package will create two files in the `dist/` directory, a `.tar.gz` containing the source files and a `.whl` that can be used to install the package efficiently.
71+
72+
To create a distributable version of the library, all you have to do is run this command:
73+
74+
```sh
75+
$ uv build
76+
# or
77+
$ python -m build
78+
```
79+
80+
Then to install:
81+
82+
```sh
83+
$ pip install ./path-to-wheel-file.whl
84+
```
85+
86+
## Running tests
87+
88+
Most tests require you to [set up a mock server](https://github.com/stoplightio/prism) against the OpenAPI spec to run the tests.
89+
90+
```sh
91+
# you will need npm installed
92+
$ npx prism mock path/to/your/openapi.yml
93+
```
94+
95+
```sh
96+
$ ./scripts/test
97+
```
98+
99+
## Linting and formatting
100+
101+
This repository uses [ruff](https://github.com/astral-sh/ruff) and
102+
[black](https://github.com/psf/black) to format the code in the repository.
103+
104+
To lint:
105+
106+
```sh
107+
$ ./scripts/lint
108+
```
109+
110+
To format and fix all ruff issues automatically:
111+
112+
```sh
113+
$ ./scripts/format
114+
```
115+
116+
## Publishing and releases
117+
118+
Changes made to this repository via the automated release PR pipeline should publish to PyPI automatically. If
119+
the changes aren't made through the automated pipeline, you may want to make releases manually.
120+
121+
### Publish with a GitHub workflow
122+
123+
You can release to package managers by using [the `Publish PyPI` GitHub action](https://www.github.com/stainless-sdks/tinker-python/actions/workflows/publish-pypi.yml). This requires a setup organization or repository secret to be set up.
124+
125+
### Publish manually
126+
127+
If you need to manually release a package, you can run the `bin/publish-pypi` script with a `PYPI_TOKEN` set on
128+
the environment.

0 commit comments

Comments
 (0)