Skip to content

Commit

Permalink
Merge pull request #271 from vkottler/dev/5.6.4
Browse files Browse the repository at this point in the history
5.6.4 - Initial file-polling task
  • Loading branch information
vkottler authored Oct 16, 2024
2 parents 0b9c3a2 + c01aeae commit 18716c9
Show file tree
Hide file tree
Showing 61 changed files with 545 additions and 188 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
- run: |
mk python-release owner=vkottler \
repo=runtimepy version=5.6.3
repo=runtimepy version=5.6.4
if: |
matrix.python-version == '3.12'
&& matrix.system == 'ubuntu-latest'
Expand Down
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
max-args=10
max-positional-arguments=10
max-attributes=15
max-parents=13
max-parents=14
max-public-methods=22
max-branches=13

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
=====================================
generator=datazen
version=3.1.4
hash=ac4d0a4097094aeb4e3f43c5f1128115
hash=41c5a2511c80b2cbbaee668bb6a75bd2
=====================================
-->

# runtimepy ([5.6.3](https://pypi.org/project/runtimepy/))
# runtimepy ([5.6.4](https://pypi.org/project/runtimepy/))

[![python](https://img.shields.io/pypi/pyversions/runtimepy.svg)](https://pypi.org/project/runtimepy/)
![Build Status](https://github.com/vkottler/runtimepy/workflows/Python%20Package/badge.svg)
Expand Down
2 changes: 1 addition & 1 deletion config
7 changes: 6 additions & 1 deletion local/configs/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ entry: {{entry}}
time_command: true

requirements:
- vcorelib>=3.3.1
- aiofiles
- vcorelib>=3.4.2
- svgen>=0.6.8
- websockets
- psutil
Expand Down Expand Up @@ -39,5 +40,9 @@ init_local: |
METRICS_NAME = "metrics"
DEFAULT_EXT = "yaml"
mypy_local: |
[mypy-aiofiles.*]
ignore_missing_imports = True
ci_local:
- "- run: mk python-editable"
2 changes: 1 addition & 1 deletion local/configs/python.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
author_info:
name: Vaughn Kottler
email: vaughnkottler@gmail.com
email: vaughn@libre-embedded.com
username: vkottler
versions: ["3.11", "3.12"]

Expand Down
2 changes: 1 addition & 1 deletion local/variables/package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
major: 5
minor: 6
patch: 3
patch: 4
entry: runtimepy
4 changes: 4 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ warn_unused_ignores = False
strict = False
disallow_any_generics = False
strict_equality = False

# runtimepy-specific configurations.
[mypy-aiofiles.*]
ignore_missing_imports = True
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ build-backend = "setuptools.build_meta:__legacy__"

[project]
name = "runtimepy"
version = "5.6.3"
version = "5.6.4"
description = "A framework for implementing Python services."
readme = "README.md"
requires-python = ">=3.11"
authors = [
{name = "Vaughn Kottler", email = "vaughnkottler@gmail.com"}
{name = "Vaughn Kottler", email = "vaughn@libre-embedded.com"}
]
maintainers = [
{name = "Vaughn Kottler", email = "vaughnkottler@gmail.com"}
{name = "Vaughn Kottler", email = "vaughn@libre-embedded.com"}
]
classifiers = [
"Programming Language :: Python :: 3.11",
Expand Down
4 changes: 2 additions & 2 deletions runtimepy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# =====================================
# generator=datazen
# version=3.1.4
# hash=9547492b6c819241db9f6c010450b6ce
# hash=beefe82269955725f177c01474f7cea1
# =====================================

"""
Expand All @@ -10,7 +10,7 @@

DESCRIPTION = "A framework for implementing Python services."
PKG_NAME = "runtimepy"
VERSION = "5.6.3"
VERSION = "5.6.4"

# runtimepy-specific content.
METRICS_NAME = "metrics"
Expand Down
2 changes: 1 addition & 1 deletion runtimepy/channel/environment/command/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from vcorelib.io import ARBITER, JsonObject
from vcorelib.logging import DEFAULT_TIME_FORMAT, LoggerMixin
from vcorelib.math import default_time_ns, nano_str
from vcorelib.names import name_search

# internal
from runtimepy.channel.environment import ChannelEnvironment
Expand All @@ -26,7 +27,6 @@
)
from runtimepy.channel.registry import ParsedEvent
from runtimepy.mapping import DEFAULT_PATTERN
from runtimepy.util import name_search

# Declared so we re-export FieldOrChannel after moving where it's declared.
__all__ = [
Expand Down
4 changes: 3 additions & 1 deletion runtimepy/channel/environment/telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
from contextlib import ExitStack, contextmanager
from typing import BinaryIO, Iterator, Optional, cast

# third-party
from vcorelib.names import name_search

# internal
from runtimepy.channel.environment.base import (
BaseChannelEnvironment as _BaseChannelEnvironment,
Expand All @@ -14,7 +17,6 @@
from runtimepy.channel.registry import ParsedEvent
from runtimepy.mapping import DEFAULT_PATTERN
from runtimepy.metrics.channel import ChannelMetrics
from runtimepy.util import name_search


class TelemetryChannelEnvironment(_BaseChannelEnvironment):
Expand Down
1 change: 1 addition & 0 deletions runtimepy/data/css/bootstrap_extra.css
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

.table-container {
overflow-x: scroll;
min-height: fit-content;
}

.channel-column {
Expand Down
4 changes: 4 additions & 0 deletions runtimepy/data/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ body > :first-child {
height: 100%;
}

#runtimepy-tabs {
width: min-content;
}

#runtimepy-splash {
position: fixed;
top: 0;
Expand Down
35 changes: 34 additions & 1 deletion runtimepy/data/dummy_load.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,19 @@ tasks:
# Sinusoids.
- {name: wave1, factory: sinusoid, period_s: 0.01}
- {name: wave2, factory: sinusoid, period_s: 0.02}
- {name: wave3, factory: sinusoid, period_s: 0.03}
- name: wave3
factory: sinusoid
period_s: 0.03
markdown: |
# Markdown for wave3
* list element 1
* list element 2
* list element 3
To be continued.
`peace`
# Drive interactions with runtime entities that won't otherwise be polled.
- {name: app, factory: SampleApp, period_s: 0.25}
Expand All @@ -21,6 +33,11 @@ clients:
defer: true
kwargs:
remote_addr: [localhost, "$udp_json"]
markdown: |
# `udp_json_client`
Connects to `udp_json_server`.
- factory: udp_json
name: udp_json_server
kwargs:
Expand All @@ -36,8 +53,19 @@ structs:
b: 2
c: 3

markdown: |
# Docs for `example.struct1`
Should be shown for peer process as well?
- name: struct2
factory: sample_struct
config:
markdown: |
# `struct2`
One of the structs of all time.
- name: struct3
factory: sample_struct

Expand All @@ -46,6 +74,11 @@ processes:
- name: proc1
factory: sample_peer

markdown: |
# Markdown for `proc1`
A process that
# The peer itself runs an arbiter process.
config:
includes:
Expand Down
3 changes: 3 additions & 0 deletions runtimepy/data/md/Connection.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Connections

To be continued.
3 changes: 3 additions & 0 deletions runtimepy/data/md/PeriodicTask.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Periodic Tasks

To be continued.
3 changes: 3 additions & 0 deletions runtimepy/data/md/RuntimeStruct.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Runtime Structures

To be continued.
3 changes: 3 additions & 0 deletions runtimepy/data/md/RuntimepyPeer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Peer Programs

To be continued.
20 changes: 20 additions & 0 deletions runtimepy/data/md/SinusoidTask.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Sinusoid Tasks

## Intent

These tasks compute
[`math.sin`](https://docs.python.org/3/library/math.html#math.sin) and
[`math.cos`](https://docs.python.org/3/library/math.html#math.cos) on every
iteration, which advances one "step" per dispatch where the "step angle"
advanced depends on the `steps` control.

Once the current "step angle" is computed, controls `amplitude` and phase
angles are considered for final `sin` and `cos` channel values.

## Discussion

* Is it worth adding a `tan` channel that computes
[`math.tan`](https://docs.python.org/3/library/math.html#math.tan) and/or other
trigonometric functions?
* Is it worth adding a "number of steps" control, such that one task iteration
could advance multiple waveform steps?
1 change: 1 addition & 0 deletions runtimepy/data/schemas/ClientConnectionConfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
includes:
- has_factory.yaml
- has_name.yaml
- has_markdown.yaml

properties:
defer:
Expand Down
1 change: 1 addition & 0 deletions runtimepy/data/schemas/PeerProcessConfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ includes:
- has_factory.yaml
- has_name.yaml
- has_config.yaml
- has_markdown.yaml

required: [program]

Expand Down
1 change: 1 addition & 0 deletions runtimepy/data/schemas/TaskConfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
includes:
- has_factory.yaml
- has_name.yaml
- has_markdown.yaml

properties:
period_s:
Expand Down
4 changes: 4 additions & 0 deletions runtimepy/data/schemas/has_markdown.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
properties:
markdown:
type: string
2 changes: 1 addition & 1 deletion runtimepy/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@

# third-party
from vcorelib.logging import LoggerMixin
from vcorelib.names import name_search

# internal
from runtimepy.mixins.regex import RegexMixin as _RegexMixin
from runtimepy.util import name_search

# This determines types that are valid as keys.
T = _TypeVar("T", int, bool)
Expand Down
4 changes: 2 additions & 2 deletions runtimepy/message/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

# third-party
from vcorelib.dict.codec import JsonCodec
from vcorelib.logging import LoggerType
from vcorelib.logging import ListLogger, LoggerType
from vcorelib.target.resolver import TargetResolver

# internal
Expand Down Expand Up @@ -39,7 +39,7 @@
T,
TypedHandler,
)
from runtimepy.util import Identifier, ListLogger
from runtimepy.util import Identifier


class JsonMessageInterface:
Expand Down
14 changes: 10 additions & 4 deletions runtimepy/mixins/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,14 @@ def __hash__(self) -> int:
return id(self.env)

def register_task_metrics(
self, metrics: PeriodicTaskMetrics, namespace: str = METRICS_NAME
self,
metrics: PeriodicTaskMetrics,
*names: str,
namespace: str = METRICS_NAME,
) -> None:
"""Register periodic task metrics."""

with self.env.names_pushed(namespace):
with self.env.names_pushed(namespace, *names):
self.env.channel(
"dispatches",
metrics.dispatches,
Expand Down Expand Up @@ -104,11 +107,14 @@ def register_channel_metrics(
)

def register_connection_metrics(
self, metrics: ConnectionMetrics, namespace: str = METRICS_NAME
self,
metrics: ConnectionMetrics,
*names: str,
namespace: str = METRICS_NAME,
) -> None:
"""Register connection metrics."""

with self.env.names_pushed(namespace):
with self.env.names_pushed(namespace, *names):
for name, direction, verb in [
("tx", metrics.tx, "transmitted"),
("rx", metrics.rx, "received"),
Expand Down
Loading

0 comments on commit 18716c9

Please sign in to comment.