Skip to content

Lightweight server for testing equivalence of two symbolic expressions.

License

Notifications You must be signed in to change notification settings

isaacphysics/equality-checker

Repository files navigation

equality-checker

equality-checker Tests codecov

A not-quite-so-tiny-any-more server for testing the equivalence of two algebraic expressions using SymPy.

This project now uses Python 3. The last version using Python 2.7 was v0.8.0.

Development Setup Instructions

Simple Setup

  1. Install Python 3.10
  2. Clone this repository
  3. Run pip install -r requirements.txt
  4. Run python server\api.py

Your server should be running at http://localhost:5000/check. Now make JSON-based POST requests with target and test expression strings, e.g.

{
    "target": "x + 3",
    "test": "3 + x",
    "description": "An optional description for the logs!"
}

which will get a response like:

{
    "equal": "true",
    "equality_type": "exact",
    "parsed_target": "x + 3",
    "parsed_test": "x + 3",
    "target": "x + 3",
    "test": "3 + x"
}

or, if something went wrong, an error like:

{
    "error": "Some error message here",
    ...
}

Docker Setup

To develop the Docker container as well:

  1. Install Docker
  2. Run docker build -t ucamcldtg/equality-checker --pull .
  3. Test using docker run -p 5000:5000 -it ucamcldtg/equality-checker rather than running Python locally
  4. Optionally deploy to dockerhub: docker push ucamcldtg/equality-checker (requires authentication)

Production Use

The Docker container is available from dockerhub by running: docker pull ucamcldtg/equality-checker or by listing it as an image in a Docker Compose file. Port 5000 of the container will need to be mapped to the port the checker is expected to listen on.

For instance, run:

docker run -d -p 5000:5000 --name equality-checker ucamcldtg/equality-checker

To see live output:

docker logs -f equality-checker