XanaduAI / strawberryfields

Strawberry Fields is a full-stack Python library for designing, simulating, and optimizing continuous variable (CV) quantum optical circuits.
https://strawberryfields.ai
Apache License 2.0
745 stars 187 forks source link

CI tests without TensorFlow installed #641

Closed thisac closed 2 years ago

thisac commented 2 years ago

Feature details

Add a CI action that runs the relevant tests in an environment without TensorFlow installed.

Currently, no tests are being run without TensorFlow installed (with the exception of some specific tests where TensorFlow is in some way mocked). This makes it easy to mistakenly add code that is dependent on TensorFlow to core Strawberry Fields, which doesn't have TensorFlow as a requirement.

Example: Importing a function from the TensorFlow backend into other parts of Strawberry Fields would bypass the check for whether TensorFlow is installed or not. For example, adding the following in strawberryfields/__init__.py would implicitely try to import TensorFlow each time Strawberry Fields is imported (e.g., import strawberryfields as sf):

# strawberryfields/__init__.py
from tensorflow.backends.ops import update_symplectic

Implementation

Add a GitHub action that creates an environment without TensorFlow installed, and runs the parts of the test suite that do not depend on TensorFlow. This should be run on each push to PR and merge.

How important would you say this feature is?

1: Not important. Would be nice to have.

Additional information

Front-end tests have recently been fixed to be able to run without TensorFlow (#639).