Skip to content

Commit c7a1a20

Browse files
committed
- Add new feature X
- Refactor code for better readability - Fix bug in method Y - Update dependencies to latest versions - Remove unused imports
1 parent 3f9aab5 commit c7a1a20

File tree

2 files changed

+136
-0
lines changed

2 files changed

+136
-0
lines changed

braininventory/get.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ def __get_number_of_datasets(df):
3030
def __get_completeness_score(df):
3131
return df['score'].sum()/len(df)
3232

33+
def __is_reachable(url):
34+
response = requests.get(url)
35+
36+
if response.status_code == 200:
37+
return True
38+
else:
39+
return False
40+
3341
def __get_metadata_version(df):
3442
return df['metadata_version'] .value_counts().to_dict()
3543

@@ -47,5 +55,6 @@ def report():
4755
report['number_of_datasets'] = __get_number_of_datasets(df)
4856
report['completeness_score'] = __get_completeness_score(df)
4957
report['metadata_version'] = __get_metadata_version(df)
58+
report['is_reachable'] = df['URL'].apply(__is_reachable)
5059

5160
return report

notebooks/Untitled.ipynb

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 9,
6+
"id": "ec311d94-3350-4a60-9418-e934fb65487a",
7+
"metadata": {},
8+
"outputs": [],
9+
"source": [
10+
"import braininventory"
11+
]
12+
},
13+
{
14+
"cell_type": "code",
15+
"execution_count": 10,
16+
"id": "cd60e1b5-e898-4c20-81fd-61bda774e59c",
17+
"metadata": {},
18+
"outputs": [
19+
{
20+
"data": {
21+
"text/plain": [
22+
"{'date': '2023-07-07',\n",
23+
" 'number_of_datasets': 7198,\n",
24+
" 'completeness_score': 0.997031232284329,\n",
25+
" 'metadata_version': {1.0: 5755, 2.0: 1443}}"
26+
]
27+
},
28+
"execution_count": 10,
29+
"metadata": {},
30+
"output_type": "execute_result"
31+
}
32+
],
33+
"source": [
34+
"data = braininventory.get.today()\n",
35+
"report = braininventory.get.report()\n",
36+
"report"
37+
]
38+
},
39+
{
40+
"cell_type": "code",
41+
"execution_count": 11,
42+
"id": "078104fd-1d0d-4fb9-b170-8fea75802669",
43+
"metadata": {},
44+
"outputs": [
45+
{
46+
"data": {
47+
"text/plain": [
48+
"Index(['score', 'metadata_version', 'dataset_uuid', 'bildirectory', 'exists',\n",
49+
" 'project', 'is_biccn', 'bil_uuid', 'contributorname', 'affiliation',\n",
50+
" 'award_number', 'species', 'ncbitaxonomy', 'samplelocalid', 'genotype',\n",
51+
" 'generalmodality', 'technique', 'locations', 'URL', 'temp_file',\n",
52+
" 'json_file', 'md5_coverage', 'sha256_coverage'],\n",
53+
" dtype='object')"
54+
]
55+
},
56+
"execution_count": 11,
57+
"metadata": {},
58+
"output_type": "execute_result"
59+
}
60+
],
61+
"source": [
62+
"data.keys()"
63+
]
64+
},
65+
{
66+
"cell_type": "code",
67+
"execution_count": 12,
68+
"id": "e0b560fa-fdeb-44af-9653-ecd28f29cef1",
69+
"metadata": {},
70+
"outputs": [
71+
{
72+
"data": {
73+
"text/plain": [
74+
"0 https://download.brainimagelibrary.org/f1/60/f...\n",
75+
"1 https://download.brainimagelibrary.org/90/a9/9...\n",
76+
"2 https://download.brainimagelibrary.org/dd/90/d...\n",
77+
"3 https://download.brainimagelibrary.org/9a/ae/9...\n",
78+
"4 https://download.brainimagelibrary.org/9a/ae/9...\n",
79+
" ... \n",
80+
"7193 https://download.brainimagelibrary.org/84/d8/8...\n",
81+
"7194 https://download.brainimagelibrary.org/77/72/7...\n",
82+
"7195 https://download.brainimagelibrary.org/dd/c8/d...\n",
83+
"7196 https://download.brainimagelibrary.org/6e/38/6...\n",
84+
"7197 https://download.brainimagelibrary.org/01/fc/0...\n",
85+
"Name: URL, Length: 7198, dtype: object"
86+
]
87+
},
88+
"execution_count": 12,
89+
"metadata": {},
90+
"output_type": "execute_result"
91+
}
92+
],
93+
"source": [
94+
"data['URL']"
95+
]
96+
},
97+
{
98+
"cell_type": "code",
99+
"execution_count": null,
100+
"id": "596642ad-c204-41fd-b6c8-93e3dc53fd04",
101+
"metadata": {},
102+
"outputs": [],
103+
"source": []
104+
}
105+
],
106+
"metadata": {
107+
"kernelspec": {
108+
"display_name": "Python 3",
109+
"language": "python",
110+
"name": "python3"
111+
},
112+
"language_info": {
113+
"codemirror_mode": {
114+
"name": "ipython",
115+
"version": 3
116+
},
117+
"file_extension": ".py",
118+
"mimetype": "text/x-python",
119+
"name": "python",
120+
"nbconvert_exporter": "python",
121+
"pygments_lexer": "ipython3",
122+
"version": "3.8.8"
123+
}
124+
},
125+
"nbformat": 4,
126+
"nbformat_minor": 5
127+
}

0 commit comments

Comments
 (0)