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

Api V2 #25

Merged
merged 6 commits into from
Feb 6, 2024
Merged
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
663 changes: 0 additions & 663 deletions notebooks/1_too_models.ipynb

This file was deleted.

165 changes: 165 additions & 0 deletions notebooks/Example_1_Setting_Up_Credentials.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "3fb54b95",
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"import logging\n",
"from winterapi import WinterAPI\n",
"from winterapi.endpoints import BASE_URL"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "84869822",
"metadata": {},
"outputs": [],
"source": [
"logging.getLogger(\"winterapi\").setLevel(\"DEBUG\")"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "b7024bc4",
"metadata": {},
"outputs": [],
"source": [
"winter = WinterAPI()"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "25197a54",
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Using server http://winter.caltech.edu:82\n",
"Pinging server: True\n"
]
}
],
"source": [
"print(f\"Using server {BASE_URL}\") # Should show the URL of the API\n",
"print(f\"Pinging server: {winter.ping()}\")"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "88d1d907",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"User is rdstein@caltech.edu\n"
]
}
],
"source": [
"try:\n",
" print(f\"User is {winter.get_user()}\")\n",
"except KeyError:\n",
" print(\"No user credentials found. Please add these first!\")\n",
" winter.add_user_details(overwrite=True)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "f0dc0b3f",
"metadata": {},
"outputs": [],
"source": [
"# Uncomment to add new credentials\n",
"# winter.add_user_details(user=x, password=y, overwrite=True)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "64797375",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Found the following saved programs: ['2024A001']\n"
]
}
],
"source": [
"print(f\"Found the following saved programs: {winter.get_programs()}\")\n",
"if len(winter.get_programs()) == 0:\n",
" print(\"No programs found. Add one to get started:\")\n",
" winter.add_program(overwrite=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "42f4d81b",
"metadata": {},
"outputs": [],
"source": [
"# Uncomment to add additional programs\n",
"winter.add_program(overwrite=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b16a0900",
"metadata": {},
"outputs": [],
"source": [
"# A fake local program I have created\n",
"winter.get_program_details(\"202XA000\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1023561f",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "winterapi",
"language": "python",
"name": "winterapi"
},
"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.11.3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading
Loading