Skip to content

Commit

Permalink
Create notebook for generating headlines
Browse files Browse the repository at this point in the history
  • Loading branch information
tschaffter committed Oct 24, 2023
1 parent 61bb1f8 commit 9110fc4
Show file tree
Hide file tree
Showing 2 changed files with 200 additions and 5 deletions.
153 changes: 153 additions & 0 deletions apps/openchallenges/notebook/notebooks/openai-challenge-headline.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "34a39b07-385c-49b7-931f-3631a1aff129",
"metadata": {
"tags": []
},
"source": [
"# OpenChallenges REST API Example"
]
},
{
"cell_type": "markdown",
"id": "ed72ae29-13e0-4533-8e7e-f13c9b34da1a",
"metadata": {},
"source": [
"## Overview"
]
},
{
"cell_type": "markdown",
"id": "b876938b-ae3a-49ba-b416-b9fd59f88ae7",
"metadata": {},
"source": [
"This notebook generates challenge headlines for challenges fetched from OpenChallenges (OC)."
]
},
{
"cell_type": "markdown",
"id": "7e95e24d-3f3a-47d0-bb52-35e718eb7ac6",
"metadata": {},
"source": [
"## Requirements"
]
},
{
"cell_type": "markdown",
"id": "cc586a81-e5b4-4021-9c6b-aa8a69ef221c",
"metadata": {},
"source": [
"- Access to OpenChallenges REST API\n",
"- Access to OpenAI API"
]
},
{
"cell_type": "markdown",
"id": "c90710c2-f053-44ae-a3c2-610eecff9073",
"metadata": {},
"source": [
"## List challenges"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "c41a64a1",
"metadata": {},
"outputs": [],
"source": [
"import openchallenges_client\n",
"from pprint import pprint\n",
"from openchallenges_client.api import challenge_api"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "8fc3ac4c-2ceb-4bbc-bdb8-3bb8be08dfc6",
"metadata": {},
"outputs": [],
"source": [
"# See configuration.py for a list of all supported configuration parameters.\n",
"configuration = openchallenges_client.Configuration(\n",
" host = \"https://openchallenges.io/api/v1\"\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "b2f952f5-9140-4702-8a96-3457ca4df841",
"metadata": {},
"outputs": [],
"source": [
"# Enter a context with an instance of the API client\n",
"challenges = []\n",
"with openchallenges_client.ApiClient(configuration) as api_client:\n",
" api_instance = challenge_api.ChallengeApi(api_client)\n",
" \n",
" query = openchallenges_client.ChallengeSearchQuery(page_number=1, page_size=1)\n",
"\n",
" try:\n",
" # Get the first page of the list of challenges\n",
" page = api_instance.list_challenges(query)\n",
" challenges.extend(page.challenges)\n",
" except openchallenges_client.ApiException as e:\n",
" print(\"Exception when calling ChallengeApi->list_challenges: %s\\n\" % e)"
]
},
{
"cell_type": "code",
"execution_count": 24,
"id": "d0c0b308-0b58-44a7-8ff6-4987dfbccb17",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Challenge(id=279, slug='niddk-central-repository-data-centric-challenge', name='NIDDK Central Repository Data-Centric Challenge', headline='Enhancing NIDDK datasets for future Artificial Intelligence (AI) applications.', description='The National Institute of Diabetes and Digestive and Kidney Diseases (NIDDK) Central Repository (https://repository.niddk.nih.gov/home/) is conducting a Data Centric Challenge aimed at augmenting existing Repository data for future secondary research including data-driven discovery by artificial intelligence (AI) researchers. The NIDDK Central Repository (NIDDK-CR) program strives to increase the utilization and impact of the resources under its guardianship. However, lack of standardization and consistent metadata within and across studies limit the ability of secondary researchers to easily combine datasets from related studies to generate new insights using data science methods. In the fall of 2021, the NIDDK-CR began implementing approaches to augment data quality to improve AI-readiness by making research data FAIR (findable, accessible, interoperable, and reusable) via a small pilot project utilizing Natural Language Processing (NLP) to tag study variables. In 2022, the NIDD...', doi='', status=<ChallengeStatus.ACTIVE: 'active'>, difficulty=<ChallengeDifficulty.INTERMEDIATE: 'intermediate'>, platform=SimpleChallengePlatform(id=14, slug='other', name='Other'), website_url='https://www.challenge.gov/?challenge=niddk-central-repository-data-centric-challenge', avatar_url='', incentives=[<ChallengeIncentive.PUBLICATION: 'publication'>, <ChallengeIncentive.SPEAKING_ENGAGEMENT: 'speaking_engagement'>, <ChallengeIncentive.OTHER: 'other'>], submission_types=[<ChallengeSubmissionType.PREDICTION_FILE: 'prediction_file'>, <ChallengeSubmissionType.NOTEBOOK: 'notebook'>], input_data_types=[], start_date=datetime.date(2023, 9, 20), end_date=datetime.date(2023, 11, 3), starred_count=0, created_at=datetime.datetime(2023, 10, 18, 16, 58, 17, tzinfo=datetime.timezone.utc), updated_at=datetime.datetime(2023, 10, 18, 20, 52, 49, tzinfo=datetime.timezone.utc))"
]
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"challenge = challenges[0]\n",
"challenge"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "dfaaa94a",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
52 changes: 47 additions & 5 deletions apps/openchallenges/notebook/notebooks/openchallenges-api.ipynb

Large diffs are not rendered by default.

0 comments on commit 9110fc4

Please sign in to comment.