Skip to content

Commit 5ea1fdf

Browse files
committed
simplify download url, more links
1 parent 020dbe2 commit 5ea1fdf

File tree

5 files changed

+67
-24
lines changed

5 files changed

+67
-24
lines changed

app.py

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,26 @@ def render_template(template, dataset):
6969
kwargs["datasheet"] = True
7070
else:
7171
kwargs["datasheet"] = False
72+
# Check for dataset.zip file
73+
zipfile = os.path.join(dataset_folder, "dataset.zip")
74+
if os.path.exists(zipfile):
75+
kwargs["filesize"] = sizeof_fmt(os.stat(zipfile).st_size)
76+
kwargs["download_url"] = f"https://data.aifarms.org/download/{dataset}"
77+
else:
78+
kwargs["filesize"] = "N/A"
79+
kwargs["download_url"] = ""
80+
81+
# Compute download_url based on presence of urls['download'] or urls['github']
82+
urls = kwargs.get("urls", {})
83+
if not kwargs["download_url"]:
84+
if "download" in urls and urls["download"]:
85+
kwargs["download_url"] = urls["download"]
86+
elif "github" in urls and urls["github"]:
87+
kwargs["download_url"] = urls["github"]
88+
89+
keywords = set(["AIFARMS"])
90+
keywords.update(kwargs.get("keywords", ""))
91+
kwargs["aifarms_keywords"] = keywords
7292

7393
if template == "view.html":
7494
kwargs["title"] = f"{kwargs['title']} - AIFARMS Data Portal"
@@ -79,23 +99,6 @@ def render_template(template, dataset):
7999
else:
80100
kwargs["contact"] = {"name": kwargs["contact"].strip(), "email": ""}
81101

82-
dataset_folder = os.path.join(DATASETS, dataset)
83-
zipfile = os.path.join(dataset_folder, "dataset.zip")
84-
if os.path.exists(zipfile):
85-
kwargs["filesize"] = sizeof_fmt(os.stat(zipfile).st_size)
86-
else:
87-
kwargs["filesize"] = "N/A"
88-
89-
# Compute download_url based on presence of url in the dataset
90-
if kwargs.get("url") and kwargs["url"] != "":
91-
kwargs["download_url"] = kwargs["url"]
92-
else:
93-
kwargs["download_url"] = f"https://data.aifarms.org/download/{dataset}"
94-
95-
keywords = set(["AIFARMS"])
96-
keywords.update(kwargs.get("keywords", ""))
97-
kwargs["aifarms_keywords"] = keywords
98-
99102
return flask.render_template(template, **kwargs)
100103

101104

data/datasets.json

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"email": "[email protected]"
1717
},
1818
"citation": "",
19-
"keywords":["pigs"],
19+
"keywords": ["pigs"],
2020
"funding": "This work is supported by Agriculture and Food Research Initiative (AFRI) grant no. 2020-67021-32799/project accession no.1024178 from the USDA National Institute of Food and Agriculture."
2121
},
2222
"slamdataset": {
@@ -37,11 +37,40 @@
3737
"short_description": "This dataset is intended for the evaluation of visual-based localization and mapping systems in agriculture.",
3838
"description": "This dataset is intended for the evaluation of visual-based localization and mapping systems in agriculture. It includes stereo images, IMU, GPS, and wheel encoder measurements. It was collected from a ground robot in the Illinois Autonomous Farm at the University of Illinois at Urbana-Champaign. The collection campaign took place during the Summer of 2022. Different data sequences were collected twice per week in corn fields, and less often in soybean and sorghum. This dataset exhibit high variability in terms of weather conditions and growth stages. It contains challenging features like occlusions, illumination variations, weeds, dynamic objects, and rough terrain.",
3939
"images": [],
40-
"contact": {
40+
"contact": {
4141
"name": "Jose Cuaran"
4242
},
4343
"citation": "",
44-
"keywords":[],
44+
"keywords": [],
4545
"funding": "This work is supported by National Institute of Food and Agriculture grant no. 2020-67021- 32799"
46+
},
47+
"multi-camera-pig-tracking": {
48+
"title": "Multi Camera Pig Tracking",
49+
"preview": "image/multi-camera-pig-tracking/multicam-tracking.png",
50+
"authors": [
51+
"Aniket Shirke",
52+
"J. Li",
53+
"A. Green-Miller",
54+
"T. Williams",
55+
"X. Hu",
56+
"A. Luthra",
57+
"N. Ahuja",
58+
"M. Caesar"
59+
],
60+
"department": "",
61+
"created": "Jul 1, 2021",
62+
"short_description": "Tracking Grow-Finish Pigs Across Large Pens Using Multiple Cameras.",
63+
"description": "",
64+
"images": [],
65+
"contact": {
66+
"name": "Angela Green-Miller",
67+
"email": "[email protected]"
68+
},
69+
"citation": "",
70+
"keywords": ["pigs"],
71+
"funding": "",
72+
"urls": {
73+
"github": "https://github.com/AIFARMS/multi-camera-pig-tracking"
74+
}
4675
}
4776
}
2.03 MB
Loading

templates/croissant.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
{%- endif %}
2727
{%- endfor %}
2828
],
29-
{% if (url and url != '') or (filesize and filesize != 'N/A' and filesize != '') %}
29+
{% if download_url %}
3030
"distribution": [
3131
{
3232
"@type": "cr:FileSet",
3333
"@id": "{{ dataset }}.zip",
34-
"contentUrl": "{{ url if url and url != '' else download_url }}",
34+
"contentUrl": "{{ download_url }}",
3535
{% if filesize and filesize != 'N/A' and filesize != '' %}
3636
"contentSize": "{{ filesize }}",
3737
{% endif %}
@@ -47,4 +47,4 @@
4747
{%- endif %}
4848
{%- endfor %}
4949
]
50-
}
50+
}

templates/view.html

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<div id="nextToCarousel" class="col-3 position-absolute top-0 end-0" >
3939
<div class="vstack gap-3">
4040
<row>
41-
{% if (filesize and filesize != 'N/A' and filesize != '') or (url and url != '') %}
41+
{% if download_url %}
4242
<a href="{{ download_url }}"><button type="submit" data-bs-toggle="tooltip" data-bs-placement="top"
4343
title="Download" class="btn btn-secondary bi bi-cloud-download"></button></a>
4444
{% endif %}
@@ -62,6 +62,17 @@
6262
{% endfor -%}
6363
</ul>
6464
</div>
65+
{% if urls %}
66+
<div><b>Links:</b>
67+
<ul class="mb-0">
68+
{% for key, value in urls.items() %}
69+
{% if key != 'download' %}
70+
<li><a href="{{ value }}" target="_blank">{{ key|capitalize }}</a></li>
71+
{% endif %}
72+
{% endfor %}
73+
</ul>
74+
</div>
75+
{% endif %}
6576
{% if filesize and filesize != 'N/A' and filesize != '' %}
6677
<div>Download Size: {{ filesize }}</div>
6778
{% endif %}

0 commit comments

Comments
 (0)