Skip to content

Commit

Permalink
Tidy up file structure.
Browse files Browse the repository at this point in the history
We use what seems to be the standard `src` and `tests` directory
structure.
  • Loading branch information
MrCurtis committed Jan 27, 2024
1 parent 34aa61f commit d9de94e
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 16 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Install library
run: pip install .
- name: Run tests
run: python -m unittest
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,19 @@ To install:
```
pip install fk-graph
```

Development:
------------

Clone the repo and `cd` in to the project directory. Create a virtual env, then install
the requirements with

```
pip install -r requirements.txt
```

Finally, to be able to run tests while developing, install the package as an editable install.

```
pip install --editable .
```
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "fk-graph"
version = "0.0.7"
packages = ["src/fk_graph"]
version = "0.0.8"
authors = [
{ name="Andrew Curtis", email="[email protected]" },
{ name="John C Thomas" },
Expand Down
3 changes: 3 additions & 0 deletions src/fk_graph/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from fk_graph.data_setup import setup_data
from fk_graph.graph import get_graph
from fk_graph.plot_graph import plot
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions plot_graph.py → src/fk_graph/plot_graph.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from plotly_functions import plot_v2, process_graph
from fk_graph.plotly_functions import plot_v2, process_graph
import networkx as nx
import plotly as ply

def plot(graph:nx.Graph) -> ply.graph_objs.Figure:
args = process_graph(graph)
fig = plot_v2(*args)
return fig
return fig
8 changes: 4 additions & 4 deletions plotly_functions.py → src/fk_graph/plotly_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import plotly.express as px
from plotly import graph_objects as go

from graph import Node
from fk_graph.graph import Node

import flask

Expand Down Expand Up @@ -296,8 +296,8 @@ def basic_graph(data=(('A', 'B'), ('B', 'C'), ('C', 'A'))) -> nx.Graph:


def _get_test_graph() -> nx.Graph:
from data_setup import setup_data
from graph import get_graph
from fk_graph.data_setup import setup_data
from fk_graph.graph import get_graph
from sqlalchemy import create_engine
engine = create_engine("sqlite+pysqlite:///:memory:", echo=False)
setup_data(engine)
Expand All @@ -321,4 +321,4 @@ def dash_app():

if __name__ == '__main__':
dash_app()
pass
pass
Empty file added tests/__init__.py
Empty file.
4 changes: 2 additions & 2 deletions test_data_setup.py → tests/test_data_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

from sqlalchemy import create_engine, text

from data_setup import setup_data
from fk_graph.data_setup import setup_data

from plotly_functions import basic_test
from fk_graph.plotly_functions import basic_test

class DataSetupTests(TestCase):

Expand Down
4 changes: 2 additions & 2 deletions test_graph.py → tests/test_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
from networkx import Graph, is_isomorphic
from sqlalchemy import Column, create_engine, ForeignKey, insert, Integer, MetaData, String, Table

from data_setup import setup_data
from fk_graph.data_setup import setup_data

from graph import (
from fk_graph.graph import (
get_graph,
Node,
PrimaryKeyDoesNotExist,
Expand Down
8 changes: 3 additions & 5 deletions integration_test.py → tests/test_intergration.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
from unittest import TestCase

from data_setup import setup_data

from graph import get_graph

from sqlalchemy import create_engine, text

from plot_graph import plot
from fk_graph.graph import get_graph
from fk_graph.data_setup import setup_data
from fk_graph.plot_graph import plot

engine = create_engine("sqlite+pysqlite:///:memory:", echo=True)

Expand Down

0 comments on commit d9de94e

Please sign in to comment.