Skip to content

CLI Mode (Advanced Usage)

Glopix edited this page Jun 28, 2024 · 4 revisions

CLI Mode

The platform also supports interaction through a Command-Line Interface (CLI), allowing users to start or stop a run by specifying benchmarks and detector tools, and ensures the necessary configuration files are in place before executing the run.

⚠️ Please note:
As the web interface is the recommended and originally only intended method of interaction, the CLI mode has limited functionality. Additionally, the CLI mode has fewer input checks and may be more prone to errors.
It requires you to manually edit the configuration files for each clone detector tool and benchmark before initiating a run via the CLI.

Prerequisites

Ensure you have the Cloreco platform up and running without errors. Start a run via the web interface to make sure.

All containers/services from the docker compse file need to be executed.

Usage

Starting a Run

docker exec <docker container name> ./cli.py start   \ 
 --benchmarks <benchmark1> [<benchmark2> ...]        \
 --detector-tools <tool1> [<tool2> ...]              \
 --directory <path/to/configuration>                 \
 [--run-name <RunName>]

Example:
(if the container is named 'cloreco-web-1')

docker exec cloreco-web-1 ./cli.py start                 \ 
 --benchmarks BigCloneEval                               \
 --detector-tools StoneDetector NiCad                    \
 --directory /app/data/cloneDetection/CLI_run_template/  \
 --run-name myRun2

Note: You can find the container name by running docker ps and looking for the container associated with the image "ghcr.io/glopix/cloreco/cloreco-frontend".

Options

Options short description Required
command The action to perform. Either start to initiate a run or stop to abort a run. Yes
--benchmarks Space-separated list of benchmarks to execute. Yes
--detector-tools Space-separated list of clone detector tools to execute. Yes
--directory The path to the directory containing configuration files for benchmarks and detector tools. Please see the notes below. Yes
--run-name The name to assign to the run. No, optional

--benchmarks and --detector-tools option

The benchmarks and clone detector tools must be available in your platform instance. This means that for each benchmark and clone detector tool, the corresponding template files need to exist in the data/cloneDetection/cloneDetectorTools/workbench/ and data/cloneDetection/benchmarks directories, respectively.

Use the exact names of these templates when specifying them in the options. For example, to run the clone detector defined in the data/cloneDetection/cloneDetectorTools/workbench/Sourcerer-CC.cfg.web.template file, you should use --detector-tools Sourcerer-CC.

--directory option

The directory specified by the --directory option, which contains configuration files for benchmarks and detector tools, must follow the same structure as a run directory. The contents of this directory will be copied into a new run directory and used for your newly started run.

The path IN the container need to be specified, so if your directory is at data/cloneDetection/myDir, you need to enter /app/data/cloneDetection/myDir. This directory must be located somewhere below the mounted data directory. You need to prepend /app/ to its path, as the data directory in your installation directory (where the Docker Compose file is stored) is mounted into the container at /app/data/.

You can use data/cloneDetection/CLI_run_template/ as a reference template. Alternatively, you can start a run via the web interface and copy the resulting run directory, or modify the configuration in a run directory from a past run and specify this as the --directory option.

Stopping a Run

docker exec <docker container name> ./cli.py stop

Example:
(if the container is named 'cloreco-web-1')

docker exec cloreco-web-1 ./cli.py stop
Clone this wiki locally