Skip to content

Traits Futures 0.2.0

Choose a tag to compare

@mdickinson mdickinson released this 24 Sep 07:35

This is a feature release of Traits Futures. The main features of this
release are:

  • Improved support for user-defined background task types.
  • Easier creation of background calculations that can be (cooperatively)
    cancelled mid-calculation.
  • Significant internal refactoring and cleanup, aimed at eventual support
    for alternative front ends (GUI event loops other than the Qt event
    loop) and back ends (e.g., multiprocessing).
  • Improved and expanded documentation.

There are no immediately API-breaking changes in this release: existing working
code using Traits Futures 0.1.1 should continue to work with no changes
required. However, some parts of the existing API have been deprecated, and
will be removed in a future release. See the Changes section below for more
details.

Detailed changes follow. Note that the list below is not exhaustive: many
more minor PRs have been omitted.

Features

  • Users can now easily create their own background task types to supplement
    the provided task types (background calls, background iterations and
    background progress). A combination of a new ITaskSpecification
    interface and a convenience BaseFuture base class support this.
    (#198)
  • The submit_iteration function now supports generator functions that
    return a result. This provides an easy way to submit background computations
    that can be cancelled mid-calculation. (#167)
  • The TraitsExecutor class now accepts a max_workers argument,
    which specifies the maximum number of workers for a worker pool created
    by the executor. (#125)
  • There are new task submission functions submit_call,
    submit_iteration and submit_progress. These functions replace
    the eponymous existing TraitsExecutor methods, which are now
    deprecated. (#166)
  • There's a new IFuture interface class in the
    traits_futures.api module, to aid in typing and Trait declarations.
    (#169)
  • A new IParallelContext interface supports eventual addition
    of alternative back ends. The new MultithreadingContext class
    implements this interface and provides the default threading back-end.
    (#149)

Changes

  • The state trait on CallFuture, IterationFuture and ProgressFuture is
    now read-only. It used to be writable.
  • The default number of workers in an owned worker pool (that is, a worker pool
    created by a TraitsExecutor) has changed. Previously it was
    hard-coded as 4. Now it defaults to whatever Python's
    concurrent.futures executors give, but can be controlled by passing
    the max_workers argument. (#125)
  • The submit_call, submit_iteration and submit_progress
    methods on the TraitsExecutor have been deprecated. Use the
    submit_call, submit_iteration and submit_progress
    convenience functions instead. (#159)
  • The thread_pool argument to TraitsExecutor has been renamed
    to worker_pool. The original name is still available for backwards
    compatibility, but its use is deprecated. (#144, #148)
  • Python 2.7 is no longer supported. Traits Futures requires Python >= 3.5,
    and has been tested with Python 3.5 through Python 3.9. (#123, #130, #131,
    #132, #133, #138, #145)

Fixes

  • Don't create a new MessageRouter at executor shutdown time. (#187)

Tests

  • Fix some intermittent test failures due to test interactions. (#176)
  • The 'null' backend that's used for testing in the absence of a Qt backend
    now uses a asyncio-based event loop instead of a custom event loop.
    (#107, #179)
  • Rewrite the Qt GuiTestAssistant to react rather than polling. This
    significantly speeds up the test run. (#153)
  • Ensure that all tests properly stop the executors they create. (#108, #146)
  • Refactor the test structure in preparation for multiprocessing
    support. (#135, #141)
  • Test the GuiTestAssistant class. (#109)

Developer tooling

  • Add a new python -m ci shell click cmd. (#204)
  • Update edm version in CI. (#205)
  • Add checks for missing or malformed copyright headers in Python files (and
    fix existing copyright headers). (#193)
  • Add import order checks (and fix existing import order bugs). (#161)
  • Add separate "build" and "ci" modes for setting up the development
    environment. (#104)
  • Don't pin dependent packages in the build environment. (#99)

Documentation

  • Update docs to use the Enthought Sphinx Theme. (#128)
  • Autogenerated API documentation is now included in the documentation
    build. (#177, #181)
  • Restructure the documentation to avoid nesting 'User Guide'
    under 'User Documentation'. (#191)
  • Document creation of new background task types. (#198)
  • Document use of submit_iteration for interruptible tasks. (#188)