Skip to content

Refactored scripts location #815

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/build-and-run-tests-from-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ jobs:
- name: Run monitoring
run: |
echo Find your Prometheus metrics using label {instance=\"${GITHUB_RUN_ID}-${HOSTNAME}\"}
chmod +x ./scripts/monitoring.sh
./scripts/monitoring.sh ${{ secrets.PUSHGATEWAY_HOSTNAME }} ${{ secrets.PUSHGATEWAY_USER }} ${{ secrets.PUSHGATEWAY_PASSWORD }}
chmod +x ./scripts/project/monitoring.sh
./scripts/project/monitoring.sh ${{ secrets.PUSHGATEWAY_HOSTNAME }} ${{ secrets.PUSHGATEWAY_USER }} ${{ secrets.PUSHGATEWAY_PASSWORD }}
- name: Run tests
run: |
gradle --no-daemon :utbot-framework:test ${{ matrix.project.TESTS_TO_RUN }}
Expand Down Expand Up @@ -131,8 +131,8 @@ jobs:
- name: Run monitoring
run: |
echo Find your Prometheus metrics using label {instance=\"${GITHUB_RUN_ID}-${HOSTNAME}\"}
chmod +x ./scripts/monitoring.sh
./scripts/monitoring.sh ${{ secrets.PUSHGATEWAY_HOSTNAME }} ${{ secrets.PUSHGATEWAY_USER }} ${{ secrets.PUSHGATEWAY_PASSWORD }}
chmod +x ./scripts/project/monitoring.sh
./scripts/project/monitoring.sh ${{ secrets.PUSHGATEWAY_HOSTNAME }} ${{ secrets.PUSHGATEWAY_USER }} ${{ secrets.PUSHGATEWAY_PASSWORD }}
- name: Run tests
run: |
cd ${{ matrix.project }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/run-chosen-tests-from-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ jobs:
- name: Run monitoring
run: |
echo Find your Prometheus metrics using label {instance=\"${GITHUB_RUN_ID}-${HOSTNAME}\"}
chmod +x ./scripts/monitoring.sh
./scripts/monitoring.sh ${{ secrets.PUSHGATEWAY_HOSTNAME }} ${{ secrets.PUSHGATEWAY_USER }} ${{ secrets.PUSHGATEWAY_PASSWORD }}
chmod +x ./scripts/project/monitoring.sh
./scripts/project/monitoring.sh ${{ secrets.PUSHGATEWAY_HOSTNAME }} ${{ secrets.PUSHGATEWAY_USER }} ${{ secrets.PUSHGATEWAY_PASSWORD }}

- name: Run chosen tests
run: |
Expand Down
6 changes: 3 additions & 3 deletions docs/jlearch/pipeline-training-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ Briefly:
To do this, you should:
* Be sure that you use `Java 8` by `java` command and set `JAVA_HOME` to `Java 8`.
* Put projects, on which you want to learn in `contest_input/projects` folder, then list classes, on which you want to learn in `contest_input/classes/<project name>/list` (if it is empty, than we will take all classes from project jar).
* Run `pip install -r scripts/requirements.txt`. It is up to you to make it in virtual environment or not.
* List selectors in `scripts/selector_list` and projects in `scripts/prog_list`
* Run `./scripts/train_iteratively.sh `
* Run `pip install -r scripts/ml/requirements.txt`. It is up to you to make it in virtual environment or not.
* List selectors in `scripts/ml/selector_list` and projects in `scripts/ml/prog_list`
* Run `./scripts/ml/train_iteratively.sh `
10 changes: 5 additions & 5 deletions docs/jlearch/scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ For each scenario: go to root of `UTBotJava` repository - it is `WORKDIR`.

Before start of work run:
```bash
./scripts/prepare.sh
./scripts/ml/prepare.sh
```

It will copy contest resources in `contest_input` folder and build the project, because we use jars, so if you want to change something in code and re-run scripts, then you should run:
Expand All @@ -16,11 +16,11 @@ It will copy contest resources in `contest_input` folder and build the project,
## To Train a few iterations of your models:
By default features directory is `eval/features` - it should be created, to change it you should manually do it in source code of scripts.

List projects and selectors on what you want to train in `scripts/prog_list` and `scripts/selector_list`. You will be trained on all methods of all classes from `contest_input/classes/<project name>/list`.
List projects and selectors on what you want to train in `scripts/ml/prog_list` and `scripts/selector_list`. You will be trained on all methods of all classes from `contest_input/classes/<project name>/list`.

Then just run:
```bash
./scripts/train_iteratively.sh <time_limit> <iterations> <output_dir> <python_command>
./scripts/ml/train_iteratively.sh <time_limit> <iterations> <output_dir> <python_command>
```
Python command is your command for python3, in the end of execution you will get iterations models in `<output_dir>` folder and features for each selector and project in `<features_dir>/<selector>/<project>` for `selector` from `selectors_list` and in `<features_dir>/jlearch/<selector>/<prog>` for models.

Expand All @@ -29,15 +29,15 @@ Check that `srcTestDir` with your project exist in `build.gradle` of `utbot-juni

Then just run:
```bash
./scripts/run_with_coverage.sh <project> <time_limit> <path_selector> <selector_alias>
./scripts/ml/run_with_coverage.sh <project> <time_limit> <path_selector> <selector_alias>
```

In the end of execution you will get jacoco report in `eval/jacoco/<project>/<selector_alias>/` folder.

## To estimate quality
Just run:
```bash
./scripts/quality_analysis.sh <project> <selector_aliases, separated by comma>
./scripts/ml/quality_analysis.sh <project> <selector_aliases, separated by comma>
```
It will take coverage reports from relative report folders (at `eval/jacoco/project/alias`) and generate charts in `$outputDir/<project>/<timestamp>.html`.
`outputDir` can be changed in `QualityAnalysisConfig`. Result file will contain information about 3 metrics:
Expand Down
14 changes: 7 additions & 7 deletions docs/jlearch/setup.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# How to setup environment for experiments on Linux

* Clone repository, go to root
* `chmod +x ./scripts/*` and `chmod +x gradlew`.
* `chmod +x ./scripts/ml/*` and `chmod +x gradlew`.
* Set `Java 8` as default and set `JAVA_HOME` to this `Java`.
For example
* Go through [this](https://sdkman.io/install) until `Windows installation`
Expand All @@ -17,19 +17,19 @@
* `python3 -m venv /path/to/new/virtual/environment`
* `source /path/to/venv/bin/activate`
* Check `which python3`, it should be somewhere in `path/to/env` folder.
* `pip install -r scripts/requirements.txt`
* `./scripts/prepare.sh`
* Change `scripts/prog_list` to run on smaller project or delete some classes from `contest_input/classes/<project>/list`.
* `pip install -r scripts/ml/requirements.txt`
* `./scripts/ml/prepare.sh`
* Change `scripts/ml/prog_list` to run on smaller project or delete some classes from `contest_input/classes/<project>/list`.

# Default settings and how to change it
* You can reduce number of models in `models` variable in `scripts/train_iteratively.sh`
* You can reduce number of models in `models` variable in `scripts/ml/train_iteratively.sh`
* You can change amount of required RAM in `run_contest_estimator.sh`: `16 gb` by default
* You can change `batch_size` or `device` n `train.py`: `4096` and `gpu` by default
* If you are completing setup on server, then you will need to uncomment tmp directory option in `run_contest_estimator.sh`

# Continue setup
* `scripts/train_iteratively.sh 30 2 models <your python3 command>`
* `scripts/ml/train_iteratively.sh 30 2 models <your python3 command>`
* In `models/` you should get models.
* `mkdir eval/jacoco`
* `./scripts/run_with_coverage.sh <any project (guava-26.0, for example)> 30 "NN_REWARD_GUIDED_SELECTOR path/to/model" some_alias`. `path/to/model` should be something like `models/nn32/0`, where `nn32` is a type of model and `0` is the iteration number
* `./scripts/ml/run_with_coverage.sh <any project (guava-26.0, for example)> 30 "NN_REWARD_GUIDED_SELECTOR path/to/model" some_alias`. `path/to/model` should be something like `models/nn32/0`, where `nn32` is a type of model and `0` is the iteration number
* You should get jacoco report in `eval/jacoco/guava-26.0/some_alias/`
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if [[ -n $COVERAGE_PROCESSING ]]; then
fi

WORKDIR="."
$WORKDIR/scripts/run_contest_estimator.sh $PROJECT $TIME_LIMIT "$PATH_SELECTOR" "" "$COVERAGE_PROCESSING"
$WORKDIR/scripts/ml/run_contest_estimator.sh $PROJECT $TIME_LIMIT "$PATH_SELECTOR" "" "$COVERAGE_PROCESSING"

./gradlew :utbot-junit-contest:test :utbot-junit-contest:jacocoTestReport

Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions scripts/train_data.sh → scripts/ml/train_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ while read prog; do
while read selector; do
echo "Starting features collection from $prog with $selector"
selector="${selector%%[[:cntrl:]]}"
$WORKDIR/scripts/run_contest_estimator.sh "$prog" "$TIME_LIMIT" "$selector" true
done <"$WORKDIR/scripts/selector_list"
done <"$WORKDIR/scripts/prog_list"
$WORKDIR/scripts/ml/run_contest_estimator.sh "$prog" "$TIME_LIMIT" "$selector" true
done <"$WORKDIR/scripts/ml/selector_list"
done <"$WORKDIR/scripts/ml/prog_list"
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ WORKDIR="."

echo "Start training data on heuristical based selectors"

$WORKDIR/scripts/train_data.sh $TIME_LIMIT
$WORKDIR/scripts/ml/train_data.sh $TIME_LIMIT

echo "Start iterative learning of models"

Expand All @@ -28,7 +28,7 @@ do
echo "EXTRA_ARGS=$EXTRA_ARGS"
fi

COMMAND="$PYTHON_COMMAND $WORKDIR/scripts/train.py --features_dir $WORKDIR/eval/features --output_dir $OUTPUT_DIR/$model/$i --prog_list $WORKDIR/scripts/prog_list --model $model $EXTRA_ARGS"
COMMAND="$PYTHON_COMMAND $WORKDIR/scripts/ml/train.py --features_dir $WORKDIR/eval/features --output_dir $OUTPUT_DIR/$model/$i --prog_list $WORKDIR/scripts/prog_list --model $model $EXTRA_ARGS"
echo "TRAINING COMMAND=$COMMAND"
$COMMAND
done
Expand All @@ -44,7 +44,7 @@ do
PREDICTOR="LINEAR"
fi

$WORKDIR/scripts/run_contest_estimator.sh $prog $TIME_LIMIT "NN_REWARD_GUIDED_SELECTOR $OUTPUT_DIR/$model/$i $PREDICTOR" "true eval/features/jlearch/$model$i/$prog"
$WORKDIR/scripts/ml/run_contest_estimator.sh $prog $TIME_LIMIT "NN_REWARD_GUIDED_SELECTOR $OUTPUT_DIR/$model/$i $PREDICTOR" "true eval/features/jlearch/$model$i/$prog"
done
done <"$WORKDIR/scripts/prog_list"
done <"$WORKDIR/scripts/ml/prog_list"
done
4 changes: 2 additions & 2 deletions scripts/monitoring.sh → scripts/project/monitoring.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ if ! netstat -tulpn | grep -q ${PORT_NODE_EXPORTER} ; then
fi

# custom java processes memory metrics
chmod +x scripts/ps_parser.sh
chmod +x scripts/project/ps_parser.sh
while true; do
./scripts/ps_parser.sh | curl -u "${PUSHGATEWAY_USER}":"${PUSHGATEWAY_PASSWORD}" --data-binary @- "https://${PUSHGATEWAY_HOSTNAME}${PUSHGATEWAY_ADDITIONAL_PATH}/metrics/job/pushgateway/instance/${GITHUB_RUN_ID}-${HOSTNAME}${PROM_ADDITIONAL_LABELS}" 2>/dev/null
./scripts/project/ps_parser.sh | curl -u "${PUSHGATEWAY_USER}":"${PUSHGATEWAY_PASSWORD}" --data-binary @- "https://${PUSHGATEWAY_HOSTNAME}${PUSHGATEWAY_ADDITIONAL_PATH}/metrics/job/pushgateway/instance/${GITHUB_RUN_ID}-${HOSTNAME}${PROM_ADDITIONAL_LABELS}" 2>/dev/null
sleep ${SLEEP_TIME_SECONDS}
done &

Expand Down
File renamed without changes.