Skip to content

Commit

Permalink
Added documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
h-0-0 committed Dec 2, 2023
1 parent 10a48b8 commit 481f939
Show file tree
Hide file tree
Showing 22 changed files with 6,936 additions and 13 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: website

# build the documentation whenever there are new commits on main
on:
push:
branches:
- main
# Alternative: only build for tags.
# tags:
# - '*'

# security: restrict permissions for CI jobs.
permissions:
contents: read

jobs:
# Build the documentation and upload the static HTML files as an artifact.
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.12'

# ADJUST THIS: install all dependencies (including pdoc)
- run: pip install -e .
- run: pip install pdoc
# ADJUST THIS: build your documentation into docs/.
# We use a custom build script for pdoc itself, ideally you just run `pdoc -o docs/ ...` here.
- run: pdoc --docformat google -o docs/.html src

- uses: actions/upload-pages-artifact@v2
with:
path: docs/

# Deploy the artifact to GitHub pages.
# This is a separate job so that only actions/deploy-pages has the necessary permissions.
deploy:
needs: build
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- id: deployment
uses: actions/deploy-pages@v2
14 changes: 14 additions & 0 deletions CLASSDESIGN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Class Design
Here we will outline the different kind of classes that are used in slune and how they interact with each other. There are 3 types:
- 'Searcher' classes - these are the classes that are used to define and traverse a search space.
- 'Logger' classes - these are the classes that are used to create and read log files.
- 'Saver' classes - these are the classes that are used to save logs to files and read logs from files.

The base module is where the base classes for each of these types are defined. The base classes are:
- BaseSearcher
- BaseLogger
- BaseSaver

To create a new searcher, logger or saver, you must inherit from the appropriate base class and implement the required methods. The required methods will have the '@abc.abstractmethod' decorator above them and will throw errors if they are not implemented. The compulsory methods allow for well-defined interactions between the different classes and should allow for any combination of searcher, logger and saver to be used together.

Please read the docs for the base classes to see what methods are required to be implemented and how they should be implemented.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
![PyPI - Version](https://img.shields.io/pypi/v/:slune-lib)
[![license](https://img.shields.io/badge/License-MIT-purple.svg)](LICENSE)
![badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/h-0-0/4aa01e058fee448070c587f6967037e4/raw/CodeCovSlune.json)

Expand Down Expand Up @@ -111,7 +112,6 @@ Please check out the examples folder for notebooks detailing in more depth some

## Roadmap
- Make package user friendly:
- Add documentation.
- Go through automation settings.
- Code of conduct.
- Contributing guidelines.
Expand Down
7 changes: 7 additions & 0 deletions docs/.html/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="refresh" content="0; url=./src.html"/>
</head>
</html>
46 changes: 46 additions & 0 deletions docs/.html/search.js

Large diffs are not rendered by default.

432 changes: 432 additions & 0 deletions docs/.html/src.html

Large diffs are not rendered by default.

264 changes: 264 additions & 0 deletions docs/.html/src/slune.html

Large diffs are not rendered by default.

982 changes: 982 additions & 0 deletions docs/.html/src/slune/base.html

Large diffs are not rendered by default.

244 changes: 244 additions & 0 deletions docs/.html/src/slune/loggers.html

Large diffs are not rendered by default.

608 changes: 608 additions & 0 deletions docs/.html/src/slune/loggers/default.html

Large diffs are not rendered by default.

244 changes: 244 additions & 0 deletions docs/.html/src/slune/savers.html

Large diffs are not rendered by default.

1,465 changes: 1,465 additions & 0 deletions docs/.html/src/slune/savers/csv.html

Large diffs are not rendered by default.

244 changes: 244 additions & 0 deletions docs/.html/src/slune/searchers.html

Large diffs are not rendered by default.

982 changes: 982 additions & 0 deletions docs/.html/src/slune/searchers/grid.html

Large diffs are not rendered by default.

614 changes: 614 additions & 0 deletions docs/.html/src/slune/slune.html

Large diffs are not rendered by default.

721 changes: 721 additions & 0 deletions docs/.html/src/slune/utils.html

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
# Empty
"""
.. include:: ../README.md
.. include:: ../CLASSDESIGN.md
"""
13 changes: 8 additions & 5 deletions src/slune/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# from .slune import submit_job, sbatchit
# __all__ = ['slune', 'base', 'utils', 'loggers', 'savers', 'searchers' ]

from .searchers import grid
from .savers import csv
from .loggers import default
from .searchers import *
from .savers import *
from .loggers import *
from .slune import submit_job, sbatchit, lsargs, garg, get_csv_slog
from . import base, utils

__all__ = ['submit_job', 'sbatchit', 'lsargs', 'garg', 'get_csv_slog',
'base', 'utils', 'default', 'grid', 'csv']
# __all__ = ['submit_job', 'sbatchit', 'lsargs', 'garg', 'get_csv_slog',
# 'base', 'utils', 'default', 'grid', 'csv']

import importlib.metadata
__version__ = importlib.metadata.version("slune-lib")
2 changes: 1 addition & 1 deletion src/slune/loggers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .default import LoggerDefault

__all__ = ['LoggerDefault']
# __all__ = ['LoggerDefault']
2 changes: 1 addition & 1 deletion src/slune/savers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .csv import SaverCsv

__all__ = ['SaverCsv']
# __all__ = ['SaverCsv']
2 changes: 1 addition & 1 deletion src/slune/searchers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .grid import SearcherGrid

__all__ = ['SearcherGrid']
# __all__ = ['SearcherGrid']
6 changes: 3 additions & 3 deletions src/slune/slune.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from typing import List, Optional, Union
from slune.base import Searcher, Saver
from slune.base import BaseSearcher, BaseSaver
import subprocess
import sys
from slune.savers.csv import SaverCsv
Expand All @@ -22,7 +22,7 @@ def submit_job(sh_path: str, args: List[str]):
except subprocess.CalledProcessError as e:
print(f"Error running sbatch: {e}")

def sbatchit(script_path: str, sbatch_path: str, searcher: Searcher, cargs: Optional[List]=[], saver: Optional[Saver]=None):
def sbatchit(script_path: str, sbatch_path: str, searcher: BaseSearcher, cargs: Optional[List]=[], saver: Optional[BaseSaver]=None):
""" Submits jobs based on arguments given by searcher.
For each job runs the script stored at script_path with selected parameter values given by searcher
Expand Down Expand Up @@ -91,7 +91,7 @@ def single_garg(arg_name):
else:
return single_garg(arg_names)

def get_csv_slog(params: Optional[dict]= None, root_dir: Optional[str]='slune_results') -> Saver:
def get_csv_slog(params: Optional[dict]= None, root_dir: Optional[str]='slune_results') -> BaseSaver:
""" Returns a SaverCsv object with the given parameters and root directory.
Args:
Expand Down

0 comments on commit 481f939

Please sign in to comment.