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

Test py branch #27

Merged
merged 33 commits into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
c9c6719
Inital test configuration
jbenegassi Jun 10, 2023
f666149
Inital test configuration
jbenegassi Jun 10, 2023
8d5d1cb
Test py files uploaded
jbenegassi Jun 10, 2023
3ce1b95
Update project name when adding testing directory
jbenegassi Jun 11, 2023
aa14daf
Change node Exec
jbenegassi Jun 11, 2023
98d29dd
Enable testing
jbenegassi Jun 11, 2023
8bc04be
Coeus updates commented
jbenegassi Jun 11, 2023
61e1865
Move from directory
jbenegassi Jun 12, 2023
d1fb1b0
Enable testing removed
jbenegassi Jun 12, 2023
ec8c031
Update CMakeLists.txt
adiazleanteferreiro Jun 13, 2023
1eab943
Update CMakeLists.txt
adiazleanteferreiro Jun 13, 2023
8f8b569
Update CMakeLists.txt
adiazleanteferreiro Jun 13, 2023
a241a54
Update CMakeLists.txt
adiazleanteferreiro Jun 13, 2023
6739f4b
Update run_test.py
adiazleanteferreiro Jun 13, 2023
10b673b
jarvis-util added
jbenegassi Jun 13, 2023
76a428f
Remove address sanitizer
jbenegassi Jun 13, 2023
0ea91cb
Script adapted to COEUS
jbenegassi Jun 13, 2023
a1d2847
Update run_test.py
adiazleanteferreiro Jun 14, 2023
d4cb53b
Removed test_types
jbenegassi Jun 14, 2023
0b142a5
Removed unnecessary test_types
jbenegassi Jun 14, 2023
5155818
Updated files
jbenegassi Jun 15, 2023
b09367c
Get and Put functions update
adiazleanteferreiro Jun 15, 2023
2ea760d
Removed finalize_hermes and hermes_deamon directories with executable
jbenegassi Jun 15, 2023
b8d679f
Updates
jbenegassi Jun 15, 2023
7994349
Removed hermes interceptor paths
jbenegassi Jun 15, 2023
33bc0dc
Update #!/usr/bin/python3
jbenegassi Jun 15, 2023
87f1a8d
Update shebang
jbenegassi Jun 15, 2023
ad2a54b
Update import
jbenegassi Jun 16, 2023
f543f6b
Added python3 command
jbenegassi Jun 16, 2023
d906ff4
Change name to test_basic
jbenegassi Jun 16, 2023
2a70ffe
Added LD_LIBRARY_PATH
jbenegassi Jun 16, 2023
74148a3
def test_basic
jbenegassi Jun 16, 2023
45bd2f7
Update image
jbenegassi Jun 16, 2023
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
2 changes: 1 addition & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
container-test-job:
runs-on: ubuntu-latest
container:
image: scslab/coeus:0.9.1
image: scslab/coeus:0.9.3
steps:
- name: Check for dockerenv file
run: (ls /.dockerenv && echo Found dockerenv) || (echo No dockerenv)
Expand Down
4 changes: 4 additions & 0 deletions CI/jarvis-util/.coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# .coveragerc
[run]
source = .
omit = *test*
139 changes: 139 additions & 0 deletions CI/jarvis-util/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
.idea
hostfile.txt
lcov.info

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
/.idea/jarvis-cd.iml
/.idea/misc.xml
/.idea/modules.xml
/.idea/inspectionProfiles/profiles_settings.xml
/.idea/inspectionProfiles/Project_Default.xml
/.idea/vcs.xml
/.idea/deployment.xml
21 changes: 21 additions & 0 deletions CI/jarvis-util/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022-present Luke Logan and other contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
118 changes: 118 additions & 0 deletions CI/jarvis-util/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# Jarvis UTIL

Jarvis-util is a library which contains various utilities to aid with
creating shell scripts within Python. This library contains wrappers
for executing shell commands locally, SSH, SCP, MPI, argument parsing,
and various other random utilities.

