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

New Source ID - add NorESM2-LM #38

Closed
wants to merge 10 commits into from
Closed
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
Binary file added .github/.wiki/CMIP6plus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions .github/.wiki/CMIP6plus.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions .github/.wiki/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
A store of materials needed for the wiki
Binary file added .github/.wiki/cmip6plus600.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/.wiki/model_components.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/.wiki/source_id.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion .github/libs/source_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@

# sort out the model components
for c in component_list:
if c not in data: continue
cdummy = data[c][0]
model_components[c] = OrderedDict({"description": cdummy.get('description','none'),
"version":cdummy.get('version number','none'),
"native_nominal_resolution": cdummy.get('resolution','none') })

license = data['license(automated)'][0]
Expand All @@ -66,7 +68,7 @@
"license": license['license_id'],
"url": license['license_url'],
"exceptions_contact": "@%s <- %s"%tuple(data['license_exceptions_contact'].split('@')[::-1]),
"history": data.get('license_history',''),
# "history": data.get('license_history',''),
"source_specific_info": data.get("source_specific_info",''),

}),
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/getting workflow actions
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
curl -s -H "Authorization: token $github_token" "https://api.github.com/repos/$repository/actions/runs?event=repository_dispatch" | jq -r '.workflow_runs |keys'


last run => 0
curl -s -H "Authorization: token $github_token" "https://api.github.com/repos/$repository/actions/runs?event=repository_dispatch&name=Source_ID_dispatch" | jq -r '.workflow_runs[0] '


rerunurl

curl -s -H "Authorization: token $github_token" "https://api.github.com/repos/$repository/actions/runs?event=repository_dispatch&name=Source_ID_dispatch" | jq -r '.workflow_runs[0].rerun_url'


# Set your GitHub token and repository variables
github_token="$(gh auth token)"
repository="WCRP-CMIP/CMIP6Plus_CVs"
workflow_run_id="7054479259"

# Trigger a new workflow dispatch event for the specified run
curl -X POST \
-H "Authorization: token $github_token" \
-H "Accept: application/vnd.github.everest-preview+json" \
"https://api.github.com/repos/$repository/actions/runs/$workflow_run_id/rerun"
82 changes: 71 additions & 11 deletions .github/workflows/source_id.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,29 @@ jobs:
GITHUB_USERNAME: ${{ github.event.client_payload.author }}
run: |


repository="${{ github.repository }}"
github_token="${{ secrets.GITHUB_TOKEN }}"


base_branch="main"
feature_branch="source_id_${{ github.event.client_payload.name }}"

git pull
git checkout -b $feature_branch;


remote_branch="origin/$feature_branch"
branch_info=$(git rev-parse --verify "$remote_branch" 2>&1)
echo "branch info: $branch_info"

if [ -n "$branch_info" ]; then

git checkout $feature_branch
git reset --hard origin/main

else
git checkout -b $feature_branch;
fi

content=$(python .github/libs/source_id.py -k ${{ github.event.client_payload.key }} -r ${{ github.event.client_payload.record }})

git config --global user.email "${GITHUB_USERNAME}@users.noreply.github.com"
Expand All @@ -76,18 +93,61 @@ jobs:

git add *source_id.json
git commit -m "Adding ${{ github.event.client_payload.name }} to source_id"
git push origin $feature_branch
git push origin $feature_branch --force

gh pr create --base $base_branch --head $feature_branch --title "New Source ID - add ${{ github.event.client_payload.name }}" --body \
"This pull request was automatically created by a GitHub Actions workflow.

if [ -n "$branch_info" ]; then
pull_requests=$(curl -s -H "Authorization: token $github_token" \
"https://api.github.com/repos/$repository/pulls?state=open&head=$feature_branch" | jq -r '.[].number')

# base is main, head is our branch.

echo "pull requests ${pull_requests}";
# Iterate through each pull request and add the comment
for pr_number in $pull_requests; do
# author=$(curl -s -H "Authorization: token $github_token" \
# "https://api.github.com/repos/$repository/pulls/$pr_number" | jq -r '.user.login')

echo "running pull request $pr_number" ;
# keep indentation of comment_body !important
comment_body="This pull request (#$pr_number) was automatically updated by a GitHub Actions workflow.

Data submitted by @${{github.event.client_payload.author}}
Adding the following new data.

Adding the following updated data.
\`\`\`json
$content
\`\`\`

" --reviewer $GITHUB_USERNAME
$content
\`\`\` "
# escaped=$(echo "$comment_body" | sed 's/"/\\"/g')
echo "comment- $comment_body"

# # Add comment to the pull request
# curl -s -H "Authorization: token $github_token" \
# -x POST -d '{"body": "$comment_body"}' \
# "https://api.github.com/repos/$repository/issues/$pr_number/comments"
# # > /dev/null

gh pr comment $pr_number --body "$comment_body"

echo "Comment added to pull request #$pr_number"
done

else


echo "clean pull"
gh pr create --base $base_branch --head $feature_branch --title "New Source ID - add ${{ github.event.client_payload.name }}" --body \
"This pull request was automatically created by a GitHub Actions workflow.

Data submitted by @${{github.event.client_payload.author}}

Adding the following new data.
\`\`\`json
$content
\`\`\`

" --reviewer $GITHUB_USERNAME


fi

1 change: 1 addition & 0 deletions 2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8bd4ab6d051269250878053a78550cbd869dc398
65 changes: 65 additions & 0 deletions CMIP6Plus_source_id.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,71 @@
},
"release_year": "2016",
"source_id": "HadGEM3-GC31-LL"
},
"NorESM2-LM": {
"activity_participation": [
"CMIP",
"LESFMIP"
],
"cohort": [
"unknown"
wolfiex marked this conversation as resolved.
Show resolved Hide resolved
],
"institution_id": [
"NCC"
],
"label": "NorESM2-LM",
"label_extended": "NorESM2-LM (low atmosphere-medium ocean resolution, GHG concentration driven)",
"license_info": {
"id": "CC BY 4.0",
"license": "Creative Commons Attribution 4.0 International",
"url": "https://creativecommons.org/licenses/by/4.0/",
"exceptions_contact": "@met.no <- noresm-ncc",
"source_specific_info": ""
},
"model_component": {
"aerosol": {
"description": "OsloAero",
wolfiex marked this conversation as resolved.
Show resolved Hide resolved
"version": "none",
"native_nominal_resolution": "250"
wolfiex marked this conversation as resolved.
Show resolved Hide resolved
},
"atmos": {
"description": "CAM-OSLO (2 degree resolution; 144 x 96; 32 levels; top level 3 mb)",
"version": "none",
"native_nominal_resolution": "250"
},
"atmosChem": {
"description": "OsloChemSimp",
"version": "none",
"native_nominal_resolution": "250"
},
"land": {
"description": "CLM",
"version": "none",
"native_nominal_resolution": "250"
},
"landIce": {
"description": "CISM",
"version": "none",
"native_nominal_resolution": "250"
},
"ocean": {
"description": "MICOM (1 degree resolution; 360 x 384; 70 levels; top grid cell minimum 0-2.5 m [native model uses hybrid density and generic upper-layer coordinate interpolated to z-level for contributed data])",
"version": "none",
"native_nominal_resolution": "100"
},
"ocnBgchem": {
"description": "HAMOCC",
"version": "none",
"native_nominal_resolution": "100"
},
"seaIce": {
"description": "CICE",
"version": "none",
"native_nominal_resolution": "100"
}
},
"release_year": 2017,
"source_id": "NorESM2-LM"
}
}
}
Loading