Commit 23915c74 authored by tchervec's avatar tchervec
Browse files

Resolve "upgrade to JDK 11"

parent 74ca8951
...@@ -7,7 +7,7 @@ test: ...@@ -7,7 +7,7 @@ test:
- conda list - conda list
- which python - which python
- python --version - python --version
- python -u -v -m synpp config_gitlab.yml - python -u -m synpp config_gitlab.yml
before_script: before_script:
- rm -rf env - rm -rf env
......
**3.0.0** **3.0.0**
- Update to `java 11.0.x`
- Update environment set-up on servers - Update environment set-up on servers
- Refactor IPU fitting - Refactor IPU fitting
- Impute canton id directly from shapefile - Impute canton id directly from shapefile
......
import numpy as np import numpy as np
def configure(context): def configure(context):
context.config("input_downsampling")
context.stage("data.statpop.scaled") context.stage("data.statpop.scaled")
def execute(context): def execute(context):
df = context.stage("data.statpop.scaled") df = context.stage("data.statpop.scaled")
if "input_downsampling" in context.config: # If we do not want to downsample, set the value to 1.0 in config
probability = context.config("input_downsampling") probability = context.config("input_downsampling")
if probability < 1.0:
print("Downsampling (%f)" % probability) print("Downsampling (%f)" % probability)
household_ids = np.unique(df["household_id"]) household_ids = np.unique(df["household_id"])
...@@ -18,7 +23,7 @@ def execute(context): ...@@ -18,7 +23,7 @@ def execute(context):
# during downsampling, households are selected randomly without specifying a seed, # during downsampling, households are selected randomly without specifying a seed,
# which means that running the pipeline twice will produce different populations # which means that running the pipeline twice will produce different populations
# resulting in potentially different simulation results # resulting in potentially different simulation results
f = np.random.random(size = (len(household_ids),)) < probability f = np.random.random(size=(len(household_ids),)) < probability
remaining_household_ids = household_ids[f] remaining_household_ids = household_ids[f]
print(" Sampled number of households:", len(remaining_household_ids)) print(" Sampled number of households:", len(remaining_household_ids))
......
import subprocess as sp import subprocess as sp
class JavaRunner: class JavaRunner:
def __init__(self, binary, memory): def __init__(self, binary, memory):
self.memory = memory self.memory = memory
self.binary = binary self.binary = binary
def __call__(self, classpath, entry_point, arguments, vm_arguments = None, cwd = None, memory = None, output = False): def __call__(self, classpath, entry_point, arguments, vm_arguments=None, cwd=None, memory=None, output=False):
memory = self.memory if memory is None else memory memory = self.memory if memory is None else memory
if vm_arguments is None: if vm_arguments is None:
...@@ -22,9 +23,10 @@ class JavaRunner: ...@@ -22,9 +23,10 @@ class JavaRunner:
print(" " + " ".join(command_line)) print(" " + " ".join(command_line))
if output: if output:
return sp.check_output(command_line, cwd = cwd) return sp.check_output(command_line, cwd=cwd)
else: else:
return sp.check_call(command_line, cwd = cwd) return sp.check_call(command_line, cwd=cwd)
def configure(context): def configure(context):
context.config("java_memory", "10G") context.config("java_memory", "10G")
...@@ -33,7 +35,8 @@ def configure(context): ...@@ -33,7 +35,8 @@ def configure(context):
# Not ideal, because we assume that "java" is the right binary. # Not ideal, because we assume that "java" is the right binary.
# This should better go into a "validate" step between configure and # This should better go into a "validate" step between configure and
# execute ... TODO # execute ... TODO
assert("1.8.0" in sp.check_output(["java", "-version"], stderr = sp.STDOUT).decode("utf-8")) assert ("11.0" in sp.check_output(["java", "-version"], stderr=sp.STDOUT).decode("utf-8"))
def execute(context): def execute(context):
return JavaRunner(context.config("java_binary"), context.config("java_memory")) return JavaRunner(context.config("java_binary"), context.config("java_memory"))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment