-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from moka-guys/tso_upload_helper
Tso upload helper (#5)
- Loading branch information
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/bin/bash | ||
|
||
# Check if a project name is provided | ||
if [ "$#" -ne 1 ]; then | ||
echo "Usage: $0 <project_name>" | ||
exit 1 | ||
fi | ||
|
||
# Assign the first argument to a variable | ||
project_name="$1" | ||
|
||
# Capture the output from dx find into a variable | ||
table_output=$(dx find data --name "*.zip" --json --path "${project_name}":results | jq -r ' | ||
["ID", "Name", "State", "Folder", "Modified", "Size"] as $headers | ||
| ["---", "---", "---", "---", "---", "---"] as $separator | ||
| [$headers, $separator] + | ||
(map([.id, .describe.name, .describe.state, .describe.folder, (.describe.modified / 1000 | todate), .describe.size])) | ||
| .[] | ||
| @tsv' | column -t) | ||
|
||
# Define APP_ID and MOKAGUYS_AUTH_TOKEN | ||
APP_ID="APP_ID" | ||
MOKAGUYS_AUTH_TOKEN="MOKAGUYS_AUTH_TOKEN" | ||
|
||
# Now you can manipulate $table_output with awk or any other tool. | ||
# Iterate over the table row by row | ||
while IFS= read -r line; do | ||
# Skip the header and separator lines | ||
if [[ "$line" == ID* ]] || [[ "$line" == "---"* ]]; then | ||
continue | ||
fi | ||
|
||
# Extract the Name, Folder, and ID using awk | ||
FILE_NAME=$(echo "$line" | awk '{print $2}') | ||
FOLDER=$(echo "$line" | awk '{print $4}') | ||
ID=$(echo "$line" | awk '{print $1}') | ||
|
||
FILE_ID="${FOLDER}/${FILE_NAME}" | ||
SAMPLE_NAME="${FILE_NAME%.zip}" | ||
|
||
# Print the dx run command | ||
echo "dx run project-ByfFPz00jy1fk6PjpZ95F27J:$APP_ID --priority high -y --name=$SAMPLE_NAME -isample_name=$SAMPLE_NAME -isample_zip_folder=$project_name:$FILE_ID --project=$project_name --auth $MOKAGUYS_AUTH_TOKEN" | ||
|
||
done <<< "$table_output" |