Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Python package
on: [push, pull_request, workflow_dispatch]

env:
release-python-version: "3.10"
release-python-version: "3.11"

jobs:
test:
Expand Down Expand Up @@ -81,7 +81,7 @@ jobs:
name: distribution-packages
path: dist/
- name: Publish a Python distribution to PyPI
uses: pypa/gh-action-pypi-publish@master
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.pypi_password }}
Expand Down
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ exclude .gitmodules
exclude .pre-commit-config.yaml
exclude .github_changelog_generator
exclude .dockerignore

prune docs/_build
6 changes: 3 additions & 3 deletions docs/api/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ Decorators
----------

.. automodule:: metricq.cli.decorator
:members: metricq_command, metricq_metric_option, metricq_server_option, metricq_syslog_option, metricq_token_option,
:members: command, metric_option, server_option, syslog_option, token_option,


Parameter
---------
Parameters
----------
For you convenience, we provide a set of custom parameter types that you can use as custom types in your click option definitions.

.. automodule:: metricq.cli.params
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
intersphinx_mapping = {
"python": ("https://docs.python.org/3", None),
"dateutil": ("https://dateutil.readthedocs.io/en/stable/", None),
"aio_pika": ("https://aio-pika.readthedocs.io/en/latest/", None),
"aio_pika": ("https://docs.aio-pika.com/", None),
}


Expand Down
4 changes: 2 additions & 2 deletions docs/howto/project-structure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,11 @@ code at runtime:

.. code-block:: toml

# in pythonproject.toml
# in pyproject.toml

[build-system]
requires = [
..., # other build dependencies here
# ..., other build dependencies here
"setuptools_scm[toml]~=6.0",
]

Expand Down
16 changes: 16 additions & 0 deletions docs/upgrading.rst
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,19 @@ Renaming of setup.py options
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The user option ``out-dir`` has been renamed to ``package-dir``.

`5.x` → `6.0`
-------------

Renaming of CLI decorators
^^^^^^^^^^^^^^^^^^^^^^^^^^

The docorators of the CLI feature have been renamed.

- `metricq_syslog_option` -> :func:`cli.decorator.syslog_option`
- `metricq_server_option` -> :func:`cli.decorator.server_option`
- `metricq_token_option` -> :func:`cli.decorator.token_option`
- `metricq_metric_option` -> :func:`cli.decorator.metric_option`
- `metricq_command` -> :func:`cli.decorator.command`


3 changes: 1 addition & 2 deletions examples/metricq_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import aiomonitor # type: ignore

import metricq
from metricq.cli import metricq_command

logger = metricq.get_logger()

Expand All @@ -59,7 +58,7 @@ async def run(server: str, token: str) -> None:
await client.stopped()


@metricq_command(default_token="client-py-example")
@metricq.cli.command(default_token="client-py-example")
def main(server: str, token: str) -> None:
asyncio.run(run(server, token))

Expand Down
9 changes: 3 additions & 6 deletions examples/metricq_get_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,8 @@
import click

import metricq
from metricq.cli import metricq_command
from metricq.cli.decorator import metricq_metric_option
from metricq.logging import get_logger

logger = get_logger()
logger = metricq.get_logger()


