Skip to content

Commit 5315501

Browse files
committed
Initial
0 parents  commit 5315501

Some content is hidden

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

42 files changed

+8703
-0
lines changed

.github/workflows/ci.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ["3.9", "3.10", "3.11", "3.12"]
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install -e .[test]
28+
pip install pytest-cov
29+
30+
- name: Run tests with coverage
31+
run: |
32+
pytest tests/ --cov=foxnose_sdk --cov-report=xml --cov-report=term-missing
33+
34+
- name: Upload coverage to Codecov
35+
if: matrix.python-version == '3.11'
36+
uses: codecov/codecov-action@v4
37+
with:
38+
token: ${{ secrets.CODECOV_TOKEN }}
39+
files: ./coverage.xml
40+
fail_ci_if_error: false
41+
42+
lint:
43+
runs-on: ubuntu-latest
44+
steps:
45+
- uses: actions/checkout@v4
46+
47+
- name: Set up Python
48+
uses: actions/setup-python@v5
49+
with:
50+
python-version: "3.11"
51+
52+
- name: Install ruff
53+
run: pip install ruff
54+
55+
- name: Run ruff check
56+
run: ruff check src/
57+
58+
- name: Run ruff format check
59+
run: ruff format --check src/

.github/workflows/publish.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
publish:
9+
runs-on: ubuntu-latest
10+
environment: release
11+
permissions:
12+
id-token: write # For trusted publishing (optional)
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: "3.11"
21+
22+
- name: Install build dependencies
23+
run: pip install build
24+
25+
- name: Build package
26+
run: python -m build
27+
28+
- name: Publish to PyPI
29+
uses: pypa/gh-action-pypi-publish@release/v1
30+
with:
31+
password: ${{ secrets.PYPI_API_TOKEN }}

.gitignore

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
*.egg-info/
24+
.installed.cfg
25+
*.egg
26+
27+
# PyInstaller
28+
*.manifest
29+
*.spec
30+
31+
# Installer logs
32+
pip-log.txt
33+
pip-delete-this-directory.txt
34+
35+
# Unit test / coverage reports
36+
htmlcov/
37+
.tox/
38+
.nox/
39+
.coverage
40+
.coverage.*
41+
.cache
42+
nosetests.xml
43+
coverage.xml
44+
*.cover
45+
*.py,cover
46+
.hypothesis/
47+
.pytest_cache/
48+
49+
# Translations
50+
*.mo
51+
*.pot
52+
53+
# Environments
54+
.env
55+
.venv
56+
env/
57+
venv/
58+
ENV/
59+
env.bak/
60+
venv.bak/
61+
62+
# IDEs
63+
.idea/
64+
.vscode/
65+
*.swp
66+
*.swo
67+
*~
68+
69+
# Jupyter Notebook
70+
.ipynb_checkpoints
71+
72+
# pyenv
73+
.python-version
74+
75+
# mypy
76+
.mypy_cache/
77+
.dmypy.json
78+
dmypy.json
79+
80+
# ruff
81+
.ruff_cache/
82+
83+
# MkDocs
84+
site/
85+
86+
# OS
87+
.DS_Store
88+
Thumbs.db

.readthedocs.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Read the Docs configuration file
2+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
3+
4+
version: 2
5+
6+
build:
7+
os: ubuntu-24.04
8+
tools:
9+
python: "3.11"
10+
11+
mkdocs:
12+
configuration: mkdocs.yml
13+
14+
python:
15+
install:
16+
- method: pip
17+
path: .
18+
extra_requirements:
19+
- docs

