Skip to content

Commit

Permalink
Merge pull request #455 from ncihtan/aditigopalan-patch-1
Browse files Browse the repository at this point in the history
Aditigopalan patch 1
  • Loading branch information
aditigopalan authored Sep 11, 2024
2 parents 1547507 + 47d84c7 commit 1b69fc1
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 114 deletions.
88 changes: 0 additions & 88 deletions .github/workflows/build-dependencies-table.yml

This file was deleted.

61 changes: 35 additions & 26 deletions .github/workflows/ci-lint-validate-convert.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,42 +116,51 @@ 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"
from io import StringIO
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)
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"
# Prepare parameters or request body as needed
params = {'schema_url': jsonld_url}
print("Fetching attribute table...")
# Change to POST if required by the API
response = requests.post(url, params=params)
print(f"Status Code: {response.status_code}")
print(f"Response Text: {response.text[:500]}") # Print first 500 characters for review
df.to_csv('HTAN.dependencies.csv', index=False)
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}")
if __name__ == "__main__":
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

0 comments on commit 1b69fc1

Please sign in to comment.