Split functionality into modules by dependencies

Open
#13 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Stale
Tech stack
fastapi, python

Research direction

Start by reading pyproject.toml and inspecting the current observability_utils package for imports used by the FastAPI and STOMP integrations. Trace the existing tracing entry points and dependency declarations before deciding how the modules should be separated. Done means each integration is importable only with its corresponding optional dependency group, without imposing the other integration's dependency.

Written by the indexing model from the issue text.

Description

enhancement

As a user I would like to use this library in a FastAPI project without also having a transient dependency on stomp-py (and vice versa)

Possible Solution

Split project into modules by import dependency e.g.:

  • src
    • fastapi
      • tracing.py
    • stomp
      • tracing.py

And then add dependency groups to pyproject.toml e.g.

dependencies = [
    "typing_extensions<4.6",
    "opentelemetry-distro",
    "opentelemetry-exporter-otlp",
    "stomp.py",
] # Add project dependencies here, e.g. ["click", "numpy"]
dynamic = ["version"]
license.file = "LICENSE"
readme = "README.md"
requires-python = ">=3.10"

[project.optional-dependencies]
dev = [
    "copier",
    "pipdeptree",
    "pre-commit",
    "pyright",
    "pytest",
    "pytest-cov",
    "ruff",
    "tox-direct",
    "types-mock",
]

fastapi = ["fastapi[all]<0.99", "opentelemetry-instrumentation-fastapi"]
stomp = ["stomp-py"]

Acceptance Criteria

  • Importing from observability_utils.fastapi only works if I have run pip install observability_utils[fastapi]
  • Importing from observability_utils.stomp only works if I have run pip install observability_utils[stomp]
Dominant language
Python
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from DiamondLightSource/observability-utils

All issues in DiamondLightSource/observability-utils

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.