Skip to content

Commit 9bb64ab

Browse files
committed
updating script entry point
1 parent 876e030 commit 9bb64ab

File tree

4 files changed

+45
-9
lines changed

4 files changed

+45
-9
lines changed

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- name: Install Package from Local
2626
run: pip install .
2727
- name: Download Dataset
28-
run: download-eca -u ${{ secrets.SYNAPSE_USERNAME }} -p ${{ secrets.SYNAPSE_PASSWORD }}
28+
run: ecadataset download -u ${{ secrets.SYNAPSE_USERNAME }} -p ${{ secrets.SYNAPSE_PASSWORD }}
2929
- name: Run Tests
3030
run: python -m unittest
3131

@@ -51,7 +51,7 @@ jobs:
5151
- name: Install Package from PyPI
5252
run: pip install --extra-index-url https://test.pypi.org/simple/ ecadataset
5353
- name: Download Dataset
54-
run: download-eca -u ${{ secrets.SYNAPSE_USERNAME }} -p ${{ secrets.SYNAPSE_PASSWORD }}
54+
run: ecadataset download -u ${{ secrets.SYNAPSE_USERNAME }} -p ${{ secrets.SYNAPSE_PASSWORD }}
5555
- name: Run Tests
5656
run: python -m unittest
5757

@@ -76,6 +76,6 @@ jobs:
7676
- name: Install Package from PyPI
7777
run: pip install ecadataset
7878
- name: Download Dataset
79-
run: download-eca -u ${{ secrets.SYNAPSE_USERNAME }} -p ${{ secrets.SYNAPSE_PASSWORD }}
79+
run: ecadataset download -u ${{ secrets.SYNAPSE_USERNAME }} -p ${{ secrets.SYNAPSE_PASSWORD }}
8080
- name: Run Tests
8181
run: python -m unittest

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@ pip install ecadataset
1010
```
1111
and run the download command...
1212
```bash
13-
download-eca -d path/to/dataset
13+
ecadataset download -d path/to/dataset
14+
```
15+
You'll be prompted for your synapse credentials and the data will be downloaded.
16+
You may also check an existing copy of the dataset with the check command...
17+
```bash
18+
ecadataset check -d path/to/dataset
1419
```
15-
You'll be prompted for your synapse credentials and the data will be downloaded.
1620

1721
## Usage
1822

bin/download-eca renamed to bin/ecadataset

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
#!/usr/bin/env python
2-
2+
import argparse
33
import synapseclient
44
import synapseutils
55
from getpass import getpass
66
from os import devnull
77
from contextlib import redirect_stdout
8-
import argparse
8+
from glob import glob
9+
from json import load
10+
from os.path import exists
911

1012
ECA_SYNAPSE_ID = "syn32148000"
1113

@@ -24,10 +26,40 @@ def download(dataset_path, username, password):
2426
synapseutils.syncFromSynapse(syn, ECA_SYNAPSE_ID, path=dataset_path, manifest="suppress")
2527
print("Download finished.\n")
2628

29+
def check(dataset_path):
30+
print("Checking for missing files in \"" + dataset_path + "\".")
31+
32+
manifest_files = glob(dataset_path + "/*/manifest.json")
33+
if len(manifest_files) < 2:
34+
print("Missing manifest files detected!")
35+
return
36+
samples = []
37+
for manifest_file in manifest_files:
38+
with open(manifest_file) as file:
39+
samples += load(file)
40+
41+
for sample in samples:
42+
image_exists = exists(dataset_path + "/" + sample["image_file"])
43+
mask_exists = exists(dataset_path + "/" + sample["mask_file"])
44+
if not image_exists or not mask_exists:
45+
print("Missing samples detected!")
46+
return
47+
48+
print("Dataset is complete.")
49+
2750
if __name__ == "__main__":
2851
parser = argparse.ArgumentParser()
52+
parser.add_argument(nargs=1, dest='command', default=None, choices=["download", "check"])
2953
parser.add_argument('-d', '--dir', dest='directory', default="eca-data", help="The directory to download the dataset to", metavar="\b")
3054
parser.add_argument('-u', '--user', dest='username', default=None, help="Synapse username", metavar="\b")
3155
parser.add_argument('-p', '--pass', dest='password', default=None, help="Synapse password", metavar="\b")
3256
args = parser.parse_args()
33-
download(args.directory, args.username, args.password)
57+
58+
args.command = args.command[0]
59+
60+
if args.command == "download":
61+
download(args.directory, args.username, args.password)
62+
elif args.command == "check":
63+
check(args.directory)
64+
else:
65+
raise Exception("Invalid command! Options are \"download\", and \"check\".")

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
license='MIT',
1818
package_dir={'':'src'},
1919
packages=['ecadataset'],
20-
scripts=['bin/download-eca'],
20+
scripts=['bin/ecadataset'],
2121
install_requires=['synapseclient', 'pillow', 'numpy']
2222
)

0 commit comments

Comments
 (0)