Skip to content

Commit 6644014

Browse files
authored
Merge pull request #15 from pablormier/dev
post r1 improvements 1.0.0.dev5
2 parents dbac128 + a36c5db commit 6644014

108 files changed

Lines changed: 40379 additions & 18133 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/clean-pages.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Cleanup gh-pages (One-Time)
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
cleanup-gh-pages:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout gh-pages branch
11+
uses: actions/checkout@v4
12+
with:
13+
ref: gh-pages
14+
15+
- name: Remove all files
16+
run: |
17+
git rm -rf .
18+
git commit -m "Cleanup gh-pages branch for new structure" || echo "Nothing to commit"
19+
git push origin gh-pages
20+

.github/workflows/deploy-docs.yml

Lines changed: 91 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,47 +18,107 @@ jobs:
1818
fetch-depth: 0
1919

2020
- name: Set up Python
21-
uses: actions/setup-python@v4
21+
uses: actions/setup-python@v5
2222
with:
2323
python-version: '3.11'
2424

2525
- name: Setup Graphviz
2626
uses: ts-graphviz/setup-graphviz@v2
2727

28+
- name: Cache Poetry packages
29+
uses: actions/cache@v3
30+
with:
31+
path: ~/.cache/pypoetry
32+
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
33+
34+
- name: Cache pip packages
35+
uses: actions/cache@v3
36+
with:
37+
path: ~/.cache/pip
38+
key: ${{ runner.os }}-pip-${{ hashFiles('**/poetry.lock') }}
39+
2840
- name: Install Dependencies
2941
run: |
42+
set -e
3043
pip install poetry
3144
poetry install --with dev,docs
3245
33-
- name: Build Docs with sphinx-multiversion
46+
- name: Build Docs
3447
run: |
35-
# Create a temporary directory
36-
TEMP_DIR=$(mktemp -d)
37-
chmod 777 $TEMP_DIR
38-
echo "TEMP_DIR=$TEMP_DIR" >> $GITHUB_ENV
39-
echo "Temporary directory is $TEMP_DIR"
40-
poetry run sphinx-multiversion docs $TEMP_DIR
41-
touch $TEMP_DIR/.nojekyll
42-
echo '<meta http-equiv="refresh" content="0; URL='https://saezlab.github.io/corneto/main'" />' > $TEMP_DIR/index.html
43-
44-
- name: Deploy to GitHub Pages
48+
set -e
49+
poetry run sphinx-build -b html docs docs/_build/html
50+
51+
- name: Determine doc version
52+
id: set_version
53+
run: |
54+
set -e
55+
case "${GITHUB_REF}" in
56+
refs/tags/*)
57+
version="${GITHUB_REF#refs/tags/}"
58+
;;
59+
refs/heads/main)
60+
version="main"
61+
;;
62+
refs/heads/dev)
63+
version="dev"
64+
;;
65+
*)
66+
echo "Unexpected branch/ref: ${GITHUB_REF}"
67+
version="dev"
68+
;;
69+
esac
70+
echo "doc_version=${version}" >> $GITHUB_OUTPUT
71+
72+
- name: Generate switcher.json
4573
run: |
46-
git config --local user.email "action@github.com"
47-
git config --local user.name "GitHub Action"
48-
49-
# Now checkout to gh-pages
50-
git fetch origin gh-pages
51-
git checkout gh-pages || git checkout --orphan gh-pages
52-
53-
# Clean existing files for the branch and copy new ones
54-
echo "Removing current folder content: $BRANCH_NAME"
55-
rm -rf "./$BRANCH_NAME"
56-
cp -r "$TEMP_DIR/$BRANCH_NAME" "$BRANCH_NAME"
57-
58-
# Adding changes to git
59-
git add .
60-
git commit -m "Update docs for branch $BRANCH_NAME" --allow-empty
61-
git push -u origin gh-pages
62-
env:
63-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64-
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
74+
set -e
75+
poetry run python docs/generate_switcher.py
76+
77+
- name: Create root redirect to latest
78+
run: |
79+
set -e
80+
mkdir -p temp_root
81+
cp docs/switcher.json temp_root/switcher.json
82+
touch temp_root/.nojekyll
83+
cat > temp_root/index.html << EOF
84+
<!DOCTYPE html>
85+
<html>
86+
<head>
87+
<meta charset="utf-8">
88+
<title>Redirecting to main documentation</title>
89+
<meta http-equiv="refresh" content="0; URL=./main/">
90+
<link rel="canonical" href="./main/">
91+
</head>
92+
<body>
93+
<p>Redirecting to <a href="./main/">main documentation</a>...</p>
94+
</body>
95+
</html>
96+
EOF
97+
98+
- name: Deploy content to root
99+
uses: peaceiris/actions-gh-pages@v4
100+
with:
101+
github_token: ${{ secrets.GITHUB_TOKEN }}
102+
publish_dir: ./temp_root
103+
destination_dir: ./
104+
keep_files: true
105+
106+
- name: Deploy versioned docs
107+
uses: peaceiris/actions-gh-pages@v4
108+
with:
109+
github_token: ${{ secrets.GITHUB_TOKEN }}
110+
publish_dir: ./docs/_build/html
111+
destination_dir: ${{ steps.set_version.outputs.doc_version }}
112+
keep_files: true
113+
114+
- name: Deploy latest docs to root
115+
if: ${{ steps.set_version.outputs.doc_version == 'latest' }}
116+
uses: peaceiris/actions-gh-pages@v4
117+
with:
118+
github_token: ${{ secrets.GITHUB_TOKEN }}
119+
publish_dir: ./docs/_build/html
120+
destination_dir: ./
121+
keep_files: true
122+
123+
- name: Clean up temporary files
124+
run: rm -rf temp_root

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
[_]*.ipynb
55
my_graph.pkl.gz
66
*.DS_Store
7+
tests/_notebooks
78

89
# Ignore any "generated" folder inside docs
910
docs/**/generated/

