From 6b8e1e94fafa6d850598cd52d1353cb92302c7f4 Mon Sep 17 00:00:00 2001 From: Alan Kyffin Date: Tue, 16 Feb 2021 15:57:44 +0000 Subject: [PATCH 1/6] Move config.json to datagateway_api directory --- .github/workflows/ci-build.yml | 4 ++-- README.md | 2 +- datagateway_api/common/config.py | 2 +- config.json.example => datagateway_api/config.json.example | 0 test/test_config.py | 4 +++- 5 files changed, 7 insertions(+), 5 deletions(-) rename config.json.example => datagateway_api/config.json.example (100%) diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index de7cfeab..b90d9cce 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -63,9 +63,9 @@ jobs: run: touch logs.log - name: Configure log file location run: echo "`jq -r --arg REPO_DIR "$GITHUB_WORKSPACE/logs.log" \ - '.log_location=$REPO_DIR' config.json.example`" > config.json.example + '.log_location=$REPO_DIR' datagateway_api/config.json.example`" > datagateway_api/config.json.example - name: Create config.json - run: cp config.json.example config.json + run: cp datagateway_api/config.json.example datagateway_api/config.json # Install Nox, Poetry and API's dependencies - name: Install Nox diff --git a/README.md b/README.md index 2fc4f4a8..2eb0e403 100644 --- a/README.md +++ b/README.md @@ -427,8 +427,8 @@ illustrated below: ├── .pre-commit-config.yaml ├── LICENSE ├── README.md -├── config.json.example ├── datagateway_api +│ ├── config.json.example │ ├── common │ │ ├── backend.py │ │ ├── backends.py diff --git a/datagateway_api/common/config.py b/datagateway_api/common/config.py index 9b5090a4..28e4d8d1 100644 --- a/datagateway_api/common/config.py +++ b/datagateway_api/common/config.py @@ -10,7 +10,7 @@ class Config(object): - def __init__(self, path=Path(__file__).parent.parent.parent / "config.json"): + def __init__(self, path=Path(__file__).parent.parent / "config.json"): self.path = path with open(self.path) as target: self.config = json.load(target) diff --git a/config.json.example b/datagateway_api/config.json.example similarity index 100% rename from config.json.example rename to datagateway_api/config.json.example diff --git a/test/test_config.py b/test/test_config.py index 4d5da769..108f4cdc 100644 --- a/test/test_config.py +++ b/test/test_config.py @@ -8,7 +8,9 @@ @pytest.fixture() def valid_config(): - return Config(path=Path(__file__).parent.parent / "config.json.example") + return Config( + path=Path(__file__).parent.parent / "datagateway_api" / "config.json.example" + ) @pytest.fixture() From 8afe25a1337185ca6f00f8f41507bdd2716afb76 Mon Sep 17 00:00:00 2001 From: Alan Kyffin Date: Tue, 16 Feb 2021 16:25:03 +0000 Subject: [PATCH 2/6] Add wsgi.py --- README.md | 1 + datagateway_api/wsgi.py | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 datagateway_api/wsgi.py diff --git a/README.md b/README.md index 2eb0e403..db51e24e 100644 --- a/README.md +++ b/README.md @@ -429,6 +429,7 @@ illustrated below: ├── README.md ├── datagateway_api │ ├── config.json.example +│ ├── wsgi.py │ ├── common │ │ ├── backend.py │ │ ├── backends.py diff --git a/datagateway_api/wsgi.py b/datagateway_api/wsgi.py new file mode 100644 index 00000000..a31e1f21 --- /dev/null +++ b/datagateway_api/wsgi.py @@ -0,0 +1,6 @@ +import logging +import sys + +logging.basicConfig(stream=sys.stderr) + +from datagateway_api.src.main import app as application From 668d0e9fe26d0ba21444c1c932d92b143191ec73 Mon Sep 17 00:00:00 2001 From: Alan Kyffin Date: Tue, 16 Feb 2021 16:13:25 +0000 Subject: [PATCH 3/6] Add requests as a dependency --- poetry.lock | 43 ++++++++++++++++++++++++++++++++----------- pyproject.toml | 1 + 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/poetry.lock b/poetry.lock index b9d46a1d..b54a51aa 100644 --- a/poetry.lock +++ b/poetry.lock @@ -91,7 +91,7 @@ d = ["aiohttp (>=3.3.2)", "aiohttp-cors"] name = "certifi" version = "2020.11.8" description = "Python package for providing Mozilla's CA Bundle." -category = "dev" +category = "main" optional = false python-versions = "*" @@ -99,7 +99,7 @@ python-versions = "*" name = "chardet" version = "3.0.4" description = "Universal encoding detector for Python 2 and 3" -category = "dev" +category = "main" optional = false python-versions = "*" @@ -385,7 +385,7 @@ python-versions = "*" name = "idna" version = "2.10" description = "Internationalized Domain Names in Applications (IDNA)" -category = "dev" +category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" @@ -679,17 +679,17 @@ python-versions = "*" [[package]] name = "requests" -version = "2.24.0" +version = "2.25.1" description = "Python HTTP for Humans." -category = "dev" +category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" [package.dependencies] certifi = ">=2017.4.17" -chardet = ">=3.0.2,<4" +chardet = ">=3.0.2,<5" idna = ">=2.5,<3" -urllib3 = ">=1.21.1,<1.25.0 || >1.25.0,<1.25.1 || >1.25.1,<1.26" +urllib3 = ">=1.21.1,<1.27" [package.extras] security = ["pyOpenSSL (>=0.14)", "cryptography (>=1.3.4)"] @@ -793,7 +793,7 @@ python-versions = "*" name = "urllib3" version = "1.25.11" description = "HTTP library with thread-safe connection pooling, file post, and more." -category = "dev" +category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4" @@ -829,7 +829,7 @@ testing = ["pytest (>=3.5,!=3.7.3)", "pytest-checkdocs (>=1.2.3)", "pytest-flake [metadata] lock-version = "1.1" python-versions = "^3.5" -content-hash = "db66f1e49ef4c5f9929c189d886b7c6b7d4306044a31e0eed7993d3ab6e9baab" +content-hash = "4517e06de24c84bb2c343d4f94823821ba1dc09478b4cf7b315341f624712fb0" [metadata.files] aniso8601 = [ @@ -1026,20 +1026,39 @@ markupsafe = [ {file = "MarkupSafe-1.1.1-cp35-cp35m-win32.whl", hash = "sha256:6dd73240d2af64df90aa7c4e7481e23825ea70af4b4922f8ede5b9e35f78a3b1"}, {file = "MarkupSafe-1.1.1-cp35-cp35m-win_amd64.whl", hash = "sha256:9add70b36c5666a2ed02b43b335fe19002ee5235efd4b8a89bfcf9005bebac0d"}, {file = "MarkupSafe-1.1.1-cp36-cp36m-macosx_10_6_intel.whl", hash = "sha256:24982cc2533820871eba85ba648cd53d8623687ff11cbb805be4ff7b4c971aff"}, + {file = "MarkupSafe-1.1.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:d53bc011414228441014aa71dbec320c66468c1030aae3a6e29778a3382d96e5"}, {file = "MarkupSafe-1.1.1-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:00bc623926325b26bb9605ae9eae8a215691f33cae5df11ca5424f06f2d1f473"}, {file = "MarkupSafe-1.1.1-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:717ba8fe3ae9cc0006d7c451f0bb265ee07739daf76355d06366154ee68d221e"}, + {file = "MarkupSafe-1.1.1-cp36-cp36m-manylinux2010_i686.whl", hash = "sha256:3b8a6499709d29c2e2399569d96719a1b21dcd94410a586a18526b143ec8470f"}, + {file = "MarkupSafe-1.1.1-cp36-cp36m-manylinux2010_x86_64.whl", hash = "sha256:84dee80c15f1b560d55bcfe6d47b27d070b4681c699c572af2e3c7cc90a3b8e0"}, + {file = "MarkupSafe-1.1.1-cp36-cp36m-manylinux2014_aarch64.whl", hash = "sha256:b1dba4527182c95a0db8b6060cc98ac49b9e2f5e64320e2b56e47cb2831978c7"}, {file = "MarkupSafe-1.1.1-cp36-cp36m-win32.whl", hash = "sha256:535f6fc4d397c1563d08b88e485c3496cf5784e927af890fb3c3aac7f933ec66"}, {file = "MarkupSafe-1.1.1-cp36-cp36m-win_amd64.whl", hash = "sha256:b1282f8c00509d99fef04d8ba936b156d419be841854fe901d8ae224c59f0be5"}, {file = "MarkupSafe-1.1.1-cp37-cp37m-macosx_10_6_intel.whl", hash = "sha256:8defac2f2ccd6805ebf65f5eeb132adcf2ab57aa11fdf4c0dd5169a004710e7d"}, + {file = "MarkupSafe-1.1.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:bf5aa3cbcfdf57fa2ee9cd1822c862ef23037f5c832ad09cfea57fa846dec193"}, {file = "MarkupSafe-1.1.1-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:46c99d2de99945ec5cb54f23c8cd5689f6d7177305ebff350a58ce5f8de1669e"}, {file = "MarkupSafe-1.1.1-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:ba59edeaa2fc6114428f1637ffff42da1e311e29382d81b339c1817d37ec93c6"}, + {file = "MarkupSafe-1.1.1-cp37-cp37m-manylinux2010_i686.whl", hash = "sha256:6fffc775d90dcc9aed1b89219549b329a9250d918fd0b8fa8d93d154918422e1"}, + {file = "MarkupSafe-1.1.1-cp37-cp37m-manylinux2010_x86_64.whl", hash = "sha256:a6a744282b7718a2a62d2ed9d993cad6f5f585605ad352c11de459f4108df0a1"}, + {file = "MarkupSafe-1.1.1-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:195d7d2c4fbb0ee8139a6cf67194f3973a6b3042d742ebe0a9ed36d8b6f0c07f"}, {file = "MarkupSafe-1.1.1-cp37-cp37m-win32.whl", hash = "sha256:b00c1de48212e4cc9603895652c5c410df699856a2853135b3967591e4beebc2"}, {file = "MarkupSafe-1.1.1-cp37-cp37m-win_amd64.whl", hash = "sha256:9bf40443012702a1d2070043cb6291650a0841ece432556f784f004937f0f32c"}, {file = "MarkupSafe-1.1.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:6788b695d50a51edb699cb55e35487e430fa21f1ed838122d722e0ff0ac5ba15"}, {file = "MarkupSafe-1.1.1-cp38-cp38-manylinux1_i686.whl", hash = "sha256:cdb132fc825c38e1aeec2c8aa9338310d29d337bebbd7baa06889d09a60a1fa2"}, {file = "MarkupSafe-1.1.1-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:13d3144e1e340870b25e7b10b98d779608c02016d5184cfb9927a9f10c689f42"}, + {file = "MarkupSafe-1.1.1-cp38-cp38-manylinux2010_i686.whl", hash = "sha256:acf08ac40292838b3cbbb06cfe9b2cb9ec78fce8baca31ddb87aaac2e2dc3bc2"}, + {file = "MarkupSafe-1.1.1-cp38-cp38-manylinux2010_x86_64.whl", hash = "sha256:d9be0ba6c527163cbed5e0857c451fcd092ce83947944d6c14bc95441203f032"}, + {file = "MarkupSafe-1.1.1-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:caabedc8323f1e93231b52fc32bdcde6db817623d33e100708d9a68e1f53b26b"}, {file = "MarkupSafe-1.1.1-cp38-cp38-win32.whl", hash = "sha256:596510de112c685489095da617b5bcbbac7dd6384aeebeda4df6025d0256a81b"}, {file = "MarkupSafe-1.1.1-cp38-cp38-win_amd64.whl", hash = "sha256:e8313f01ba26fbbe36c7be1966a7b7424942f670f38e666995b88d012765b9be"}, + {file = "MarkupSafe-1.1.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:d73a845f227b0bfe8a7455ee623525ee656a9e2e749e4742706d80a6065d5e2c"}, + {file = "MarkupSafe-1.1.1-cp39-cp39-manylinux1_i686.whl", hash = "sha256:98bae9582248d6cf62321dcb52aaf5d9adf0bad3b40582925ef7c7f0ed85fceb"}, + {file = "MarkupSafe-1.1.1-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:2beec1e0de6924ea551859edb9e7679da6e4870d32cb766240ce17e0a0ba2014"}, + {file = "MarkupSafe-1.1.1-cp39-cp39-manylinux2010_i686.whl", hash = "sha256:7fed13866cf14bba33e7176717346713881f56d9d2bcebab207f7a036f41b850"}, + {file = "MarkupSafe-1.1.1-cp39-cp39-manylinux2010_x86_64.whl", hash = "sha256:6f1e273a344928347c1290119b493a1f0303c52f5a5eae5f16d74f48c15d4a85"}, + {file = "MarkupSafe-1.1.1-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:feb7b34d6325451ef96bc0e36e1a6c0c1c64bc1fbec4b854f4529e51887b1621"}, + {file = "MarkupSafe-1.1.1-cp39-cp39-win32.whl", hash = "sha256:22c178a091fc6630d0d045bdb5992d2dfe14e3259760e713c490da5323866c39"}, + {file = "MarkupSafe-1.1.1-cp39-cp39-win_amd64.whl", hash = "sha256:b7d644ddb4dbd407d31ffb699f1d140bc35478da613b441c582aeb7c43838dd8"}, {file = "MarkupSafe-1.1.1.tar.gz", hash = "sha256:29872e92839765e546828bb7754a68c418d927cd064fd4708fab9fe9c8bb116b"}, ] mccabe = [ @@ -1131,6 +1150,8 @@ pyyaml = [ {file = "PyYAML-5.3.1-cp37-cp37m-win_amd64.whl", hash = "sha256:73f099454b799e05e5ab51423c7bcf361c58d3206fa7b0d555426b1f4d9a3eaf"}, {file = "PyYAML-5.3.1-cp38-cp38-win32.whl", hash = "sha256:06a0d7ba600ce0b2d2fe2e78453a470b5a6e000a985dd4a4e54e436cc36b0e97"}, {file = "PyYAML-5.3.1-cp38-cp38-win_amd64.whl", hash = "sha256:95f71d2af0ff4227885f7a6605c37fd53d3a106fcab511b8860ecca9fcf400ee"}, + {file = "PyYAML-5.3.1-cp39-cp39-win32.whl", hash = "sha256:ad9c67312c84def58f3c04504727ca879cb0013b2517c85a9a253f0cb6380c0a"}, + {file = "PyYAML-5.3.1-cp39-cp39-win_amd64.whl", hash = "sha256:6034f55dab5fea9e53f436aa68fa3ace2634918e8b5994d82f3621c04ff5ed2e"}, {file = "PyYAML-5.3.1.tar.gz", hash = "sha256:b8eac752c5e14d3eca0e6dd9199cd627518cb5ec06add0de9d32baeee6fe645d"}, ] regex = [ @@ -1179,8 +1200,8 @@ regex = [ {file = "regex-2020.10.28.tar.gz", hash = "sha256:dd3e6547ecf842a29cf25123fbf8d2461c53c8d37aa20d87ecee130c89b7079b"}, ] requests = [ - {file = "requests-2.24.0-py2.py3-none-any.whl", hash = "sha256:fe75cc94a9443b9246fc7049224f75604b113c36acb93f87b80ed42c44cbb898"}, - {file = "requests-2.24.0.tar.gz", hash = "sha256:b3559a131db72c33ee969480840fff4bb6dd111de7dd27c8ee1f820f4f00231b"}, + {file = "requests-2.25.1-py2.py3-none-any.whl", hash = "sha256:c210084e36a42ae6b9219e00e48287def368a26d03a048ddad7bfee44f75871e"}, + {file = "requests-2.25.1.tar.gz", hash = "sha256:27973dd4a904a4f13b263a19c866c13b92a39ed1c964655f025f3f8d3d75b804"}, ] safety = [ {file = "safety-1.9.0-py2.py3-none-any.whl", hash = "sha256:86c1c4a031fe35bd624fce143fbe642a0234d29f7cbf7a9aa269f244a955b087"}, diff --git a/pyproject.toml b/pyproject.toml index 1323ded7..4b73b234 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,6 +19,7 @@ flask-swagger-ui = "3.25.0" PyYAML = "5.3.1" python-icat = "0.17.0" suds-community = "^0.8.4" +requests = "^2.25.1" [tool.poetry.dev-dependencies] pip-tools = "5.3.1" From 2b87c760f98cbe85f0afc3da6fc73d5f0538eb0c Mon Sep 17 00:00:00 2001 From: Alan Kyffin Date: Wed, 17 Feb 2021 09:38:54 +0000 Subject: [PATCH 4/6] Add trailing comma to appease linter --- test/test_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_config.py b/test/test_config.py index 108f4cdc..248764cb 100644 --- a/test/test_config.py +++ b/test/test_config.py @@ -9,7 +9,7 @@ @pytest.fixture() def valid_config(): return Config( - path=Path(__file__).parent.parent / "datagateway_api" / "config.json.example" + path=Path(__file__).parent.parent / "datagateway_api" / "config.json.example", ) From 8f3ffc696e18b3cec655475b36051071dc4d1bd9 Mon Sep 17 00:00:00 2001 From: Alan Kyffin Date: Wed, 17 Feb 2021 09:47:11 +0000 Subject: [PATCH 5/6] Ignore linter errors in wsgi.py --- .flake8 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.flake8 b/.flake8 index eef539f2..58cc2602 100644 --- a/.flake8 +++ b/.flake8 @@ -6,5 +6,5 @@ max-complexity = 17 max-line-length = 80 application-import-names = datagateway_api,test,util import-order-style = google -per-file-ignores = test/*:S101,util/icat_db_generator.py:S311 +per-file-ignores = test/*:S101,util/icat_db_generator.py:S311,datagateway_api/wsgi.py:E402,F401 enable-extensions=G From 1572c0cf9a118cbffc26b6006fdff28e148afda9 Mon Sep 17 00:00:00 2001 From: Alan Kyffin Date: Wed, 24 Feb 2021 11:54:02 +0000 Subject: [PATCH 6/6] Add missing python-dateutil dependency --- poetry.lock | 4 ++-- pyproject.toml | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/poetry.lock b/poetry.lock index 0ffd69c4..e03f1899 100644 --- a/poetry.lock +++ b/poetry.lock @@ -650,7 +650,7 @@ pytest = "*" name = "python-dateutil" version = "2.8.1" description = "Extensions to the standard Python datetime module" -category = "dev" +category = "main" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" @@ -841,7 +841,7 @@ testing = ["pytest (>=3.5,!=3.7.3)", "pytest-checkdocs (>=1.2.3)", "pytest-flake [metadata] lock-version = "1.1" python-versions = "^3.5" -content-hash = "2494cbdf616bbd9d2e75af3026faf972a06a8eb2ee81f353036bbae62beaa784" +content-hash = "77aef4a2b4ca9adc854dd74da351a5914a7807046dd280e4e957c6a8e3860b83" [metadata.files] aniso8601 = [ diff --git a/pyproject.toml b/pyproject.toml index 7aa761f7..8c52cca0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,6 +21,7 @@ python-icat = "0.17.0" suds-community = "^0.8.4" Flask-SQLAlchemy = "^2.4.4" requests = "^2.25.1" +python-dateutil = "^2.8.1" [tool.poetry.dev-dependencies] pip-tools = "5.3.1"