Skip to content

Commit

Permalink
Merge branch 'v0.14' of https://github.com/openhealthcare/elcid-rfh i…
Browse files Browse the repository at this point in the history
…nto v0.14
  • Loading branch information
fredkingham committed Aug 19, 2019
2 parents cba46e1 + 6391666 commit eb12f11
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 20 deletions.
13 changes: 7 additions & 6 deletions fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class FabException(Exception):
class Env(object):
def __init__(self, branch):
self.branch = branch
self.release_backup_name = self.get_release_backup_name()

@property
def project_directory(self):
Expand Down Expand Up @@ -135,14 +136,12 @@ def backup_file_name(self):

@property
def backup_name(self):
now = datetime.datetime.now()
return BACKUP_NAME.format(
backup_dir=BACKUP_DIR,
backup_file_name=self.backup_file_name
)

@property
def release_backup_name(self):
def get_release_backup_name(self):
return RELEASE_BACKUP_NAME.format(
backup_dir=BACKUP_DIR,
dt=datetime.datetime.now().strftime("%d.%m.%Y.%H.%M"),
Expand Down Expand Up @@ -624,7 +623,7 @@ def create_private_settings():


def get_python_3():
return local("which python3", capture=True)
return local("which python3.5", capture=True)


def _deploy(new_branch, backup_name=None, remove_existing=False):
Expand All @@ -639,6 +638,8 @@ def _deploy(new_branch, backup_name=None, remove_existing=False):
env.host_string = private_settings["host_string"]

kill_running_processes()

install_apt_dependencies()

# Setup environment
pip_create_virtual_env(
Expand All @@ -649,7 +650,6 @@ def _deploy(new_branch, backup_name=None, remove_existing=False):
pip_set_project_directory(new_env)
pip_create_deployment_env(new_branch)

install_apt_dependencies()
pip_install_requirements(new_env, private_settings["proxy"])

# create a database
Expand Down Expand Up @@ -754,7 +754,8 @@ def roll_back_prod(branch_name):
def install_apt_dependencies():
dependences = [
("smbclient", "2:4.3.11+dfsg-0ubuntu0.14.04.19"),
("python3-dev", "3.4.0-0ubuntu2"),
("python3.5", "3.5.2-2ubuntu0~16.04.4~14.04.1"),
("python3.5-dev", "3.5.2-2ubuntu0~16.04.4~14.04.1"),
]

for dependency in dependences:
Expand Down
2 changes: 1 addition & 1 deletion intrahospital_api/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class PatientAdmin(OldPatientAdmin):

def refresh_lab_tests(self, request, queryset):
for patient in queryset:
loader.load_patient(patient, async=False)
loader.load_patient(patient, run_async=False)

def upstream_lab_results(self, obj):
hospital_number = obj.demographics_set.first().hospital_number
Expand Down
14 changes: 7 additions & 7 deletions intrahospital_api/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def _initial_load():

for iterator, patient in enumerate(patients.all()):
logger.info("running {}/{}".format(iterator+1, total))
load_patient(patient, async=False)
load_patient(patient, run_async=False)


def log_errors(name):
Expand Down Expand Up @@ -127,7 +127,7 @@ def load_demographics(hospital_number):
return result


def load_patient(patient, async=None):
def load_patient(patient, run_async=None):
"""
Load all the things for a patient.
Expand All @@ -139,14 +139,14 @@ def load_patient(patient, async=None):
it will default to settings.ASYNC_API.
"""
logger.info("starting to load patient {}".format(patient.id))
if async is None:
async = settings.ASYNC_API
if run_async is None:
run_async = settings.ASYNC_API

patient_load = models.InitialPatientLoad(
patient=patient,
)
patient_load.start()
if async:
if run_async:
logger.info("loading patient {} asynchronously".format(patient.id))
async_task(patient, patient_load)
else:
Expand Down Expand Up @@ -219,8 +219,8 @@ def good_to_go():
)
)

one_hour_ago = timezone.now() - datetime.timedelta(seconds=60 * 60)
if models.BatchPatientLoad.objects.last().stopped < one_hour_ago:
three_hours_ago = timezone.now() - datetime.timedelta(seconds=60 * 180)
if models.BatchPatientLoad.objects.last().stopped < three_hours_ago:
raise BatchLoadError("Last load has not run since {}".format(
models.BatchPatientLoad.objects.last().stopped
))
Expand Down
12 changes: 6 additions & 6 deletions intrahospital_api/test/test_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ def test_flow(self, load_patient, reconcile_all_demographics):
call_args_list[0][0], (self.patient_1,)
)
self.assertEqual(
call_args_list[0][1], dict(async=False)
call_args_list[0][1], dict(run_async=False)
)
self.assertEqual(
call_args_list[1][0], (self.patient_2,)
)
self.assertEqual(
call_args_list[1][1], dict(async=False)
call_args_list[1][1], dict(run_async=False)
)
call_args_list = info.call_args_list
self.assertEqual(
Expand Down Expand Up @@ -217,15 +217,15 @@ def setUp(self, *args, **kwargs):
def test_load_patient_arg_override_settings_True(
self, load_lab_tests, async
):
loader.load_patient(self.patient, async=False)
loader.load_patient(self.patient, run_async=False)
self.assertTrue(load_lab_tests.called)
self.assertFalse(async.called)

@override_settings(ASYNC_API=False)
def test_load_patient_arg_override_settings_False(
self, load_lab_tests, async
):
loader.load_patient(self.patient, async=True)
loader.load_patient(self.patient, run_async=True)
self.assertFalse(load_lab_tests.called)
self.assertTrue(async.called)

Expand All @@ -248,7 +248,7 @@ def test_load_patient_arg_override_settings_None_False(
def test_load_patient_async(
self, load_lab_tests, async
):
loader.load_patient(self.patient, async=True)
loader.load_patient(self.patient, run_async=True)
self.assertFalse(load_lab_tests.called)
self.assertTrue(async.called)
call_args_list = async.call_args_list
Expand All @@ -263,7 +263,7 @@ def test_load_patient_async(
def test_load_patient_async_false(
self, load_lab_tests, async
):
loader.load_patient(self.patient, async=False)
loader.load_patient(self.patient, run_async=False)
self.assertFalse(async.called)
self.assertTrue(load_lab_tests.called)
call_args_list = load_lab_tests.call_args_list
Expand Down

0 comments on commit eb12f11

Please sign in to comment.