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

Proper file structure #29

Merged
merged 1 commit into from
Jan 27, 2024
Merged
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
Tidy up file structure.
We use what seems to be the standard `src` and `tests` directory
structure.
  • Loading branch information
MrCurtis committed Jan 27, 2024
commit d9de94e3101aa6550c98940eed96666efc36c03a
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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
@@ -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
@@ -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="fk.graph@fastmail.com" },
{ name="John C Thomas" },
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
@@ -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

@@ -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)
@@ -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
@@ -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):

4 changes: 2 additions & 2 deletions test_graph.py → tests/test_graph.py
Original file line number Diff line number Diff line change
@@ -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,
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)

Loading