![Build](https://github.com/lukemartinlogan/jarvis-util/workflows/GitHub%20Actions/badge.svg)

[![Coverage Status](https://coveralls.io/repos/github/lukemartinlogan/jarvis-util/badge.svg?branch=master)](https://coveralls.io/github/lukemartinlogan/jarvis-util?branch=master)

## Installation

For now, we only consider manual installation
```bash
cd jarvis-util
python3 -m pip install -r requirements.txt
python3 -m pip install -e .
```

## Executing a program

The following code will execute a command on the local machine.
The output will NOT be collected into an in-memory buffer.
The output will be printed to the terminal as it occurs.

```python
from jarvis_util.shell.exec import Exec
from jarvis_util.shell.local_exec import LocalExecInfo

node = Exec('echo hello', LocalExecInfo(collect_output=False))
```

Programs can also be executed asynchronously:
```python
from jarvis_util.shell.exec import Exec
from jarvis_util.shell.local_exec import LocalExecInfo

node = Exec('echo hello', LocalExecInfo(collect_output=False,
exec_async=True))
node.wait()
```

Various examples of outputs:
```python
from jarvis_util.shell.exec import Exec
from jarvis_util.shell.local_exec import LocalExecInfo

# Will ONLY print to the terminal
node = Exec('echo hello', LocalExecInfo(collect_output=False))
# Will collect AND print to the terminal
node = Exec('echo hello', LocalExecInfo(collect_output=True))
# Will collect BUT NOT print to the terminal
node = Exec('echo hello', LocalExecInfo(collect_output=True,
hide_output=True))
# Will collect, pipe to file, and print to terminal
node = Exec('echo hello', LocalExecInfo(collect_output=True,
pipe_stdout='/tmp/stdout.txt',
pipe_stderr='/tmp/stderr.txt'))
```

This is useful if you have a program which runs using a daemon mode.

## Executing an MPI program

The following code will execute the "hostname" command on the local
machine 24 times using MPI.

```python
from jarvis_util.shell.exec import Exec
from jarvis_util.shell.mpi_exec import MpiExecInfo

node = Exec('hostname', MpiExecInfo(hostfile=None,
nprocs=24,
ppn=None,
collect_output=False))
```

## Executing an SSH program

The following code will execute the "hostname" command on all machines
in the hostfile

```python
from jarvis_util.shell.exec import Exec
from jarvis_util.shell.pssh_exec import PsshExecInfo

node = Exec('hostname', PsshExecInfo(hostfile="/tmp/hostfile.txt",
collect_output=False))
```

## The contents of a hostfile

A hostfile can have the following syntax:
```
ares-comp-01
ares-comp-[02-04]
ares-comp-[05-09,11,12-14]-40g
```

These will be expanded internally by PSSH and MPI.

# Unit tests

We run our unit tests in a docker container, which is located underneath
the CI directory. This is because we need to test multi-node functionality,
without having multiple nodes. To setup unit testing, perform the following:

1. Install Docker
2. Setup our "ci" container
3. Run the unit tests

```
```

# Contributing

We use the Google Python Style guide (pylintrc).
8 changes: 8 additions & 0 deletions CI/jarvis-util/bin/jarvis-imports
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env python3

from jarvis_util.util.import_all import *
import pathlib
import os


build_global_import_from_bin('jarvis_util')
55 changes: 55 additions & 0 deletions CI/jarvis-util/ci/cluster/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Install ubuntu 20.04
FROM ubuntu:20.04
LABEL maintainer="[email protected]"
LABEL version="0.0"
LABEL description="An example docker image"

# Disable Prompt During Packages Installation
ARG DEBIAN_FRONTEND=noninteractive

# Update ubuntu
RUN apt update && apt install

# Install some basic packages
RUN apt install -y \
openssh-server \
sudo git nano vim \
docker \
mpich \
gcc \
g++ \
gfortran \
libtool \
libtool-bin \
automake \
autoconf

# Create a new user
RUN useradd -m sshuser
RUN usermod -aG sudo sshuser
RUN passwd -d sshuser

# Copy the host's SSH keys
# Docker requires COPY be relative to the current working
# directory. We cannot pass ~/.ssh/id_rsa unfortunately...
ENV SSHDIR=/home/sshuser/.ssh
RUN sudo -u sshuser mkdir ${SSHDIR}
COPY id_rsa ${SSHDIR}/id_rsa
COPY id_rsa.pub ${SSHDIR}/id_rsa.pub

# Authorize host SSH keys
RUN sudo -u sshuser touch ${SSHDIR}/authorized_keys
RUN cat ${SSHDIR}/id_rsa.pub >> ${SSHDIR}/authorized_keys

# Set SSH permissions
RUN chmod 700 ${SSHDIR}
RUN chmod 644 ${SSHDIR}/id_rsa.pub
RUN chmod 600 ${SSHDIR}/id_rsa
RUN chmod 600 ${SSHDIR}/authorized_keys

# Enable passwordless SSH
RUN sed -i 's/#PermitEmptyPasswords no/PermitEmptyPasswords yes/' /etc/ssh/sshd_config

# Start SSHD and wait forever
RUN mkdir /run/sshd
CMD ["/usr/sbin/sshd", "-D"]
24 changes: 24 additions & 0 deletions CI/jarvis-util/ci/cluster/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: "3"

services:
node1:
build: .
links:
- node2
networks:
- net
hostname: node1
stdin_open: true
tty: true

node2:
build: .
networks:
- net
hostname: node2
stdin_open: true
tty: true

networks:
net:
driver: bridge
Loading