Skip to content
Open
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions mcserver/zipsession_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -161,14 +164,16 @@ 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:
opensim_model_short_filename = urlparse(
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,
Expand Down Expand Up @@ -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))