Skip to content

Commit

Permalink
Use uv workspaces facilities to move shareable code into packages dir
Browse files Browse the repository at this point in the history
  • Loading branch information
inean committed Oct 9, 2024
1 parent 8edf1df commit 4937b95
Show file tree
Hide file tree
Showing 35 changed files with 1,046 additions and 245 deletions.
Empty file added .cache/.gitkeep
Empty file.
32 changes: 9 additions & 23 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
// Python exrtensions
"charliermarsh.ruff",
"kevinrose.vsc-python-indent",
"matangover.mypy",
"ms-azuretools.vscode-docker",
"ms-python.mypy-type-checker",
"ms-python.python",
"ms-python.vscode-pylance",
"ms-vscode-remote.remote-containers",
Expand All @@ -33,32 +33,13 @@
"yzhang.markdown-all-in-one"
],
"settings": {
// Editor settings
"files.insertFinalNewline": true,
"files.trimTrailingWhitespace": true,

// Python setttings
"python.testing.pytestArgs": [
"tests"
],
"python.testing.pytestEnabled": true,
"python.analysis.typeCheckingMode": "basic",
"python.analysis.autoImportCompletions": true,
// Python Container settings
"python.venvPath": "${containerWorkspaceFolder}/.venv",
"python.defaultInterpreterPath": "${containerWorkspaceFolder}/.venv/bin/python",
"python.analysis.extraPaths": [
"${containerWorkspaceFolder}/types"
],
"python.defaultInterpreterPath": "${containerWorkspaceFolder}/.venv/bin/python",
"python.venvPath": "${containerWorkspaceFolder}/.venv",
"python.envFile": "",
//Extensions
"[python]": {
"editor.codeActionsOnSave": {
"source.fixAll.ruff": "explicit",
"source.organizeImports.ruff": "explicit"
},
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.formatOnSave": true
},
"terminal.integrated.defaultProfile.linux": "zsh",
"terminal.integrated.profiles.linux": {
"zsh": {
Expand All @@ -80,6 +61,11 @@
}
},

// Set environment variables
"containerEnv": {
"PYTHONPYCACHEPREFIX": "/workspace/.cache/pycache"
},

// Update container
"updateContentCommand": "uv sync --dev --all-extras",

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3301,7 +3301,7 @@
"description": "Detailed metrics must be configured in the collector configuration. They add grouping by transport protocol (http/grpc) for receivers. ",
"hide": 0,
"includeAll": false,
"label": "Additional groupping",
"label": "Additional grouping",
"multi": false,
"name": "grouping",
"options": [
Expand Down
34 changes: 24 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
---
default_stages: [commit]
default_stages: [pre-commit]
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.5
hooks:
- id: ruff
name: Ruff linter
args: [--fix]
args: [--fix, --exit-non-zero-on-fix]
types_or: [python, pyi]
- id: ruff-format
name: Ruff format
types_or: [python, pyi]

- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
additional_dependencies:
- tomli
args: [--ignore-words-list, astroid ]

- repo: https://github.com/Yelp/detect-secrets
rev: v1.5.0
hooks:
- id: detect-secrets
args: ['--baseline', '.secrets.baseline']
additional_dependencies: ["gibberish-detector"]

- repo: https://github.com/executablebooks/mdformat
rev: 0.7.17
hooks:
Expand All @@ -29,16 +44,15 @@ repos:
types: ["dockerfile"]
entry: hadolint

- repo: local
- repo: https://github.com/econchick/interrogate
rev: 1.7.0 # or master if you're bold
hooks:
- id: update-version
name: Update Version
entry: uv run scripts/versioning.py
language: python
pass_filenames: false
stages: [commit]
files: ^pyproject\.toml$
- id: interrogate
args: [--quiet, --fail-under=1]
exclude: test.*

- repo: local
hooks:
- id: mypy
name: mypy static type checker
language: system
Expand Down
127 changes: 127 additions & 0 deletions .secrets.baseline
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
{
"version": "1.5.0",
"plugins_used": [
{
"name": "ArtifactoryDetector"
},
{
"name": "AWSKeyDetector"
},
{
"name": "AzureStorageKeyDetector"
},
{
"name": "Base64HighEntropyString",
"limit": 4.5
},
{
"name": "BasicAuthDetector"
},
{
"name": "CloudantDetector"
},
{
"name": "DiscordBotTokenDetector"
},
{
"name": "GitHubTokenDetector"
},
{
"name": "GitLabTokenDetector"
},
{
"name": "HexHighEntropyString",
"limit": 3.0
},
{
"name": "IbmCloudIamDetector"
},
{
"name": "IbmCosHmacDetector"
},
{
"name": "IPPublicDetector"
},
{
"name": "JwtTokenDetector"
},
{
"name": "KeywordDetector",
"keyword_exclude": ""
},
{
"name": "MailchimpDetector"
},
{
"name": "NpmDetector"
},
{
"name": "OpenAIDetector"
},
{
"name": "PrivateKeyDetector"
},
{
"name": "PypiTokenDetector"
},
{
"name": "SendGridDetector"
},
{
"name": "SlackDetector"
},
{
"name": "SoftlayerDetector"
},
{
"name": "SquareOAuthDetector"
},
{
"name": "StripeDetector"
},
{
"name": "TelegramBotTokenDetector"
},
{
"name": "TwilioKeyDetector"
}
],
"filters_used": [
{
"path": "detect_secrets.filters.allowlist.is_line_allowlisted"
},
{
"path": "detect_secrets.filters.common.is_ignored_due_to_verification_policies",
"min_level": 2
},
{
"path": "detect_secrets.filters.heuristic.is_indirect_reference"
},
{
"path": "detect_secrets.filters.heuristic.is_likely_id_string"
},
{
"path": "detect_secrets.filters.heuristic.is_lock_file"
},
{
"path": "detect_secrets.filters.heuristic.is_not_alphanumeric_string"
},
{
"path": "detect_secrets.filters.heuristic.is_potential_uuid"
},
{
"path": "detect_secrets.filters.heuristic.is_prefixed_with_dollar_sign"
},
{
"path": "detect_secrets.filters.heuristic.is_sequential_string"
},
{
"path": "detect_secrets.filters.heuristic.is_swagger_file"
},
{
"path": "detect_secrets.filters.heuristic.is_templated_secret"
}
],
"results": {},
"generated_at": "2024-10-08T18:26:34Z"
}
5 changes: 3 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
"files.insertFinalNewline": true,
"files.trimTrailingWhitespace": true,

// Python setttings
// Python settings
"python.envFile": "",
"python.testing.pytestEnabled": true,
"python.testing.pytestArgs": [
"tests"
],
"python.testing.pytestEnabled": true,
"python.analysis.typeCheckingMode": "basic",
"python.analysis.autoImportCompletions": true,
"python.analysis.extraPaths": [
Expand Down
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ARG REPOSITORY="inean/dns-synchub"
# Builder stage
FROM ghcr.io/astral-sh/uv:python${PYTHON_VERSION}-bookworm-slim AS builder

# Re-declare the ARG to use it in this stage
# Redeclare the ARG to use it in this stage
ARG APP_PATH
ARG VIRTUAL_ENV_PATH

Expand Down Expand Up @@ -39,7 +39,8 @@ ENV UV_LINK_MODE=copy
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock,ro \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml,ro \
uv sync --frozen --no-install-project --no-dev
--mount=type=bind,source=packages,target=packages,ro \
uv sync --frozen --python-preference=system --no-install-project --no-editable --no-dev --all-extras

# Copy the application source code:
COPY src .
Expand Down
1 change: 1 addition & 0 deletions packages/telemetry/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.11
Empty file added packages/telemetry/README.md
Empty file.
22 changes: 22 additions & 0 deletions packages/telemetry/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[project]
name = "telemetry"
version = "0.1.0"
description = "Helper library to work with telemetry data"
authors = [
{ name = "Carlos Martín", email = "inean.es@gmail.com" },
]
readme = "README.md"
license = "MIT"
requires-python = ">=3.11"
dependencies = [
"opentelemetry-api>=1.27.0",
"opentelemetry-sdk>=1.27.0",
"typing-extensions>=4.12.2",
]


[build-system]
requires = [
"hatchling",
]
build-backend = "hatchling.build"
Loading

0 comments on commit 4937b95

Please sign in to comment.