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

independent km caches for distinct cases; clear the Aesara cache if it's large #1127

Merged
merged 5 commits into from
Jul 27, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,20 @@ compile:
# The reconstruction/ecoli/dataclasses/process/*.py files were generated by
# write_ode_file.py in Parca code.
# Fireworks writes launcher_20* and block_20*.
# `aesara-cache clear` clears the current $(aesara-cache) cache, not others, and
# leaves 3 small *.delete.me dirs for later in case they're in use, esp. on NFS.
clean:
rm -fr fixtures
rm -fr fixtures cache
(cd reconstruction/ecoli/dataclasses/process && rm -f equilibrium_odes.py two_component_system_odes*.py)
find . -name "*.pyc" -exec rm -rf {} \;
find . -name "*.o" -exec rm -fr {} \;
find . -name "*.so" -exec rm -fr {} \;
rm -fr build
rm -fr launcher_20* block_20*
if [ "`aesara-cache | xargs du -sm | cut -f1`" -gt 30 ]; then \
echo "Clearing the aesara-cache since it's larger than threshold."; \
aesara-cache clear; \
fi

# Delete just the *.so libraries then (re)compile them.
# This is useful when switching to a different Python virtualenv.
Expand Down
22 changes: 13 additions & 9 deletions reconstruction/ecoli/fit_sim_data_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
TODO: functionalize so that values are not both set and returned from some methods
"""

from __future__ import absolute_import, division, print_function

import binascii
import functools
import itertools
import os
Expand All @@ -26,7 +25,6 @@
from wholecell.containers.bulk_objects_container import BulkObjectsContainer
from wholecell.utils import filepath, parallelization, units
from wholecell.utils.fitting import normalize, masses_and_counts_for_homeostatic_target
from wholecell.utils import parallelization


# Fitting parameters
Expand Down Expand Up @@ -3164,6 +3162,13 @@ def calculateRnapRecruitment(sim_data, cell_specs):
}


def crc32(arr: np.ndarray) -> int:
"""Return a CRC32 checksum of an ndarray."""
shape = str(arr.shape).encode()
values = arr.tobytes()
return binascii.crc32(shape + values)


def setKmCooperativeEndoRNonLinearRNAdecay(sim_data, bulkContainer):
"""
Fits the affinities (Michaelis-Menten constants) for RNAs binding to endoRNAses.
Expand Down Expand Up @@ -3312,13 +3317,12 @@ def setKmCooperativeEndoRNonLinearRNAdecay(sim_data, bulkContainer):
alpha
)

# The checksum in the filename picks independent caches for distinct cases
# such as different Parca options or Parca code in different git branches.
# `make clean` will delete the cache files.
needToUpdate = False
fixturesDir = filepath.makedirs(filepath.ROOT_PATH, "fixtures", "endo_km")
# Numpy 'U' fields make these files incompatible with older code, so change
# the filename. No need to make files compatible between Python 2 & 3; we'd
# have to set the same protocol version and set Python 3-only args like
# encoding='latin1'.
km_filepath = os.path.join(fixturesDir, 'km{}.cPickle'.format(sys.version_info[0]))
cache_dir = filepath.makedirs(filepath.ROOT_PATH, "cache")
km_filepath = os.path.join(cache_dir, f'parca-km-{crc32(Kmcounts)}.cPickle')

if os.path.exists(km_filepath):
with open(km_filepath, "rb") as f:
Expand Down