Skip to content

Commit

Permalink
Merge branch 'main' into patch-read-indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
aditigopalan authored Jan 14, 2025
2 parents 0cfbc32 + 4b9bb3c commit 4c6e970
Show file tree
Hide file tree
Showing 3 changed files with 1,234 additions and 1,318 deletions.
88 changes: 0 additions & 88 deletions .github/workflows/build-dependencies-table.yml

This file was deleted.

69 changes: 37 additions & 32 deletions .github/workflows/ci-lint-validate-convert.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ jobs:
if: always()
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: csvlinter
uses: kcheriyath/csvlinter@V0.6.0
with:
find_pattern: "*.csv"
- uses: actions/checkout@v4
- name: csvlinter
uses: kcheriyath/csvlinter@V0.6.0
with:
find_pattern: "*.csv"

validate:
name: Validate CSV
Expand Down Expand Up @@ -125,42 +125,47 @@ jobs:
python - <<EOF
import requests
import pandas as pd
url = "https://schematic.api.sagebionetworks.org/v1/ui/" # Endpoint URL
if "${{ github.event_name }}" == "pull_request":
jsonld_url = "https://raw.githubusercontent.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }}/head/HTAN.model.jsonld"
else:
jsonld_url = "https://raw.githubusercontent.com/${{ github.repository }}/main/HTAN.model.jsonld"
response = requests.get(jsonld_url)
response.raise_for_status()
model_jsonld = response.json()
response = requests.post(url, json=model_jsonld)
response.raise_for_status()
attribute_table = response.json() # Adjust this line based on the actual response format
df = pd.DataFrame(attribute_table)
from io import StringIO
df.to_csv('HTAN.dependencies.csv', index=False)
def fetch_and_save_attribute_table():
url = "https://schematic.api.sagebionetworks.org/v1/visualize/attributes"
jsonld_url = "https://raw.githubusercontent.com/ncihtan/data-models/main/HTAN.model.jsonld"
params = {'schema_url': jsonld_url}
print("Fetching attribute table...")
response = requests.get(url, params=params)
print(f"Status Code: {response.status_code}")
if response.status_code == 200:
content_type = response.headers.get('Content-Type', '')
if 'text/html' in content_type:
print("Response in text/html format, converting to CSV...")
try:
df = pd.read_csv(StringIO(response.text))
print("Fetched attribute table.")
df.to_csv('HTAN.dependencies.csv', index=False)
print("Saved to HTAN.dependencies.csv.")
except Exception as e:
print(f"Error processing CSV: {e}")
else:
print("Unexpected content type. Expected text/html but got:", content_type)
else:
print(f"Failed to fetch data. Status Code: {response.status_code}")
fetch_and_save_attribute_table()
EOF
- name: Commit changes
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add HTAN.dependencies.csv
git commit -m "Update HTAN.dependencies.csv with the latest attribute table"
- name: Create Pull Request
if: github.event_name == 'pull_request'
uses: r-lib/actions/pr-push@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

git commit -m "Update HTAN.dependencies.csv with the latest attribute table" || echo "No changes to commit"
- name: Create Pull Request
if: github.event_name != 'pull_request'
uses: peter-evans/create-pull-request@v3
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Update HTAN.dependencies.csv"
Expand Down
Loading

0 comments on commit 4c6e970

Please sign in to comment.