diff --git a/README.md b/README.md index 9b3ed2e..40b38d5 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ Clone this repo, then: ``` conda create -n opencap python=3.7 +conda activate opencap pip install -r requirements.txt ``` Create the `.env` file with all env variables and credentials diff --git a/mcserver/zipsession_v2.py b/mcserver/zipsession_v2.py index c8af8d0..6f37335 100644 --- a/mcserver/zipsession_v2.py +++ b/mcserver/zipsession_v2.py @@ -148,6 +148,9 @@ def collect_kinematics_files(self, trial): result.media, os.path.join(kinematics_root, f"{trial.formated_name}.mot") ) + # Collect the model when we're in a mono trial (there is no neutral trial and thus no model in neutral so we download the model for each trial) + if trial.session.isMono: + self.collect_opensim_model_files(trial, isMono=True) def collect_geometry_vtp_files_from_s3(self, model_name): s3 = boto3.client("s3") @@ -161,7 +164,7 @@ def collect_geometry_vtp_files_from_s3(self, model_name): os.path.join(geometry_dir, f"{name}.vtp") ) - def collect_opensim_model_files(self, trial): + def collect_opensim_model_files(self, trial, isMono=False): root_dir_path = self.get_root_dir_path() opensim_result = trial.result_set.filter(tag=ResultTag.OPENSIM_MODEL.value).first() if opensim_result: @@ -169,6 +172,8 @@ def collect_opensim_model_files(self, trial): opensim_result.media.url ).path.split('-')[-1] model_root = os.path.join(root_dir_path, "OpenSimData", "Model") + if isMono: + model_root = os.path.join(model_root, trial.formated_name) os.makedirs(model_root, exist_ok=True) self.download_file_from_s3( opensim_result.media, @@ -369,4 +374,4 @@ def zipdir_contents_with_retry(dir_path, zip_path, max_retries=5, backoff=0.1): except (FileNotFoundError, PermissionError, OSError) as e: if attempt == max_retries - 1: raise - time.sleep(backoff * (2 ** attempt)) + time.sleep(backoff * (2 ** attempt)) \ No newline at end of file