v1.0.0-rc.1
Pre-releaseFrequenz channels Release Notes
Summary
This is the first release candidate for version 1.0. It includes few new features and a lot of cleanups and API improvements and polishing. Because of this, there are a lot of breaking changes too, but they should be easy to fix, as they ae mostly renames and reorganizations.
We hope this is the final pre-release before the final 1.0 release, and we don't expect to introduce any further breaking changes. Because of this we encourage you to test it and report any issues you find. You can also use a version constraint like >= 1.0.0-rc.1, < 2.0.0 as the final version should be compatible.
Upgrading
-
Anycast-
__init__: Themaxsizeargument was renamed tolimitand made keyword-only and a new keyword-onlynameargument was added.You should instantiate using
Anycast(name=..., limit=...)(orAnycast(name=...)if the defaultlimitis enough) instead ofAnycast(...)orAnycast(maxsize=...). -
new_senderandnew_receiver: They now return a baseSenderandReceiverclass (respectively) instead of a channel-specificSenderorReceiversubclass.This means users now don't have access to the internals to the channel-specific
SenderandReceiversubclasses.
-
-
Broadcast-
__init__: Thenameargument was made optional and keyword-only;resend_latestwas also made keyword-only. If anameis not specified, it will be generated from theid()of the instance.You should instantiate using
Broadcast(name=name, resend_latest=resend_latest)(orBroadcast()if the defaults are enough) instead ofBroadcast(name)orBroadcast(name, resend_latest). -
new_receiver: Themaxsizeargument was renamed tolimitand made keyword-only; thenameargument was also made keyword-only. If anameis not specified, it will be generated from theid()of the instance instead of a random UUID.You should use
.new_receiver(name=name, limit=limit)(or.new_receiver()if the defaults are enough) instead of.new_receiver(name)or.new_receiver(name, maxsize). -
new_senderandnew_receivernow return a baseSenderandReceiverclass (respectively) instead of a channel-specificSenderorReceiversubclass.This means users now don't have access to the internals to the channel-specific
SenderandReceiversubclasses.
-
-
Event-
__init__: Thenameargument was made keyword-only. The default was changed to a more readable version ofid(self).You should instantiate using
Event(name=...)instead ofEvent(...). -
Moved from
frequenz.channels.utiltofrequenz.channels.event.
-
-
FileWatcher-
Moved from
frequenz.channels.utiltofrequenz.channels.file_watcher. -
Support classes are no longer nested inside
FileWatcher. They are now top-level classes within the newfrequenz.channels.file_watchermodule (e.g.,frequenz.channels.util.FileWatcher.EventType->frequenz.channels.file_watcher.EventType,frequenz.channels.util.FileWatcher.Event->frequenz.channels.file_watcher.Event).
-
-
Receiver- The
map()function now takes a positional-only argument, if you were usingreceiver.map(call=fun)you should replace it withreceiver.map(func).
- The
-
SelectErrornow inherits fromchannels.Errorinstead ofBaseException, so you should be able to catch it withexcept Exception:orexcept channels.Error:. -
Selected- The
valueproperty was renamed tomessage. was_stoppedis now a property, you need to replaceselected.was_stopped()withselected.was_stopped.
- The
-
Sender- The
sendmethod now takes a positional-only argument, if you were usingsender.send(msg=message)you should replace it withsender.send(message).
- The
-
Timerand support classes- Moved from
frequenz.channels.utiltofrequenz.channels.timer.
- Moved from
-
All exceptions that took
Anyas themessageargument now takestrinstead.If you were passing a non-
strvalue to an exception, you should convert it usingstr(value)before passing it to the exception. -
The following symbols were moved to the top-level
frequenz.channelspackage:SelectedSelectErrorUnhandledSelectedErrorselectselected_from
Removals
-
BidirectionalThis channel was removed as it is not recommended practice and was a niche use case. If you need to use it, you can set up two channels or copy the
Bidirectionalclass from the previous version to your project. -
MergeReplaced by the new
merge()function. When replacingMergewithmerge()please keep in mind that this new function will raise aValueErrorif no receivers are passed to it.Please note that the old
Mergeclass is still also available but it was renamed toMergerto avoid confusion with the newmerge()function, but it is only present for typing reasons and should not be used directly. -
MergeNamedThis class was redundant, use either the new
merge()function orselect()instead. -
PeekableThis class was removed because it was merely a shortcut to a receiver that caches the last message received. It did not fit the channel abstraction well and was infrequently used.
You can replace it with a task that receives and retains the last message.
-
Broadcast.new_peekable()This was removed alongside
Peekable. -
Receiver.into_peekable()This was removed alongside
Peekable. -
ReceiverInvalidatedErrorThis was removed alongside
Peekable(it was only raised when using aReceiverthat was converted into aPeekable). -
SelectErrorGroupwas removed, a Python built-inBaseExceptionGroupis raised instead in case of unexpected errors while finalizing aselect()loop, which will be automatically converted to a simpleExceptionGroupwhen no exception in the groups is aBaseException.
-
Timer:-
periodic()andtimeout(): The names proved to be too confusing, please useTimer()and pass a missing ticks policy explicitly instead. In general you can update your code by doing:Timer.periodic(interval)/Timer.periodic(interval, skip_missed_ticks=True)->Timer(interval, TriggerAllMissed())Timer.periodic(interval, skip_missed_ticks=False)->Timer(interval, SkipMissedAndResync())Timer.timeout(interval)->Timer(interval, SkipMissedAndDrift())
-
-
utilThe entire
utilpackage was removed and its symbols were either moved to the top-level package or to their own public modules (as noted above).
New Features
-
A new User's Guide was added to the documentation and the documentation was greately improved in general.
-
A new
merge()function was added to replaceMerge. -
Anycast-
The following new read-only properties were added:
name: The name of the channel.limit: The maximum number of messages that can be sent to the channel.is_closed: Whether the channel is closed.
-
A more useful implementation of
__str__ andrepr` were added for the channel and its senders and receivers. -
A warning will be logged if senders are blocked because the channel buffer is full.
-
-
Bidirectional-
The following new read-only properties were added:
name: The name of the channel (read-only).is_closed: Whether the channel is closed (read-only).
-
A more useful implementation of
__str__ andrepr` were added for the channel and the client and service handles.
-
-
Broadcast-
The following new read-only properties were added:
name: The name of the channel.is_closed: Whether the channel is closed.
-
A more useful implementation of
__str__ andrepr` were added for the channel and the client and service handles.
-
-
FileWatcher- A more useful implementation of
__str__ andrepr` were added.
- A more useful implementation of
-
Peekable- A more useful implementation of
__str__ andrepr` were added.
- A more useful implementation of
-
Receivermap(): The returned map object now has a more useful implementation of__str__ andrepr`.
Improvements
-
Receiver,merge/Merger,Errorand its derived classes now use a covariant generic type, which allows the generic type to be broader than the actual type. -
Sendernow uses a contravariant generic type, which allows the generic type to be narrower than the required type. -
ChannelErroris now generic, so when accessing thechannelattribute, the type of the channel is preserved. -
The generated documentation / website was greatly improved, both in content and looks.
Bug Fixes
Timer: Fix bug that was causing calls toreset()to not reset the timer, if the timer was already being awaited.
What's Changed
- Update to repo-config v0.7.2 by @llucax in #230
- Bump the optional group with 5 updates by @dependabot in #229
- Clean up and improve the code and public interface by @llucax in #231
- Revamp modules structure by @llucax in #235
- Replace
MergeandMergeNamedwithmerge()by @llucax in #238 - Clear release notes by @llucax in #240
- Fix timer
reset()while it is being waited on by @llucax in #241 - Fix typo in comment by @llucax in #247
- Make
Mergepublic again and rename it toMergerby @llucax in #243 - Add some useful mkdocs extensions by @llucax in #244
- dependabot/pip/optional 62c46a5f26 by @Marenz in #255
- Add a User Guide by @llucax in #245
- Bump actions/setup-python from 4 to 5 by @dependabot in #257
- Bump the optional group with 10 updates by @dependabot in #261
- Support broadening or narrowing of types in
Receivers andSenders by @shsms in #262 Timer: Removeperiodic()andtimeout()by @llucax in #264- Bump actions/cache from 3 to 4 by @dependabot in #270
- Bump black from 23.12.1 to 24.1.1 by @dependabot in #269
- Bump flake8 from 6.1.0 to 7.0.0 by @dependabot in #267
- Bump types-markdown from 3.5.0.3 to 3.5.0.20240129 by @dependabot in #266
- Bump the optional group with 5 updates by @dependabot in #265
- Bump actions/labeler from 4.3.0 to 5.0.0 by @dependabot in #259
- Add a tip about the returned receiver type for
map()by @llucax in #271 - Remove boilerplate from examples in the user guide by @llucax in #276
- Bump the optional group with 9 updates by @dependabot in #277
- Bump actions/upload-artifact from 3 to 4 by @dependabot in #258
- Bump pytest from 7.4.4 to 8.1.0 by @dependabot in #278
- Use the new set of labels by @llucax in #274
- Enable and use GitHub Alert syntax for admonitions by @llucax in #275
- Improve documentation by @llucax in #279
- Rename "value" to "message" and other minor breaking changes by @llucax in #281
- Improve
select()-related exceptions by @llucax in #283 - Improve generics usage by @llucax in #282
- Prepare release notes for 1.0.0-rc.1 by @llucax in #284
Full Changelog: v1.0.0-beta.1...v1.0.0-rc.1