Skip to content
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

Make ROSE containers more friendly #485

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from 15 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
2 changes: 0 additions & 2 deletions .coveragerc

This file was deleted.

3 changes: 0 additions & 3 deletions .dockerignore

This file was deleted.

20 changes: 11 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v3
uses: actions/setup-python@v4
with:
python-version: "3.7"
python-version: |
3.7
3.9

- name: Install dependencies
run: |
pip install --upgrade pip
pip install -r requirements-dev.txt
run: make dev-init

- name: Lint
run: flake8 --show-source --statistics
- name: Blint
run: black --check --diff .
run: make lint

- name: Run tests
run: pytest
run: make test
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Python
__pycache__
*.pyc
.pytest_cache

# Editors
.idea
Expand All @@ -9,7 +11,8 @@
.coverage
htmlcov/

Pipfile.lock
rose_project.egg-info
dist

# Classroom setup
classroom/credentials.json
Expand Down
13 changes: 0 additions & 13 deletions .travis.yml

This file was deleted.

42 changes: 0 additions & 42 deletions Dockerfile

This file was deleted.

37 changes: 21 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
init: Pipfile
python -m pip install pipenv --user
pipenv install
init:
pip install -r rose/client/requirements.txt
pip install -r rose/server/requirements.txt

dev-init: Pipfile
python -m pip install pipenv --user
pipenv install --dev
dev-init: init
pip install -r rose/client/requirements-dev.txt
pip install -r rose/server/requirements-dev.txt

test: pytest.ini
pipenv run pytest
lint:
make -C rose/client lint
make -C rose/server lint

admin: rose-admin
pipenv run ./rose-admin
lint-fix:
make -C rose/client lint-fix
make -C rose/server lint-fix

server: rose-server
pipenv run ./rose-server
test:
make -C rose/client test
make -C rose/server test

client: rose-client
pipenv run ./rose-client
clean:
-find . -name '.coverage' -exec rm {} \;
-find . -name 'htmlcov' -exec rmdir {} \;
-find . -name '*.pyc' -exec rm {} \;
-find . -name '__pycache__' -exec rmdir {} \;
-find . -name '.pytest_cache' -exec rmdir {} \;

container-image:
podman build --build-arg DEV=True -t rose_dev .
71 changes: 34 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,31 +58,28 @@ The following commands should be performed only once; after creating the
environment you will be connecting to the same environment each time you
open a new session.

Use venv to create a virtual environment and to install the rest of
the dependencies:
## Cloning the Repository

python3 -m venv ~/.venv/rose
First, clone the ROSE repository from GitHub:

After creating the environment, we want to activate and enter our
environment (make sure you're in the ROSE directory):
```bash
git clone https://github.com/RedHat-Israel/ROSE.git
```

source ~/.venv/rose/bin/activate
Navigate to the cloned directory:

After entering the virtual enviornment we need to install the project dependencies:
```bash
cd ROSE
```

pip install -r requirements.txt
Once you're in the ROSE directory, install the project dependencies:

Indication that you are inside the environment, the prompt line will
look like this:

(rose) [username@hostname ROSE]$
```bash
pip install -r requirements.txt
```

## Running the server

If you are not in your virtual environment, please activate it:

source ~/.venv/rose/bin/activate

Start the server on some machine:

./rose-server
Expand All @@ -103,7 +100,7 @@ Build the Docker image:

Run the Docker image on port 8880:

podman run -it --rm --name=rose_server -p 8880:8880 rose_server python ./rose-server
podman run -it --rm --name=rose_server -p 8880:8880 rose_server

If you don't want to see the log of the run in the current window,
replace `-it` with `-d`.
Expand All @@ -128,15 +125,10 @@ server, and browse from a local machine in case port 8880 or 8888 are
blocked by [firewalld](https://firewalld.org/):

sudo firewall-cmd --add-port=8880/tcp --permanent
sudo firewall-cmd --add-port=8888/tcp --permanent
sudo firewall-cmd --reload

## Running a driver

In a new window, open your virtual environment:

source ~/.venv/rose/bin/activate

Create your driver file:

cp examples/none.py mydriver.py
Expand All @@ -146,16 +138,11 @@ name.

Start up the client, using your driver file:

./rose-client mydriver.py

The server address can be specified that way (Replace '10.20.30.44' with
your server address):

./rose-client -s 10.20.30.44 mydriver.py
./rose-client --driver mydriver.py

For running the driver on the Docker container use:

docker exec -it rose_server python ./rose-client examples/random-driver.py
docker exec -it rose_server --driver examples/random-driver.py

For driver modules, see the [examples](examples) directory.

Expand All @@ -176,6 +163,14 @@ To stop a race, use the rose-admin tool on any machine:

./rose-admin {server-address} stop

To reset a race, use the rose-admin tool on any machine:

./rose-admin {server-address} reset

To set drivers, use the rose-admin tool on any machine:

./rose-admin {server-address} set-drivers {URL of driver1} {URL of driver2}

To modify the game rate, you can use the "set-rate" command. The
following command would change game rate to 10 frames per second:

Expand Down Expand Up @@ -208,26 +203,28 @@ Example `tmux` commands:
Should you want to contribute to the project, please read the
[Code of Conduct](docs/code-of-conduct.md).

To create venv use:
Make sure you have python and make installed

# On fedora
dnf install python make

python3 -m venv ~/.venv/rose

To enter the venv:
Change directory to the application you want to work on:

source ~/.venv/rose/bin/activate
# For the client code
cd rose/client

To install development requirements:

pip install -r requirements-dev.txt

For development in docker, use:

docker build --build-arg DEV=True -t rose_dev .
make build-image

Before submitting patches, please run the tests:

flake8
pytest
make test
make lint

Creating coverage report in html format:

Expand Down
File renamed without changes.
Binary file removed examples/best_driver.pyc
Binary file not shown.
Binary file removed examples/score.pyc
Binary file not shown.
Binary file removed examples/zigzag.pyc
Binary file not shown.
10 changes: 5 additions & 5 deletions how_to_check_student_exercises.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

## Running the checks

First, make sure you are using python 3.7 or later:
First, change directory to test folder before running the tests:

`cd docs/course_materials/exercises/test_exercises

Make sure you are using python 3.7 or later:

`pipenv --python /usr/local/bin/python3.7 shell`

Install all dependencies:

`pipenv install --dev`

Second, change directory to test folder before running the tests:

`cd docs/course_materials/exercises/test_exercises`

For getting the Help use:

`python rose_check.py --help`
Expand Down
2 changes: 0 additions & 2 deletions pytest.ini

This file was deleted.

8 changes: 0 additions & 8 deletions requirements-dev.txt

This file was deleted.

3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
autobahn
twisted
# requirements.txt
Loading