CONTRIBUTING.md

Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
# Contributing to FoxNose Python SDK
2+
3+
Thank you for your interest in contributing to the FoxNose Python SDK! This document provides guidelines and instructions for contributing.
4+
5+
## Code of Conduct
6+
7+
Please be respectful and constructive in all interactions. We welcome contributors of all backgrounds and experience levels.
8+
9+
## Getting Started
10+
11+
### Prerequisites
12+
13+
- Python 3.9 or higher
14+
- Git
15+
16+
### Development Setup
17+
18+
1. Clone the repository:
19+
20+
```bash
21+
git clone https://github.com/FoxNoseTech/foxnose-python.git
22+
cd foxnose-python
23+
```
24+
25+
2. Create a virtual environment:
26+
27+
```bash
28+
python -m venv venv
29+
source venv/bin/activate # On Windows: venv\Scripts\activate
30+
```
31+
32+
3. Install the package with development dependencies:
33+
34+
```bash
35+
pip install -e ".[test]"
36+
```
37+
38+
4. Install linting tools:
39+
40+
```bash
41+
pip install ruff
42+
```
43+
44+
## Development Workflow
45+
46+
### Code Style
47+
48+
This project uses [Ruff](https://docs.astral.sh/ruff/) for linting and formatting. Before submitting a pull request, ensure your code passes all checks:
49+
50+
```bash
51+
# Check for linting issues
52+
ruff check .
53+
54+
# Format code
55+
ruff format .
56+
```
57+
58+
### Type Hints
59+
60+
All public APIs should include type hints. We use Python's built-in `typing` module and Pydantic for model definitions.
61+
62+
### Docstrings
63+
64+
All public methods and classes should have docstrings following Google style:
65+
66+
```python
67+
def get_resource(self, folder_key: str, resource_key: str) -> ResourceSummary:
68+
"""Retrieve metadata for a specific resource.
69+
70+
Args:
71+
folder_key: Unique identifier of the folder.
72+
resource_key: Unique identifier of the resource.
73+
74+
Returns:
75+
Resource metadata including key, name, and timestamps.
76+
77+
Raises:
78+
FoxNoseAPIError: If the resource is not found or access is denied.
79+
"""
80+
```
81+
82+
### Running Tests
83+
84+
Run the test suite to ensure your changes don't break existing functionality:
85+
86+
```bash
87+
pytest
88+
```
89+
90+
For verbose output:
91+
92+
```bash
93+
pytest -v
94+
```
95+
96+
To run a specific test file:
97+
98+
```bash
99+
pytest tests/management/test_folders.py
100+
```
101+
102+
## Making Changes
103+
104+
### Branch Naming
105+
106+
Use descriptive branch names:
107+
108+
- `feature/add-webhook-support`
109+
- `fix/retry-on-timeout`
110+
- `docs/update-readme`
111+
112+
### Commit Messages
113+
114+
Write clear, concise commit messages:
115+
116+
- Use the present tense ("Add feature" not "Added feature")
117+
- Use the imperative mood ("Move cursor to..." not "Moves cursor to...")
118+
- Limit the first line to 72 characters
119+
- Reference issues and pull requests when relevant
120+
121+
Example:
122+
```
123+
Add retry logic for transient network errors
124+
125+
- Implement exponential backoff with jitter
126+
- Add configurable retry count and delay
127+
- Handle connection timeout and 5xx errors
128+
129+
Fixes #123
130+
```
131+
132+
### Pull Requests
133+
134+
1. Create a new branch from `main`
135+
2. Make your changes
136+
3. Run tests and linting
137+
4. Push your branch and create a pull request
138+
5. Fill out the PR template with:
139+
- Description of changes
140+
- Related issues
141+
- Testing performed
142+
143+
## Project Structure
144+
145+
```
146+
foxnose-python/
147+
├── src/
148+
│ └── foxnose_sdk/
149+
│ ├── __init__.py
150+
│ ├── auth.py # Authentication strategies
151+
│ ├── config.py # Configuration classes
152+
│ ├── errors.py # Exception definitions
153+
│ ├── http.py # HTTP transport layer
154+
│ ├── management/ # Management API client
155+
│ │ ├── __init__.py
156+
│ │ ├── client.py # ManagementClient, AsyncManagementClient
157+
│ │ └── models.py # Pydantic models
158+
│ └── flux/ # Flux API client
159+
│ ├── __init__.py
160+
│ ├── client.py # FluxClient, AsyncFluxClient
161+
│ └── models.py # Pydantic models
162+
├── tests/ # Test suite
163+
├── pyproject.toml
164+
├── README.md
165+
├── CONTRIBUTING.md
166+
└── LICENSE
167+
```
168+
169+
## Adding New Features
170+
171+
When adding new API methods:
172+
173+
1. Add the method to the sync client (`ManagementClient` or `FluxClient`)
174+
2. Add the corresponding async method to the async client
175+
3. Add appropriate Pydantic models if needed
176+
4. Write tests covering the new functionality
177+
5. Add docstrings with Args, Returns, and Raises sections
178+
6. Update documentation if applicable
179+
180+
## Reporting Issues
181+
182+
When reporting bugs, please include:
183+
184+
- Python version
185+
- SDK version
186+
- Operating system
187+
- Minimal code example to reproduce
188+
- Full error traceback
189+
190+
## Questions?
191+
192+
If you have questions about contributing, feel free to open an issue with the "question" label.
193+
194+
## License
195+
196+
By contributing to this project, you agree that your contributions will be licensed under the Apache License 2.0.

0 commit comments

Comments
 (0)