-
Notifications
You must be signed in to change notification settings - Fork 19.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
333 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,205 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
|
||
{ | ||
"name": "Python", | ||
"type": "python", | ||
"request": "launch", | ||
"stopOnEntry": true, | ||
"pythonPath": "${config.python.pythonPath}", | ||
"program": "${file}", | ||
"cwd": "${workspaceRoot}", | ||
"env": null, | ||
"envFile": "${workspaceRoot}/.env", | ||
"debugOptions": [ | ||
"WaitOnAbnormalExit", | ||
"WaitOnNormalExit", | ||
"RedirectOutput" | ||
] | ||
}, | ||
{ | ||
"name": "PySpark", | ||
"type": "python", | ||
"request": "launch", | ||
"stopOnEntry": true, | ||
"osx": { | ||
"pythonPath": "${env.SPARK_HOME}/bin/spark-submit" | ||
}, | ||
"windows": { | ||
"pythonPath": "${env.SPARK_HOME}/bin/spark-submit.cmd" | ||
}, | ||
"linux": { | ||
"pythonPath": "${env.SPARK_HOME}/bin/spark-submit" | ||
}, | ||
"program": "${file}", | ||
"cwd": "${workspaceRoot}", | ||
"env": null, | ||
"envFile": "${workspaceRoot}/.env", | ||
"debugOptions": [ | ||
"WaitOnAbnormalExit", | ||
"WaitOnNormalExit", | ||
"RedirectOutput" | ||
] | ||
}, | ||
{ | ||
"name": "Python Module", | ||
"type": "python", | ||
"request": "launch", | ||
"stopOnEntry": true, | ||
"pythonPath": "${config.python.pythonPath}", | ||
"module": "module.name", | ||
"cwd": "${workspaceRoot}", | ||
"env": null, | ||
"envFile": "${workspaceRoot}/.env", | ||
"debugOptions": [ | ||
"WaitOnAbnormalExit", | ||
"WaitOnNormalExit", | ||
"RedirectOutput" | ||
] | ||
}, | ||
{ | ||
"name": "Integrated Terminal/Console", | ||
"type": "python", | ||
"request": "launch", | ||
"stopOnEntry": true, | ||
"pythonPath": "${config.python.pythonPath}", | ||
"program": "${file}", | ||
"cwd": null, | ||
"console": "integratedTerminal", | ||
"env": null, | ||
"envFile": "${workspaceRoot}/.env", | ||
"debugOptions": [ | ||
"WaitOnAbnormalExit", | ||
"WaitOnNormalExit" | ||
] | ||
}, | ||
{ | ||
"name": "External Terminal/Console", | ||
"type": "python", | ||
"request": "launch", | ||
"stopOnEntry": true, | ||
"pythonPath": "${config.python.pythonPath}", | ||
"program": "${file}", | ||
"cwd": null, | ||
"console": "externalTerminal", | ||
"env": null, | ||
"envFile": "${workspaceRoot}/.env", | ||
"debugOptions": [ | ||
"WaitOnAbnormalExit", | ||
"WaitOnNormalExit" | ||
] | ||
}, | ||
{ | ||
"name": "Django", | ||
"type": "python", | ||
"request": "launch", | ||
"stopOnEntry": true, | ||
"pythonPath": "${config.python.pythonPath}", | ||
"program": "${workspaceRoot}/manage.py", | ||
"cwd": "${workspaceRoot}", | ||
"args": [ | ||
"runserver", | ||
"--noreload" | ||
], | ||
"env": null, | ||
"envFile": "${workspaceRoot}/.env", | ||
"debugOptions": [ | ||
"WaitOnAbnormalExit", | ||
"WaitOnNormalExit", | ||
"RedirectOutput", | ||
"DjangoDebugging" | ||
] | ||
}, | ||
{ | ||
"name": "Flask", | ||
"type": "python", | ||
"request": "launch", | ||
"stopOnEntry": false, | ||
"pythonPath": "${config.python.pythonPath}", | ||
"program": "fully qualified path fo 'flask' executable. Generally located along with python interpreter", | ||
"cwd": "${workspaceRoot}", | ||
"env": { | ||
"FLASK_APP": "${workspaceRoot}/quickstart/app.py" | ||
}, | ||
"args": [ | ||
"run", | ||
"--no-debugger", | ||
"--no-reload" | ||
], | ||
"envFile": "${workspaceRoot}/.env", | ||
"debugOptions": [ | ||
"WaitOnAbnormalExit", | ||
"WaitOnNormalExit", | ||
"RedirectOutput" | ||
] | ||
}, | ||
{ | ||
"name": "Flask (old)", | ||
"type": "python", | ||
"request": "launch", | ||
"stopOnEntry": false, | ||
"pythonPath": "${config.python.pythonPath}", | ||
"program": "${workspaceRoot}/run.py", | ||
"cwd": "${workspaceRoot}", | ||
"args": [], | ||
"env": null, | ||
"envFile": "${workspaceRoot}/.env", | ||
"debugOptions": [ | ||
"WaitOnAbnormalExit", | ||
"WaitOnNormalExit", | ||
"RedirectOutput" | ||
] | ||
}, | ||
{ | ||
"name": "Pyramid", | ||
"type": "python", | ||
"request": "launch", | ||
"stopOnEntry": true, | ||
"pythonPath": "${config.python.pythonPath}", | ||
"cwd": "${workspaceRoot}", | ||
"env": null, | ||
"envFile": "${workspaceRoot}/.env", | ||
"args": [ | ||
"${workspaceRoot}/development.ini" | ||
], | ||
"debugOptions": [ | ||
"WaitOnAbnormalExit", | ||
"WaitOnNormalExit", | ||
"RedirectOutput", | ||
"Pyramid" | ||
] | ||
}, | ||
{ | ||
"name": "Watson", | ||
"type": "python", | ||
"request": "launch", | ||
"stopOnEntry": true, | ||
"pythonPath": "${config.python.pythonPath}", | ||
"program": "${workspaceRoot}/console.py", | ||
"cwd": "${workspaceRoot}", | ||
"args": [ | ||
"dev", | ||
"runserver", | ||
"--noreload=True" | ||
], | ||
"env": null, | ||
"envFile": "${workspaceRoot}/.env", | ||
"debugOptions": [ | ||
"WaitOnAbnormalExit", | ||
"WaitOnNormalExit", | ||
"RedirectOutput" | ||
] | ||
}, | ||
{ | ||
"name": "Attach (Remote Debug)", | ||
"type": "python", | ||
"request": "attach", | ||
"localRoot": "${workspaceRoot}", | ||
"remoteRoot": "${workspaceRoot}", | ||
"port": 3000, | ||
"secret": "my_secret", | ||
"host": "localhost" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import os | ||
import tarfile | ||
import zipfile | ||
from six.moves.urllib.request import pathname2url | ||
from six.moves.urllib.parse import urljoin | ||
from keras.utils.data_utils import get_file | ||
from keras.utils.data_utils import validate_file | ||
from keras.utils.data_utils import _hash_file | ||
from keras import activations | ||
from keras import regularizers | ||
|
||
"""Tests get_file from a url, plus extraction and validation. | ||
""" | ||
dirname = 'data_utils' | ||
|
||
with open('test.txt', 'w') as text_file: | ||
text_file.write('Float like a butterfly, sting like a bee.') | ||
|
||
with tarfile.open('test.tar.gz', 'w:gz') as tar_file: | ||
tar_file.add('test.txt') | ||
|
||
with zipfile.ZipFile('test.zip', 'w') as zip_file: | ||
zip_file.write('test.txt') | ||
|
||
origin = urljoin('file://', pathname2url(os.path.abspath('test.tar.gz'))) | ||
|
||
path = get_file(dirname, origin, untar=True) | ||
filepath = path + '.tar.gz' | ||
hashval_sha256 = _hash_file(filepath) | ||
hashval_md5 = _hash_file(filepath, algorithm='md5') | ||
path = get_file(dirname, origin, md5_hash=hashval_md5, untar=True) | ||
path = get_file(filepath, origin, file_hash=hashval_sha256, extract=True) | ||
assert os.path.exists(filepath) | ||
assert validate_file(filepath, hashval_sha256) | ||
assert validate_file(filepath, hashval_md5) | ||
os.remove(filepath) | ||
os.remove('test.tar.gz') | ||
|
||
origin = urljoin('file://', pathname2url(os.path.abspath('test.zip'))) | ||
|
||
hashval_sha256 = _hash_file('test.zip') | ||
hashval_md5 = _hash_file('test.zip', algorithm='md5') | ||
path = get_file(dirname, origin, md5_hash=hashval_md5, extract=True) | ||
path = get_file(dirname, origin, file_hash=hashval_sha256, extract=True) | ||
assert os.path.exists(path) | ||
assert validate_file(path, hashval_sha256) | ||
assert validate_file(path, hashval_md5) | ||
|
||
os.remove(path) | ||
os.remove('test.txt') | ||
os.remove('test.zip') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<<<<<<< HEAD | ||
======= | ||
"""Tests for functions in data_utils.py. | ||
""" | ||
>>>>>>> b152b5e... data_utils.py and data_utils_test.py updated based on review (#5861) | ||
import os | ||
import pytest | ||
import tarfile | ||
import zipfile | ||
from six.moves.urllib.request import pathname2url | ||
from six.moves.urllib.parse import urljoin | ||
from keras.utils.data_utils import get_file | ||
from keras.utils.data_utils import validate_file | ||
from keras.utils.data_utils import _hash_file | ||
from keras import activations | ||
from keras import regularizers | ||
|
||
|
||
def test_data_utils(): | ||
<<<<<<< HEAD | ||
======= | ||
"""Tests get_file from a url, plus extraction and validation. | ||
""" | ||
>>>>>>> b152b5e... data_utils.py and data_utils_test.py updated based on review (#5861) | ||
dirname = 'data_utils' | ||
|
||
with open('test.txt', 'w') as text_file: | ||
text_file.write('Float like a butterfly, sting like a bee.') | ||
|
||
with tarfile.open('test.tar.gz', 'w:gz') as tar_file: | ||
tar_file.add('test.txt') | ||
|
||
with zipfile.ZipFile('test.zip', 'w') as zip_file: | ||
zip_file.write('test.txt') | ||
|
||
<<<<<<< HEAD | ||
|
||
origin = urljoin("file://", pathname2url(os.path.abspath('test.tar.gz'))) | ||
======= | ||
origin = urljoin('file://', pathname2url(os.path.abspath('test.tar.gz'))) | ||
>>>>>>> b152b5e... data_utils.py and data_utils_test.py updated based on review (#5861) | ||
|
||
path = get_file(dirname, origin, untar=True) | ||
filepath = path + '.tar.gz' | ||
hashval_sha256 = _hash_file(filepath) | ||
hashval_md5 = _hash_file(filepath, algorithm='md5') | ||
path = get_file(dirname, origin, md5_hash=hashval_md5, untar=True) | ||
path = get_file(filepath, origin, file_hash=hashval_sha256, extract=True) | ||
assert os.path.exists(filepath) | ||
assert validate_file(filepath, hashval_sha256) | ||
assert validate_file(filepath, hashval_md5) | ||
os.remove(filepath) | ||
os.remove('test.tar.gz') | ||
|
||
<<<<<<< HEAD | ||
|
||
origin = urljoin("file://", pathname2url(os.path.abspath('test.zip'))) | ||
======= | ||
origin = urljoin('file://', pathname2url(os.path.abspath('test.zip'))) | ||
>>>>>>> b152b5e... data_utils.py and data_utils_test.py updated based on review (#5861) | ||
|
||
hashval_sha256 = _hash_file('test.zip') | ||
hashval_md5 = _hash_file('test.zip', algorithm='md5') | ||
path = get_file(dirname, origin, md5_hash=hashval_md5, extract=True) | ||
path = get_file(dirname, origin, file_hash=hashval_sha256, extract=True) | ||
assert os.path.exists(path) | ||
assert validate_file(path, hashval_sha256) | ||
assert validate_file(path, hashval_md5) | ||
|
||
os.remove(path) | ||
os.remove('test.txt') | ||
os.remove('test.zip') | ||
|
||
if __name__ == '__main__': | ||
pytest.main([__file__]) |