Skip to content

Commit

Permalink
Update dependencies, Remove python 3.8 support
Browse files Browse the repository at this point in the history
capnpy-agates -> capnpy
podping-schemas 0.1.0
plexo 1.0.0b1

returns for type-safe partial
  • Loading branch information
agates committed Nov 9, 2023
1 parent 5ca2964 commit 4f769c4
Show file tree
Hide file tree
Showing 14 changed files with 1,194 additions and 964 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pypi_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ jobs:
- name: Build and publish to pypi
uses: JRubics/[email protected]
with:
python_version: "3.11.0"
python_version: "3.11.6"
ignore_dev_requirements: "yes"
pypi_token: ${{ secrets.PYPI_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9, "3.10"]
python-version: [3.9, "3.10", "3.11"]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand Down
10 changes: 6 additions & 4 deletions examples/memory_profile/long_running_zmq.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import uuid
from ipaddress import IPv4Address

from plexo.axon import Axon
from plexo.ganglion.tcp_pair import GanglionZmqTcpPair
from plexo.plexus import Plexus
from podping_schemas.org.podcastindex.podping.hivewriter.podping_hive_transaction import (
Expand Down Expand Up @@ -81,11 +82,12 @@ async def endless_send_loop():
),
)
plexus = Plexus(ganglia=(tcp_pair_ganglion,))
await plexus.adapt(
podping_hive_transaction_neuron,
podping_hive_transaction_axon = Axon(podping_hive_transaction_neuron, plexus)
podping_write_axon = Axon(podping_write_neuron, plexus)
await podping_hive_transaction_axon.react(
reactants=(podping_hive_transaction_reaction,),
)
await plexus.adapt(podping_write_neuron)
await podping_write_axon.adapt()

start_time = timer()
diag_time = timer()
Expand All @@ -101,7 +103,7 @@ async def endless_send_loop():
reason: PodpingReason = random.sample(sorted(reasons), 1)[0]
podping_write = PodpingWrite(medium=medium, reason=reason, iri=iri)

await plexus.transmit(podping_write)
await podping_write_axon.transmit(podping_write)

metrics["iris_sent"] = metrics["iris_sent"] + 1000

Expand Down
2,025 changes: 1,121 additions & 904 deletions poetry.lock

Large diffs are not rendered by default.

15 changes: 8 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
name = "podping-hivewriter"
version = "2.0.0"
license = "MIT"
authors = ["Alecks Gates <[email protected]>", "Brian of London <[email protected]>"]
maintainers = ["Alecks Gates <[email protected]>", "Brian of London <[email protected]>"]
authors = ["Alecks Gates <[email protected]>", "Brian of London <[email protected]>"]
maintainers = ["Alecks Gates <[email protected]>", "Brian of London <[email protected]>"]
readme = "README.md"
description = "This is a tool used to submit RFC 3987-compliant International Resource Identifiers as a Podping notification on the Hive blockchain."
homepage = "http://podping.org/"
Expand All @@ -19,17 +19,18 @@ classifiers = [
]

[tool.poetry.dependencies]
python = "^3.8,<3.12"
python = "^3.9,<3.12"
cffi = "^1.14.5"
pydantic = "^1.9.0"
single-source = "^0.3.0"
rfc3987 = "^1.3.8"
asgiref = "^3.5"
typer = {extras = ["all"], version = "^0.3.2"}
capnpy-agates = { version = "^0.9.0", allow-prereleases = true }
capnpy = "^0.10.0"
lighthive = "^0.4.0"
plexo = {version = "1.0.0a8", allow-prereleases = true}
podping-schemas = {version = "^0.1.0a17", allow-prereleases = true}
plexo = {version = "1.0.0b1", allow-prereleases = true}
podping-schemas = "^0.1.0"
returns = "^0.22.0"


[tool.poetry.group.dev.dependencies]
Expand All @@ -55,7 +56,7 @@ requires = ["setuptools", "poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.black]
target-version = ['py38', 'py39', 'py310', 'py311']
target-version = ['py39', 'py310', 'py311']

[tool.isort]
profile = "black"
Expand Down
26 changes: 15 additions & 11 deletions src/podping_hivewriter/podping_hivewriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
import sys
import uuid
from datetime import datetime, timedelta, timezone
from functools import partial
from timeit import default_timer as timer
from typing import List, Optional, Set, Tuple, Union, Dict, Iterable

import rfc3987
from lighthive.client import Client
from lighthive.datastructures import Operation
from lighthive.exceptions import RPCNodeException
from plexo.axon import Axon
from plexo.ganglion.tcp_pair import GanglionZmqTcpPair
from plexo.plexus import Plexus
from podping_schemas.org.podcastindex.podping.podping import Podping
Expand All @@ -23,6 +23,7 @@
from podping_schemas.org.podcastindex.podping.podping_reason import (
PodpingReason,
)
from returns.curry import partial

from podping_hivewriter import __version__ as podping_hivewriter_version
from podping_hivewriter.async_context import AsyncContext
Expand Down Expand Up @@ -157,18 +158,20 @@ async def _startup(self):

logging.info(f"Hive account: @{self.server_account}")

await self.plexus.adapt(podping_hive_transaction_neuron)
await self.plexus.adapt(
podping_write_neuron,
self.podping_hive_transaction_axon = Axon(podping_hive_transaction_neuron, self.plexus)
self.podping_write_axon = Axon(podping_write_neuron, self.plexus)
self.podping_write_error_axon = Axon(podping_write_error_neuron, self.plexus)
await self.podping_hive_transaction_axon.adapt()
await self.podping_write_axon.react(
reactants=(
partial(
self._podping_write_reactant,
self.plexus,
self.podping_write_error_axon,
self.unprocessed_iri_queue,
),
),
)
await self.plexus.adapt(podping_write_error_neuron)
await self.podping_write_error_axon.adapt()

if self.zmq_service:
tcp_pair_ganglion = GanglionZmqTcpPair(
Expand All @@ -192,7 +195,7 @@ async def _startup(self):
)
)
self._add_task(
asyncio.create_task(self._iri_batch_handler_loop(self.iri_batch_queue))
asyncio.create_task(self._iri_batch_handler_loop(self.podping_hive_transaction_axon, self.iri_batch_queue))
)
self._add_task(
asyncio.create_task(
Expand Down Expand Up @@ -309,6 +312,7 @@ async def _hive_status_loop(self):

async def _iri_batch_handler_loop(
self,
podping_hive_transaction_axon: Axon[PodpingHiveTransaction],
iri_batch_queue: "asyncio.Queue[IRIBatch]",
):
"""Opens and watches a queue and sends notifications to Hive one by one"""
Expand Down Expand Up @@ -368,7 +372,7 @@ async def _iri_batch_handler_loop(
f"last_node: {last_node}"
)

await self.plexus.transmit(
await podping_hive_transaction_axon.transmit(
PodpingHiveTransaction(
podpings=podpings,
hiveTxId=response.hive_tx_id,
Expand Down Expand Up @@ -540,7 +544,7 @@ async def _unprocessed_iri_queue_handler(

@staticmethod
async def _podping_write_reactant(
plexus: Plexus,
podping_write_error_axon: Axon[PodpingWriteError],
unprocessed_iri_queue: "asyncio.Queue[PodpingWrite]",
podping_write: PodpingWrite,
_,
Expand All @@ -553,7 +557,7 @@ async def _podping_write_reactant(
podpingWrite=podping_write,
errorType=PodpingWriteErrorType.invalidIri,
)
await plexus.transmit(podping_write_error)
await podping_write_error_axon.transmit(podping_write_error)

async def send_podping(
self,
Expand All @@ -567,7 +571,7 @@ async def send_podping(
iri=iri,
)

await self.plexus.transmit(podping_write)
await self.podping_write_axon.transmit(podping_write)

async def num_operations_in_queue(self) -> int:
return (
Expand Down
10 changes: 6 additions & 4 deletions tests/integration/test_write_dry_run_empty_tx.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from platform import python_version as pv

import pytest
from plexo.axon import Axon
from plexo.plexus import Plexus
from podping_schemas.org.podcastindex.podping.podping_medium import (
PodpingMedium,
Expand Down Expand Up @@ -53,11 +54,12 @@ async def _podping_hive_transaction_reaction(
await tx_queue.put(transaction)

plexus = Plexus()
await plexus.adapt(
podping_hive_transaction_neuron,
podping_hive_transaction_axon = Axon(podping_hive_transaction_neuron, plexus)
podping_write_axon = Axon(podping_write_neuron, plexus)
await podping_hive_transaction_axon.react(
reactants=(_podping_hive_transaction_reaction,),
)
await plexus.adapt(podping_write_neuron)
await podping_write_axon.adapt()

host = "127.0.0.1"
port = 9979
Expand All @@ -80,7 +82,7 @@ async def _podping_hive_transaction_reaction(

podping_write = PodpingWrite(medium=medium, reason=reason, iri=iri)

await plexus.transmit(podping_write)
await podping_write_axon.transmit(podping_write)

tx = await tx_queue.get()

Expand Down
16 changes: 8 additions & 8 deletions tests/integration/test_write_plexus_multiple.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from typing import List

import pytest
from plexo.axon import Axon
from plexo.plexus import Plexus
from podping_schemas.org.podcastindex.podping.podping_medium import (
PodpingMedium,
Expand Down Expand Up @@ -65,12 +66,12 @@ async def _podping_hive_transaction_reaction(
await tx_queue.put(transaction)

plexus = Plexus()

await plexus.adapt(
podping_hive_transaction_neuron,
podping_hive_transaction_axon = Axon(podping_hive_transaction_neuron, plexus)
podping_write_axon = Axon(podping_write_neuron, plexus)
await podping_hive_transaction_axon.react(
reactants=(_podping_hive_transaction_reaction,),
)
await plexus.adapt(podping_write_neuron)
await podping_write_axon.adapt()

host = "127.0.0.1"
port = 9979
Expand All @@ -94,7 +95,7 @@ async def _podping_hive_transaction_reaction(

for iri in test_iris:
podping_write = PodpingWrite(medium=medium, reason=reason, iri=iri)
await plexus.transmit(podping_write)
await podping_write_axon.transmit(podping_write)

# Sleep until all items in the queue are done processing
num_iris_processing = await podping_hivewriter.num_operations_in_queue()
Expand Down Expand Up @@ -181,16 +182,15 @@ async def _podping_hive_transaction_reaction(
) as podping_hivewriter:
await podping_hivewriter.wait_startup()

await podping_hivewriter.plexus.adapt(
podping_hive_transaction_neuron,
await podping_hivewriter.podping_hive_transaction_axon.react(
reactants=(_podping_hive_transaction_reaction,),
)

op_period = settings_manager._settings.hive_operation_period

for iri in test_iris:
podping_write = PodpingWrite(medium=medium, reason=reason, iri=iri)
await podping_hivewriter.plexus.transmit(podping_write)
await podping_hivewriter.podping_write_axon.transmit(podping_write)

# Sleep until all items in the queue are done processing
num_iris_processing = await podping_hivewriter.num_operations_in_queue()
Expand Down
15 changes: 8 additions & 7 deletions tests/integration/test_write_plexus_single.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from platform import python_version as pv

import pytest
from plexo.axon import Axon
from plexo.plexus import Plexus
from podping_schemas.org.podcastindex.podping.podping_medium import (
PodpingMedium,
Expand Down Expand Up @@ -58,11 +59,12 @@ async def _podping_hive_transaction_reaction(
await tx_queue.put(transaction)

plexus = Plexus()
await plexus.adapt(
podping_hive_transaction_neuron,
podping_hive_transaction_axon = Axon(podping_hive_transaction_neuron, plexus)
podping_write_axon = Axon(podping_write_neuron, plexus)
await podping_hive_transaction_axon.react(
reactants=(_podping_hive_transaction_reaction,),
)
await plexus.adapt(podping_write_neuron)
await podping_write_axon.adapt()

host = "127.0.0.1"
port = 9979
Expand All @@ -84,7 +86,7 @@ async def _podping_hive_transaction_reaction(

podping_write = PodpingWrite(medium=medium, reason=reason, iri=iri)

await plexus.transmit(podping_write)
await podping_write_axon.transmit(podping_write)

iri_found = False

Expand Down Expand Up @@ -155,14 +157,13 @@ async def _podping_hive_transaction_reaction(
) as podping_hivewriter:
await podping_hivewriter.wait_startup()

await podping_hivewriter.plexus.adapt(
podping_hive_transaction_neuron,
await podping_hivewriter.podping_hive_transaction_axon.react(
reactants=(_podping_hive_transaction_reaction,),
)

podping_write = PodpingWrite(medium=medium, reason=reason, iri=iri)

await podping_hivewriter.plexus.transmit(podping_write)
await podping_hivewriter.podping_write_axon.transmit(podping_write)

iri_found = False

Expand Down
3 changes: 1 addition & 2 deletions tests/integration/test_write_send_podping_multiple.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ async def _podping_hive_transaction_reaction(
) as podping_hivewriter:
await podping_hivewriter.wait_startup()

await podping_hivewriter.plexus.adapt(
podping_hive_transaction_neuron,
await podping_hivewriter.podping_hive_transaction_axon.react(
reactants=(_podping_hive_transaction_reaction,),
)

Expand Down
4 changes: 1 addition & 3 deletions tests/integration/test_write_send_podping_single.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from podping_hivewriter.models.hive_operation_id import HiveOperationId
from podping_hivewriter.models.medium import mediums
from podping_hivewriter.models.reason import reasons
from podping_hivewriter.neuron import podping_hive_transaction_neuron
from podping_hivewriter.podping_hivewriter import PodpingHivewriter
from podping_hivewriter.podping_settings_manager import PodpingSettingsManager
from podping_schemas.org.podcastindex.podping.hivewriter.podping_hive_transaction import (
Expand Down Expand Up @@ -67,8 +66,7 @@ async def _podping_hive_transaction_reaction(
) as podping_hivewriter:
await podping_hivewriter.wait_startup()

await podping_hivewriter.plexus.adapt(
podping_hive_transaction_neuron,
await podping_hivewriter.podping_hive_transaction_axon.react(
reactants=(_podping_hive_transaction_reaction,),
)

Expand Down
10 changes: 6 additions & 4 deletions tests/integration/test_write_zmq_multiple.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from typing import List

import pytest
from plexo.axon import Axon
from plexo.ganglion.tcp_pair import GanglionZmqTcpPair
from plexo.plexus import Plexus

Expand Down Expand Up @@ -84,17 +85,18 @@ async def _podping_hive_transaction_reaction(
),
)
plexus = Plexus(ganglia=(tcp_pair_ganglion,))
await plexus.adapt(
podping_hive_transaction_neuron,
podping_hive_transaction_axon = Axon(podping_hive_transaction_neuron, plexus)
podping_write_axon = Axon(podping_write_neuron, plexus)
await podping_hive_transaction_axon.react(
reactants=(_podping_hive_transaction_reaction,),
)
await plexus.adapt(podping_write_neuron)
await podping_write_axon.adapt()

op_period = settings_manager._settings.hive_operation_period

for iri in test_iris:
podping_write = PodpingWrite(medium=medium, reason=reason, iri=iri)
await plexus.transmit(podping_write)
await podping_write_axon.transmit(podping_write)

# Sleep until all items in the queue are done processing
num_iris_processing = await podping_hivewriter.num_operations_in_queue()
Expand Down
Loading

0 comments on commit 4f769c4

Please sign in to comment.