async def aget_history(
Expand Down Expand Up @@ -91,8 +88,8 @@ async def aget_history(
click.echo(aggregate)


@metricq_command(default_token="history-py-dummy")
@metricq_metric_option()
@metricq.cli.command(default_token="history-py-dummy")
@metricq.cli.metric_option()
@click.option("--list-metrics", is_flag=True)
@click.option("--list-metadata", is_flag=True)
def get_history(
Expand Down
6 changes: 2 additions & 4 deletions examples/metricq_get_history_raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
import click

import metricq
from metricq.cli import metricq_command
from metricq.cli.decorator import metricq_metric_option
from metricq.history_client import HistoryRequestType


Expand Down Expand Up @@ -73,8 +71,8 @@ async def aget_history(server: str, token: str, metric: str) -> None:
await client.stop(None)


@metricq_command(default_token="history-py-dummy")
@metricq_metric_option()
@metricq.cli.command(default_token="history-py-dummy")
@metricq.cli.metric_option()
def get_history(server: str, token: str, metric: str) -> None:
asyncio.run(aget_history(server, token, metric))

Expand Down
6 changes: 2 additions & 4 deletions examples/metricq_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
import click

import metricq
from metricq.cli import metricq_command
from metricq.cli.decorator import metricq_metric_option
from metricq.pandas import PandasHistoryClient

logger = metricq.get_logger()
Expand Down Expand Up @@ -73,8 +71,8 @@ async def aget_history(server: str, token: str, metric: str) -> None:
click.echo("----------")


@metricq_command(default_token="history-py-dummy")
@metricq_metric_option(default="example.quantity")
@metricq.cli.command(default_token="history-py-dummy")
@metricq.cli.metric_option(default="example.quantity")
def get_history(server: str, token: str, metric: str) -> None:
asyncio.run(aget_history(server, token, metric))

Expand Down
9 changes: 3 additions & 6 deletions examples/metricq_sink.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,8 @@

import metricq
from metricq import Metric
from metricq.cli import metricq_command
from metricq.cli.decorator import metricq_metric_option
from metricq.logging import get_logger

logger = get_logger()
logger = metricq.get_logger()


# To implement a MetricQ Sink, subclass metricq.Sink
Expand Down Expand Up @@ -70,8 +67,8 @@ async def on_data(
)


@metricq_command(default_token="sink-py-dummy")
@metricq_metric_option(multiple=True)
@metricq.cli.command(default_token="sink-py-dummy")
@metricq.cli.metric_option(multiple=True)
def source(server: str, token: str, metric: list[Metric]) -> None:
# Initialize the DummySink class with a list of metrics given on the
# command line.
Expand Down
6 changes: 2 additions & 4 deletions examples/metricq_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@
from typing import Any

import metricq
from metricq.cli import metricq_command
from metricq.logging import get_logger

logger = get_logger()
logger = metricq.get_logger()


class DummySource(metricq.IntervalSource):
Expand Down Expand Up @@ -65,7 +63,7 @@ async def update(self) -> None:
)


@metricq_command(default_token="source-py-dummy")
@metricq.cli.command(default_token="source-py-dummy")
def source(server: str, token: str) -> None:
src = DummySource(token=token, url=server)
src.run()
Expand Down
7 changes: 3 additions & 4 deletions examples/metricq_synchronous_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@
import random
import time

import metricq
from metricq import SynchronousSource, Timestamp
from metricq.cli import metricq_command
from metricq.logging import get_logger

logger = get_logger()
logger = metricq.get_logger()


@metricq_command(default_token="source-py-dummy")
@metricq.cli.command(default_token="source-py-dummy")
def synchronous_source(server: str, token: str) -> None:
ssource = SynchronousSource(token=token, url=server)
ssource.declare_metrics(
Expand Down
6 changes: 6 additions & 0 deletions metricq/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@
)
from .version import __version__

try:
from . import cli
except ImportError:
pass

# Please keep sorted alphabetically to avoid merge conflicts
__all__ = [
"Agent",
Expand All @@ -76,4 +81,5 @@
"Timestamp",
"TimeValue",
"__version__",
"cli",
]
20 changes: 10 additions & 10 deletions metricq/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from .decorator import (
metricq_command,
metricq_metric_option,
metricq_server_option,
metricq_syslog_option,
metricq_token_option,
command,
metric_option,
server_option,
syslog_option,
token_option,
)
from .params import (
ChoiceParam,
Expand All @@ -21,9 +21,9 @@
"TemplateStringParam",
"TimestampParam",
"MetricParam",
"metricq_command",
"metricq_metric_option",
"metricq_server_option",
"metricq_syslog_option",
"metricq_token_option",
"command",
"metric_option",
"server_option",
"syslog_option",
"token_option",
]
Loading
Loading