Skip to content

Commit 4a70294

Browse files
committed
Initial commit from pyrefine
0 parents  commit 4a70294

File tree

12 files changed

+931
-0
lines changed

12 files changed

+931
-0
lines changed

.gitignore

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
*pyc
2+
*swp
3+
*html
4+
*egg
5+
*egg-info
6+
build
7+
.vscode/.ropeproject/objectdb
8+
.vscode/.ropeproject/config.py
9+
tests/test_output_files
10+
htmlcov
11+
.coverage
12+
examples/*/*/Flow*
13+
examples/*/*/geom*
14+
examples/*/geom*
15+
16+
*pbs
17+
*log
18+
fun3d.nml_*
19+
*solb
20+
*out
21+
*dat
22+
*.forces
23+
*.grid_info
24+
*szplt
25+
*meshb
26+
*.flow
27+
*.trace
28+
moving_body.input_*
29+
*.restart
30+
*.mapbc
31+
*.ugrid
32+
*.names
33+
*.tec
34+
sfe.cfg_*
35+
cov.xml

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[![pipeline status](https://gitlab.larc.nasa.gov/sketch-to-solution/pyrefine/badges/main/pipeline.svg)](https://gitlab.larc.nasa.gov/sketch-to-solution/pyrefine/-/commits/main)
2+
3+
# Description
4+
5+
A python module for scripting PBS jobs
6+
7+
# Set up
8+
9+
## Installation with setup.py
10+
11+
setup.py in the root directory is a setuptools script for installing pyrefine.
12+
It is run with `python setup.py install`.
13+
Typical command line arguments to this script are `--user` to install in ~/.local or `--prefix={path/to/install}`.
14+
15+
## In place usage of pyrefine using pip
16+
From this root directory do `pip install -e .` to do a "developer install". This allows you to edit pbs4py without
17+
having to reinstall to get new changes.
18+
19+
# Documentation
20+
[LaRC gitlab page](https://sketch-to-solution.gitlab-pages.larc.nasa.gov/pyrefine/)
21+
22+
23+
The pyrefine documentation is generated from the source code with Sphinx.
24+
If you do not already have sphinx installed, you can use `pip` or `conda` to install it.
25+
Once you have installed or added pyrefine to your PYTHONPATH, the documentation is built by running `make html` in the docs directory.
26+
The generated documentation will be in `docs/build/html`.
27+
28+
29+
# Quick Start
30+
31+
After installation,
32+
33+
```python
34+
from pbs4py import PBS
35+
pbs = PBS.k4()
36+
pbs.launch('example_job',['echo "Hello World"'])
37+
```

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = source
9+
BUILDDIR = build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/make.bat

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=source
11+
set BUILDDIR=build
12+
13+
if "%1" == "" goto help
14+
15+
%SPHINXBUILD% >NUL 2>NUL
16+
if errorlevel 9009 (
17+
echo.
18+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
19+
echo.installed, then set the SPHINXBUILD environment variable to point
20+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
21+
echo.may add the Sphinx directory to PATH.
22+
echo.
23+
echo.If you don't have Sphinx installed, grab it from
24+
echo.http://sphinx-doc.org/
25+
exit /b 1
26+
)
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd

docs/source/conf.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# This file only contains a selection of the most common options. For a full
4+
# list see the documentation:
5+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
6+
7+
# -- Path setup --------------------------------------------------------------
8+
9+
# If extensions (or modules to document with autodoc) are in another directory,
10+
# add these directories to sys.path here. If the directory is relative to the
11+
# documentation root, use os.path.abspath to make it absolute, like shown here.
12+
#
13+
import os
14+
import sys
15+
sys.path.insert(0, os.path.abspath('../../'))
16+
17+
18+
# -- Project information -----------------------------------------------------
19+
20+
project = 'pbs4py'
21+
copyright = '2021, NASA'
22+
author = 'NASA'
23+
24+
25+
# -- General configuration ---------------------------------------------------
26+
27+
# Add any Sphinx extension module names here, as strings. They can be
28+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
29+
# ones.
30+
extensions = ['sphinx.ext.autodoc','sphinx.ext.napoleon']
31+
32+
# Add any paths that contain templates here, relative to this directory.
33+
templates_path = ['_templates']
34+
35+
# List of patterns, relative to source directory, that match files and
36+
# directories to ignore when looking for source files.
37+
# This pattern also affects html_static_path and html_extra_path.
38+
exclude_patterns = []
39+
40+
autoclass_content = 'both'
41+
autodoc_member_order = 'bysource'
42+
autodoc_default_flags = ['members', 'inherited-members']
43+
44+
# -- Options for HTML output -------------------------------------------------
45+
46+
# The theme to use for HTML and HTML Help pages. See the documentation for
47+
# a list of builtin themes.
48+
#
49+
html_theme = 'sphinxdoc'
50+
51+
# Add any paths that contain custom static files (such as style sheets) here,
52+
# relative to this directory. They are copied after the builtin static files,
53+
# so a file named "default.css" will overwrite the builtin "default.css".
54+
html_static_path = ['_static']

docs/source/index.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
pbs4py
2+
======
3+
4+
5+
PBS Job Submission Handler
6+
--------------------------
7+
.. toctree::
8+
:maxdepth: 1
9+
10+
pbs.rst
11+
pbs_examples.rst
12+
13+
14+
Batch Job Submission
15+
--------------------
16+
.. toctree::
17+
:maxdepth: 1
18+
19+
pbs_batch.rst
20+
batch_examples.rst
21+
Indices and tables
22+
==================
23+
24+
* :ref:`genindex`
25+
* :ref:`modindex`
26+
* :ref:`search`

docs/source/pbs.rst

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
.. _pbs_section:
2+
3+
PBS Job Handling
4+
%%%%%%%%%%%%%%%%
5+
6+
The adaptation process requires automation of creating and submitting PBS jobs.
7+
However each HPC machine's PBS set up is slightly different.
8+
The PBS class is a tool to define properties of the PBS set up you want to use
9+
and then launch jobs.
10+
11+
Note: Nothing about these utility classes is specific to adaptation, so they
12+
could be used for other job scripting.
13+
14+
15+
PBS stand alone example
16+
=======================
17+
18+
.. code-block :: python
19+
20+
from pbs4py import PBS
21+
22+
k4 = PBS.k4(time=48)
23+
k4.mpiexec = 'mpiexec_mpt'
24+
k4.requested_number_of_nodes = 5
25+
26+
fun3d_command = 'nodet_mpi --gamma 1.14'
27+
fun3d_mpi_command = k4.create_mpi_command(fun3d_command, 'dog')
28+
29+
pbs_commands = ['echo Start', fun3d_mpi_command, 'echo Done']
30+
31+
# submit and move on
32+
k4.launch('test_job', pbs_commands, blocking=False)
33+
34+
# submit and wait for job to finish before continuing script
35+
k4.launch('test_job', pbs_commands)
36+
37+
This script will launch pbs jobs with the following test_jobs.pbs script:
38+
39+
.. code-block :: bash
40+
41+
#!/usr/bin/env bash
42+
#PBS -N test_job
43+
#PBS -q K4-route
44+
#PBS -l select=5:ncpus=40:mpiprocs=40
45+
#PBS -l walltime=48:00:00
46+
#PBS -o test_job_pbs.log
47+
#PBS -j oe
48+
#PBS -r n
49+
50+
51+
cd $PBS_O_WORKDIR
52+
source ~/.bashrc
53+
54+
echo Start
55+
mpiexec_mpt nodet_mpi --gamma 1.14 > dog.out 2>&1
56+
echo Done
57+
58+
PBS Class
59+
=========
60+
The basic queue attributes are set in the constructor, but less common ones can be adjusted by changing the attributes.
61+
62+
.. automodule:: pbs4py.pbs
63+
64+
.. autoclass:: PBS
65+
:members:
66+
67+
PBS's classmethod constructors
68+
------------------------------
69+
Although not captured by the sphinx's autodocumentation,
70+
the ``PBS`` class has several classmethods that serve as alternate constructors which fill in properties of some NASA HPC systems and queue.
71+
72+
73+
.. code-block :: python
74+
75+
from pbs4py import PBS
76+
77+
k4 = PBS.k4(time=48)
78+
k3 = PBS.k3()
79+
k3a = PBS.k3a()
80+
nas = PBS.nas(group_list='n1337', proc_type='skylake', time = 72)
81+
82+
FakePBS Class
83+
*************
84+
Some adaptation such as 2D problems are small enough to run everything in a single pbs job so that you avoid having to sit in the queue for each operation.
85+
The FakePBS object appears to the adaptation drivers as a standard PBS object, but directly runs the commands instead of putting them into a PBS job and launching the job.
86+
87+
.. autoclass:: FakePBS
88+
:members:

0 commit comments

Comments
 (0)