Skip to content

Commit

Permalink
Merge branch 'main' into db-init
Browse files Browse the repository at this point in the history
  • Loading branch information
MasloMaslane authored Dec 19, 2024
2 parents 169d59b + 7cf0998 commit 2f3dff2
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 3 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ build
.idea
__pycache__
tests/test_django/db.sqlite3
htmlcov

# pytest-cov
.coverage*
coverage.xml

# macOS
.DS_Store

# Files from Django db
/sio3pack
/sio3pack
80 changes: 80 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,81 @@
from sio3pack.graph import GraphOperation

# SIO3Pack

## Example usage

### In OIOIOI

```python
# Package unpacking
import sio3pack, sio3workers
from django.conf import settings
package = sio3pack.from_file(path_to_package, django_settings=settings)
graph_op: GraphOperation = package.get_unpack_graph()
results = sioworkers.run(graph_op)
graph_op.return_results(results)
package.save_to_db(problem_id=1)
```

### Locally (for example `sinol-make`)

```python
import sio3pack, sio3workers.local
package = sio3pack.from_file(path_to_package)
graph_op: GraphOperation = package.get_unpack_graph()
results = sio3workers.local.run(graph_op)
graph_op.return_results(results)
```

---

## Development

### Test without django support

Install the package in editable mode and make sure that `django` and
`pytest-django` are not installed.

```bash
pip install -e ".[tests]"
pip uninstall django pytest-django
```

Then follow the instructions in
[General testing information](#general-testing-information).


### Test with django support

Install the package in editable mode along with Django dependencies:

```bash
pip install -e ".[django,tests,django_tests]"
```

Then follow the instructions in
[General testing information](#general-testing-information).


### General testing information

Run the tests with `pytest` in the root directory of
the repository.

```bash
pytest -v
```

To run tests in parallel, use the following command.

```bash
pytest -v -n auto
```

To run coverage tests, use the following command.

```bash
pytest -v --cov=sio3pack --cov-report=html
```

The coverage report will be generated in the file `htmlcov/index.html`.
4 changes: 2 additions & 2 deletions src/sio3pack/graph/graph_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ def __init__(self, graph: Graph, return_results: bool = False, return_func: call
results, if return_results is True.
"""
self.graph = graph
self.return_results = return_results
self.should_return = return_results
self.return_func = return_func

def return_results(self, data: dict):
if self.return_func:
if self.return_func and self.should_return:
return self.return_func(data)

0 comments on commit 2f3dff2

Please sign in to comment.