roboherd 0.1.7__tar.gz → 0.1.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of roboherd might be problematic. Click here for more details.
- {roboherd-0.1.7 → roboherd-0.1.8}/CHANGES.md +5 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/PKG-INFO +1 -1
- {roboherd-0.1.7 → roboherd-0.1.8}/docs/index.md +1 -1
- {roboherd-0.1.7 → roboherd-0.1.8}/pyproject.toml +1 -1
- {roboherd-0.1.7 → roboherd-0.1.8}/roboherd/cow/__init__.py +20 -19
- roboherd-0.1.8/roboherd/cow/test_init.py +41 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/roboherd/herd/manager/config.py +30 -6
- {roboherd-0.1.7 → roboherd-0.1.8}/roboherd/herd/manager/test_config.py +2 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/uv.lock +1 -1
- roboherd-0.1.7/roboherd/cow/test_init.py +0 -57
- {roboherd-0.1.7 → roboherd-0.1.8}/.gitignore +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/.woodpecker/create_release.yml +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/.woodpecker/publish_docker.yml +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/.woodpecker/publish_pypi.yml +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/.woodpecker/test.yml +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/.woodpecker/website.yml +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/README.md +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/docs/annotations.md +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/docs/assets/bull-horns.png +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/docs/assets/mastodon.png +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/docs/cli.md +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/docs/cow.md +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/docs/herd.md +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/docs/main.md +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/docs/util.md +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/mkdocs.yml +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/resources/docker/Dockerfile +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/resources/docker/build.sh +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/roboherd/__init__.py +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/roboherd/__main__.py +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/roboherd/annotations/__init__.py +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/roboherd/annotations/bovine.py +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/roboherd/annotations/common.py +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/roboherd/cow/const.py +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/roboherd/cow/handlers.py +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/roboherd/cow/profile.py +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/roboherd/cow/test_handlers.py +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/roboherd/cow/test_profile.py +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/roboherd/cow/test_util.py +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/roboherd/cow/types.py +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/roboherd/cow/util.py +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/roboherd/examples/__init__.py +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/roboherd/examples/dev_null.py +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/roboherd/examples/json_echo.py +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/roboherd/examples/meta.py +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/roboherd/examples/moocow.py +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/roboherd/examples/number.py +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/roboherd/examples/rooster.py +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/roboherd/examples/scarecrow.py +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/roboherd/herd/__init__.py +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/roboherd/herd/builder.py +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/roboherd/herd/manager/__init__.py +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/roboherd/herd/manager/load.py +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/roboherd/herd/manager/test_load.py +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/roboherd/herd/manager/test_manager.py +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/roboherd/herd/processor.py +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/roboherd/herd/scheduler.py +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/roboherd/herd/test_herd.py +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/roboherd/herd/test_scheduler.py +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/roboherd/herd/types.py +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/roboherd/register.py +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/roboherd/test_validators.py +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/roboherd/util.py +0 -0
- {roboherd-0.1.7 → roboherd-0.1.8}/roboherd/validators.py +0 -0
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changes to roboherd
|
|
2
2
|
|
|
3
|
+
## 0.1.8 ([Milestone](https://codeberg.org/bovine/roboherd/milestone/11129))
|
|
4
|
+
|
|
5
|
+
- Add ConfigOverrides model [roboherd#43](https://codeberg.org/bovine/roboherd/issues/43)
|
|
6
|
+
- Allow to skip startup [roboherd#41](https://codeberg.org/bovine/roboherd/issues/41)
|
|
7
|
+
|
|
3
8
|
## 0.1.7 ([Milestone](https://codeberg.org/bovine/roboherd/milestone/10741))
|
|
4
9
|
|
|
5
10
|
- Repair docker file [roboherd#38](https://codeberg.org/bovine/roboherd/issues/38)
|
|
@@ -122,7 +122,7 @@ handle = "nothingness"
|
|
|
122
122
|
```
|
|
123
123
|
|
|
124
124
|
one would instead create a bot with the handle `acct:nothingness@dev.bovine.social`.
|
|
125
|
-
|
|
125
|
+
The full list of options can be found in [roboherd.herd.manager.config.ConfigOverrides][].
|
|
126
126
|
|
|
127
127
|
### Posting on startup
|
|
128
128
|
|
|
@@ -76,6 +76,13 @@ class RoboCow:
|
|
|
76
76
|
),
|
|
77
77
|
)
|
|
78
78
|
|
|
79
|
+
skip_profile_update: bool = field(
|
|
80
|
+
default=False,
|
|
81
|
+
metadata=dict(
|
|
82
|
+
description="When set to True the profile is not updated automatically. Useful when managing a cow from multiple scripts."
|
|
83
|
+
),
|
|
84
|
+
)
|
|
85
|
+
|
|
79
86
|
internals: RoboCowInternals = field(
|
|
80
87
|
default_factory=RoboCowInternals,
|
|
81
88
|
metadata=dict(description="Internal data for the cow"),
|
|
@@ -166,19 +173,6 @@ class RoboCow:
|
|
|
166
173
|
|
|
167
174
|
self.internals.startup_routine = func
|
|
168
175
|
|
|
169
|
-
def needs_update(self):
|
|
170
|
-
"""Checks if the cow needs to be updated"""
|
|
171
|
-
if self.internals.profile is None:
|
|
172
|
-
return True
|
|
173
|
-
|
|
174
|
-
if self.information.name != self.internals.profile.get("name"):
|
|
175
|
-
return True
|
|
176
|
-
|
|
177
|
-
if self.information.description != self.internals.profile.get("summary"):
|
|
178
|
-
return True
|
|
179
|
-
|
|
180
|
-
return False
|
|
181
|
-
|
|
182
176
|
async def run_startup(self, connection: Almabtrieb):
|
|
183
177
|
"""Runs when the cow is birthed"""
|
|
184
178
|
|
|
@@ -198,12 +192,8 @@ class RoboCow:
|
|
|
198
192
|
)
|
|
199
193
|
self.information.frequency = frequency
|
|
200
194
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
if update:
|
|
204
|
-
logger.info("Updating profile for %s", self.information.handle)
|
|
205
|
-
|
|
206
|
-
await connection.trigger("update_actor", update)
|
|
195
|
+
if not self.skip_profile_update:
|
|
196
|
+
await self._run_profile_update(connection)
|
|
207
197
|
|
|
208
198
|
if self.internals.startup_routine:
|
|
209
199
|
await inject(self.internals.startup_routine)(
|
|
@@ -211,3 +201,14 @@ class RoboCow:
|
|
|
211
201
|
connection=connection, # type:ignore
|
|
212
202
|
actor_id=self.internals.actor_id, # type:ignore
|
|
213
203
|
) # type:ignore
|
|
204
|
+
|
|
205
|
+
async def _run_profile_update(self, connection: Almabtrieb):
|
|
206
|
+
if self.internals.profile is None:
|
|
207
|
+
raise ValueError("Profile is not set")
|
|
208
|
+
|
|
209
|
+
update = determine_profile_update(self.information, self.internals.profile)
|
|
210
|
+
|
|
211
|
+
if update:
|
|
212
|
+
logger.info("Updating profile for %s", self.information.handle)
|
|
213
|
+
|
|
214
|
+
await connection.trigger("update_actor", update)
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
from unittest.mock import AsyncMock
|
|
2
|
+
|
|
3
|
+
from . import RoboCow
|
|
4
|
+
from .types import Information
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def test_cron():
|
|
8
|
+
info = Information(handle="testcow")
|
|
9
|
+
cow = RoboCow(information=info)
|
|
10
|
+
|
|
11
|
+
@cow.cron("* * * * *")
|
|
12
|
+
async def test_func():
|
|
13
|
+
pass
|
|
14
|
+
|
|
15
|
+
assert len(cow.internals.cron_entries) == 1
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
async def test_startup():
|
|
19
|
+
info = Information(handle="testcow")
|
|
20
|
+
cow = RoboCow(information=info)
|
|
21
|
+
cow.internals.profile = {"id": "http://host.test/actor/cow"}
|
|
22
|
+
mock = AsyncMock()
|
|
23
|
+
connection = AsyncMock()
|
|
24
|
+
|
|
25
|
+
cow.startup(mock)
|
|
26
|
+
|
|
27
|
+
await cow.run_startup(connection=connection)
|
|
28
|
+
|
|
29
|
+
mock.assert_called_once()
|
|
30
|
+
connection.trigger.assert_awaited_once()
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
async def test_skip_startup():
|
|
34
|
+
info = Information(handle="testcow")
|
|
35
|
+
cow = RoboCow(information=info, skip_profile_update=True)
|
|
36
|
+
cow.internals.profile = {"id": "http://host.test/actor/cow"}
|
|
37
|
+
|
|
38
|
+
connection = AsyncMock()
|
|
39
|
+
await cow.run_startup(connection=connection)
|
|
40
|
+
|
|
41
|
+
connection.trigger.assert_not_awaited()
|
|
@@ -1,9 +1,32 @@
|
|
|
1
|
+
from pydantic import BaseModel, Field
|
|
2
|
+
|
|
1
3
|
from dataclasses import dataclass, field
|
|
2
4
|
|
|
3
5
|
from roboherd.cow import RoboCow
|
|
4
6
|
from .load import load_cow
|
|
5
7
|
|
|
6
8
|
|
|
9
|
+
class ConfigOverrides(BaseModel):
|
|
10
|
+
"""Values used in `roboherd.toml` to overide the default
|
|
11
|
+
values in the imported cow. This class is meant as a
|
|
12
|
+
reference, and not meant to be directly used."""
|
|
13
|
+
|
|
14
|
+
name: str | None = Field(
|
|
15
|
+
default=None, description="set to override the name", examples=["New name"]
|
|
16
|
+
)
|
|
17
|
+
handle: str | None = Field(
|
|
18
|
+
default=None, description="set to override the handle", examples=["new-handle"]
|
|
19
|
+
)
|
|
20
|
+
base_url: str | None = Field(
|
|
21
|
+
default=None,
|
|
22
|
+
description="set to override the base url",
|
|
23
|
+
examples=["https://other.example"],
|
|
24
|
+
)
|
|
25
|
+
skip_profile_update: bool | None = Field(
|
|
26
|
+
default=None, description="set to skip updating the profile", examples=[True]
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
|
|
7
30
|
@dataclass
|
|
8
31
|
class CowConfig:
|
|
9
32
|
name: str = field(metadata={"description": "Name of the cow, must be unique"})
|
|
@@ -20,13 +43,14 @@ class CowConfig:
|
|
|
20
43
|
def load(self) -> RoboCow:
|
|
21
44
|
cow = load_cow(self.module, self.attribute)
|
|
22
45
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
46
|
+
overrides = ConfigOverrides(**self.config)
|
|
47
|
+
|
|
48
|
+
for value in ["name", "handle", "base_url"]:
|
|
49
|
+
if getattr(overrides, value):
|
|
50
|
+
setattr(cow.information, value, getattr(overrides, value))
|
|
27
51
|
|
|
28
|
-
if
|
|
29
|
-
cow.
|
|
52
|
+
if overrides.skip_profile_update:
|
|
53
|
+
cow.skip_profile_update = overrides.skip_profile_update
|
|
30
54
|
|
|
31
55
|
return cow
|
|
32
56
|
|
|
@@ -44,6 +44,7 @@ def test_from_name_and_dict_with_new_name():
|
|
|
44
44
|
"bot": "roboherd.examples.moocow:moocow",
|
|
45
45
|
"handle": "new_handle",
|
|
46
46
|
"name": "new name",
|
|
47
|
+
"skip_profile_update": True,
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
config = CowConfig.from_name_and_dict(name, value)
|
|
@@ -52,6 +53,7 @@ def test_from_name_and_dict_with_new_name():
|
|
|
52
53
|
|
|
53
54
|
assert cow.information.name == "new name"
|
|
54
55
|
assert cow.information.handle == "new_handle"
|
|
56
|
+
assert cow.skip_profile_update is True
|
|
55
57
|
|
|
56
58
|
|
|
57
59
|
def test_load_config(test_config):
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import pytest
|
|
2
|
-
from unittest.mock import AsyncMock
|
|
3
|
-
|
|
4
|
-
from . import RoboCow
|
|
5
|
-
from .types import Information
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
@pytest.mark.parametrize(
|
|
9
|
-
"name,summary,profile,expected",
|
|
10
|
-
[
|
|
11
|
-
("moocow", None, None, True),
|
|
12
|
-
("moocow", None, {"id": "123"}, True),
|
|
13
|
-
("moocow", None, {"id": "123", "name": "moocow"}, False),
|
|
14
|
-
("moocow", None, {"id": "123", "name": "other"}, True),
|
|
15
|
-
("moocow", "description", {"id": "123", "name": "moocow"}, True),
|
|
16
|
-
(
|
|
17
|
-
"moocow",
|
|
18
|
-
"description",
|
|
19
|
-
{"id": "123", "name": "moocow", "summary": "description"},
|
|
20
|
-
False,
|
|
21
|
-
),
|
|
22
|
-
],
|
|
23
|
-
)
|
|
24
|
-
def test_needs_update(name, summary, profile, expected):
|
|
25
|
-
info = Information(
|
|
26
|
-
handle="testcow",
|
|
27
|
-
name=name,
|
|
28
|
-
description=summary,
|
|
29
|
-
)
|
|
30
|
-
cow = RoboCow(information=info)
|
|
31
|
-
cow.internals.profile = profile
|
|
32
|
-
|
|
33
|
-
assert cow.needs_update() == expected
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
def test_cron():
|
|
37
|
-
info = Information(handle="testcow")
|
|
38
|
-
cow = RoboCow(information=info)
|
|
39
|
-
|
|
40
|
-
@cow.cron("* * * * *")
|
|
41
|
-
async def test_func():
|
|
42
|
-
pass
|
|
43
|
-
|
|
44
|
-
assert len(cow.internals.cron_entries) == 1
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
async def test_startup():
|
|
48
|
-
info = Information(handle="testcow")
|
|
49
|
-
cow = RoboCow(information=info)
|
|
50
|
-
cow.internals.profile = {"id": "http://host.test/actor/cow"}
|
|
51
|
-
mock = AsyncMock()
|
|
52
|
-
|
|
53
|
-
cow.startup(mock)
|
|
54
|
-
|
|
55
|
-
await cow.run_startup(AsyncMock())
|
|
56
|
-
|
|
57
|
-
mock.assert_called_once()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|