Skip to content

Commit

Permalink
Overhauls packaging to use pipenv, as with the Quark-Gluon-Analysis r…
Browse files Browse the repository at this point in the history
…epo.
  • Loading branch information
AlexSchuy committed Apr 7, 2018
1 parent 8b39065 commit 4058a61
Show file tree
Hide file tree
Showing 6 changed files with 482 additions and 6 deletions.
17 changes: 17 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[[source]]
name = "pypi"
url = "https://pypi.python.org/simple"
verify_ssl = true

[dev-packages]

[requires]
python_version = "2.7"

[packages]
python-gssapi = "*"
paramiko = "*"
bokeh = "*"
dask = "*"
distributed = "*"
"subprocess32" = "*"
423 changes: 423 additions & 0 deletions Pipfile.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions client.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ def compute(version_number, max_events, skip_events, event_file, log_dir, tmp_di
except OSError as e:
print(e)
athena_log = os.path.join(log_dir, 'athena.log')
arg = 'nice python {} -n {} -s {} --log_file {} --tmp_dir {} --output_dir {} {} {}'.format(reco, max_events, skip_events, athena_log, tmp_dir, aod_dir, event_file, version_number)
arg = 'nice {} {} -n {} -s {} --log_file {} --tmp_dir {} --output_dir {} {} {}'.format(sys.executable, reco, max_events, skip_events, athena_log, tmp_dir, aod_dir, event_file, version_number)
with open(os.path.join(log_dir, 'reco.log'), 'w+') as fh:
subprocess32.check_call(arg, executable='/bin/bash', shell=True, stdout=fh, stderr=subprocess32.STDOUT)
subprocess32.check_call(arg, executable='/bin/bash', shell=True, stdout=fh, stderr=subprocess32.STDOUT, cwd=os.getcwd(), env=os.environ.copy())
try:
shutil.rmtree(log_dir)
shutil.rmtree(tmp_dir)
Expand Down
5 changes: 5 additions & 0 deletions dask_ssh.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

DASK_SSH="$(pipenv --venv)/lib/python2.7/site-packages/distributed/cli/dask_ssh.py"
pipenv run python $DASK_SSH --scheduler tev01 --hostfile hostfile.txt --nthreads 8

37 changes: 34 additions & 3 deletions package_setup.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,37 @@
#!/bin/bash

# Setup root
source /phys/users/gwatts/bin/CommonScripts/configASetup.sh
lsetup root
easy_install-2.7 --install-dir ~/.local/lib/python2.7/site-packages pip
~/.local/lib/python2.7/site-packages/pip install --upgrade --user python-gssapi paramiko bokeh dask distributed subprocess32
python package_test.py

# Make sure that the user base binary directory is in the path.
USER_BASE_BIN_PATH=$(python -m site --user-base)"/bin"
if [[ ":$PATH:" != *":$USER_BASE_BIN_PATH:"* ]]; then
echo "Warning: $USER_BASE_BIN_PATH not in PATH (necessary for use of local pipenv installation)!"
# Add a command to ~/.bashrc adding the user base binary directory to the path
# if such a command does not already exist.
export PATH=$PATH:$USER_BASE_BIN_PATH
if ! grep -s -q -F "$USER_BASE_BIN_PATH" ~/.bashrc; then
echo "Do you wish to add 'export PATH=\$PATH:$USER_BASE_BIN_PATH' to your ~/.bashrc for future use (recommended)?"
select yn in "Yes" "No"; do
case $yn in
Yes ) echo "export PATH=\$PATH:$USER_BASE_BIN_PATH" >> ~/.bashrc; break;;
No ) break;;
esac
done
fi
fi

# Make sure that setuptools is updated before installing pipenv.
pip install -q --user -U setuptools

# Install pipenv locally.
pip install --user -U pipenv

# Install the packages listed in the Pipfile
pipenv install

# Try to use the packages.
pipenv run python package_test.py

echo "NOTE: to use installed packages, prepend 'pipenv run' to your commands, or run 'pipenv shell' to activate the virtualenv."
2 changes: 1 addition & 1 deletion reco.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def reco(evnt_file, version, output_dir, num_events, skip_events, log_file, tmp_
print('{} arg: {}'.format(tag.tag, arg))
sys.stdout.flush()
try:
subprocess32.check_call(arg, executable='/bin/bash', cwd=tmp_dir, shell=True, stdout=log_file_handle, stderr=subprocess32.STDOUT)
subprocess32.check_call(arg, executable='/bin/bash', cwd=tmp_dir, shell=True, stdout=log_file_handle, stderr=subprocess32.STDOUT, env=os.environ.copy())
except subprocess32.CalledProcessError as e:
print('reco.py: {}'.format(e))
sys.stdout.flush()
Expand Down

0 comments on commit 4058a61

Please sign in to comment.