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

Check python version against jar version #4328

Merged
merged 5 commits into from
Sep 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion hail/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ src/main/c/libsimdpp-2*
src/main/c/headers
src/main/c/lib
src/main/resources/build-info.properties
python/hail/_generated_version_info.py
src/test/resources/example.v11.bgen.idx*
src/test/resources/example.8bits.bgen.idx*
src/test/resources/random.bgen.idx*
src/test/resources/random.bgen-*.bgen.idx*
src/test/resources/skip_invalid_loci.bgen.idx*
src/test/resources/parallelBgenExport.bgen/part-00000.idx*
src/test/resources/parallelBgenExport.bgen/part-00000.idx*
4 changes: 2 additions & 2 deletions hail/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ compileJava {
}

task generateBuildInfo(type: Exec) {
commandLine 'sh', 'generate-build-info.sh', sparkVersion, hailVersion
commandLine 'bash', 'generate-build-info.sh', sparkVersion, hailVersion
outputs.upToDateWhen { false }
}

Expand Down Expand Up @@ -419,7 +419,7 @@ task testJar(type: Jar) {
from sourceSets.test.output
}

task archiveZip(type: Zip) {
task archiveZip(type: Zip, dependsOn: generateBuildInfo) {
from fileTree('python')
classifier = 'python'
}
Expand Down
21 changes: 15 additions & 6 deletions hail/generate-build-info.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,25 @@

set -e

REVISION=$(git rev-parse HEAD)
DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ)
DATE=$(git rev-parse --abbrev-ref HEAD)
URL=$(git config --get remote.origin.url)
SPARK_VERSION=$1
HAIL_VERSION=$2

echo_build_properties() {
echo "[Build Metadata]"
echo user=$USER
echo revision=$(git rev-parse HEAD)
echo branch=$(git rev-parse --abbrev-ref HEAD)
echo date=$(date -u +%Y-%m-%dT%H:%M:%SZ)
echo url=$(git config --get remote.origin.url)
echo sparkVersion=$1
echo hailVersion=$2
echo revision=$REVISION
echo branch=$BRANCH
echo date=$DATE
echo url=$URL
echo sparkVersion=$SPARK_VERSION
echo hailVersion=$HAIL_VERSION
}

mkdir -p src/main/resources/

echo_build_properties $1 $2 > "src/main/resources/build-info.properties"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this echo function business is a bit unusual. I'd just use the

cat <<DONE
blah blah blah
DONE

idiom. But this is really an unrelated change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, that's what I would have done too

echo "hail_version = \"${HAIL_VERSION}-${REVISION:0:12}\"" > python/hail/_generated_version_info.py
14 changes: 13 additions & 1 deletion hail/python/hail/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from hail.utils.java import Env, joption, FatalError, connect_logger, install_exception_handler, uninstall_exception_handler

import sys

import os

class HailContext(object):
@typecheck_method(sc=nullable(SparkContext),
Expand Down Expand Up @@ -83,6 +83,13 @@ def __init__(self, sc=None, app_name="Hail", master=None, local='local[*]',
version = self._jhc.version()
hail.__version__ = version

if not os.getenv('HAIL_IGNORE_PYTHON_VERSION'):
py_version = read_version_info()
if py_version != version:
raise RuntimeError(f"Hail version mismatch between JAR and Python library\n"
f" JAR: {version}\n"
f" Python: {py_version}")

if not quiet:
sys.stderr.write('Running on Apache Spark version {}\n'.format(self.sc.version))
if self._jsc.uiWebUrl().isDefined():
Expand Down Expand Up @@ -252,3 +259,8 @@ def set_global_seed(seed):
"""

Env.set_seed(seed)


def read_version_info() -> str:
from ._generated_version_info import hail_version
return hail_version