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
754 stars 191 forks source link

Refactoring the starship CLI and adding unit tests #312

Closed antalszava closed 4 years ago

antalszava commented 4 years ago

Context: The command line interface (CLI), starship has a few options which can be used. However, its functionality can be extended and tests need to be included such that most caveats for bugs are covered.

In terms of portability, the idea is to keep the command line interface platform independent.

Description of the Change: Created a fixed CLI structure where there are two main types of options:

In more details this looks as follows: There are two general options: --help and --ping, in more details:

starship: returns the help menu
starship --help: returns the help menu
starship --ping: tests the connection to the remote backend

There are two commands: configure and run, in more details:

Configure

starship configure [--local]: interactive wizard
starship configure [--local] --token: only the authentication token with default configurations
(in both cases the --local option creates the configuration file locally)

Run

starship run bbscript.xbb: run a blackbird script
starship run bbscript.xbb --ouput myhome/mydirectory/myresult.txt: run a blackbird script and store the result

In terms of code structure, the ability to create unit tests was regarded (as an example, suggestions on how to write tests for the argparse method were followed).

Benefits:

The idea behind separating the previously mentioned two groups:

In terms of functionality, users can:

Possible Drawbacks: To have General options appear when the help menu is queried, the protected member _optionals of the ArgumentParser class was set. This was the best solution to be found for this task; caution must be taken in case the implementation of the ArgumentParser class changes.

Related GitHub Issues: N/A

codecov[bot] commented 4 years ago

Codecov Report

Merging #312 into demo will not change coverage by %. The diff coverage is n/a.

@@           Coverage Diff           @@
##             demo     #312   +/-   ##
=======================================
  Coverage   97.66%   97.66%           
=======================================
  Files          50       50           
  Lines        6245     6245           
=======================================
  Hits         6099     6099           
  Misses        146      146           

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update b7a74bd...b7a74bd. Read the comment docs.