corneto/__init__.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
import logging
12
import sys
23
import warnings
34

45
from corneto import _plotting as pl
56
from corneto._constants import *
6-
from corneto._graph import Attr, Attributes, EdgeType, Graph
7-
from corneto._util import info
7+
from corneto._data import Data, Feature, Sample
8+
from corneto._util import info, suppress_output
89
from corneto.backend import DEFAULT_BACKEND, DEFAULT_SOLVER, available_backends
910

1011
# from corneto.backend import DEFAULT_BACKEND as K # deprecate
@@ -13,6 +14,9 @@
1314
from corneto.backend._base import HammingLoss as hamming_loss
1415
from corneto.backend._base import Indicator, NonZeroIndicator
1516

17+
#from corneto._graph import Attr, Attributes, EdgeType, Graph
18+
from corneto.graph import Attr, Attributes, EdgeType, Graph
19+
from corneto.io import load_graph_from_sif
1620
# from corneto._core import GReNet as Graph
1721
from corneto.methods import (
1822
create_flow_graph,
@@ -22,6 +26,9 @@
2226
)
2327
from corneto.utils import Attr, Attributes
2428

29+
logger = logging.getLogger(__name__)
30+
logger.addHandler(logging.NullHandler())
31+
2532

2633
def get_version():
2734
import os
@@ -59,19 +66,24 @@ def __getattr__(self, attr):
5966

6067

6168
__all__ = [
69+
"DEFAULT_BACKEND",
6270
"Attr",
63-
"EdgeType",
6471
"Attributes",
72+
"Data",
73+
"EdgeType",
74+
"Feature",
6575
"Graph",
66-
"info",
67-
"DEFAULT_BACKEND",
68-
"available_backends",
6976
"K",
77+
"Sample",
78+
"available_backends",
79+
"info",
7080
"ops",
81+
"suppress_output",
7182
]
7283

7384

74-
import_sif = Graph.from_sif
85+
#import_sif = Graph.from_sif
86+
import_sif = load_graph_from_sif
7587

7688
try:
7789
# Python 3.8 and newer

0 commit comments

Comments
 (0)