|
| 1 | +from sio3pack.graph import GraphOperation |
| 2 | + |
1 | 3 | # SIO3Pack
|
| 4 | + |
| 5 | +## Example usage |
| 6 | + |
| 7 | +### In OIOIOI |
| 8 | + |
| 9 | +```python |
| 10 | +# Package unpacking |
| 11 | +import sio3pack, sio3workers |
| 12 | +from django.conf import settings |
| 13 | +package = sio3pack.from_file(path_to_package, django_settings=settings) |
| 14 | +graph_op: GraphOperation = package.get_unpack_graph() |
| 15 | +results = sioworkers.run(graph_op) |
| 16 | +graph_op.return_results(results) |
| 17 | +package.save_to_db(problem_id=1) |
| 18 | +``` |
| 19 | + |
| 20 | +### Locally (for example `sinol-make`) |
| 21 | + |
| 22 | +```python |
| 23 | +import sio3pack, sio3workers.local |
| 24 | +package = sio3pack.from_file(path_to_package) |
| 25 | +graph_op: GraphOperation = package.get_unpack_graph() |
| 26 | +results = sio3workers.local.run(graph_op) |
| 27 | +graph_op.return_results(results) |
| 28 | +``` |
| 29 | + |
| 30 | +--- |
| 31 | + |
| 32 | +## Development |
| 33 | + |
| 34 | +### Test without django support |
| 35 | + |
| 36 | +Install the package in editable mode and make sure that `django` and |
| 37 | +`pytest-django` are not installed. |
| 38 | + |
| 39 | +```bash |
| 40 | +pip install -e ".[tests]" |
| 41 | +pip uninstall django pytest-django |
| 42 | +``` |
| 43 | + |
| 44 | +Then follow the instructions in |
| 45 | +[General testing information](#general-testing-information). |
| 46 | + |
| 47 | + |
| 48 | +### Test with django support |
| 49 | + |
| 50 | +Install the package in editable mode along with Django dependencies: |
| 51 | + |
| 52 | +```bash |
| 53 | +pip install -e ".[django,tests,django_tests]" |
| 54 | +``` |
| 55 | + |
| 56 | +Then follow the instructions in |
| 57 | +[General testing information](#general-testing-information). |
| 58 | + |
| 59 | + |
| 60 | +### General testing information |
| 61 | + |
| 62 | +Run the tests with `pytest` in the root directory of |
| 63 | +the repository. |
| 64 | + |
| 65 | +```bash |
| 66 | +pytest -v |
| 67 | +``` |
| 68 | + |
| 69 | +To run tests in parallel, use the following command. |
| 70 | + |
| 71 | +```bash |
| 72 | +pytest -v -n auto |
| 73 | +``` |
| 74 | + |
| 75 | +To run coverage tests, use the following command. |
| 76 | + |
| 77 | +```bash |
| 78 | +pytest -v --cov=sio3pack --cov-report=html |
| 79 | +``` |
| 80 | + |
| 81 | +The coverage report will be generated in the file `htmlcov/index.html`. |
0 commit comments