Skip to content

Commit

Permalink
Merge branch 'main' into feature/use-yaml-config#372
Browse files Browse the repository at this point in the history
  • Loading branch information
Reillyhewitson authored Nov 16, 2022
2 parents a24d429 + 57edaaa commit 8921643
Show file tree
Hide file tree
Showing 12 changed files with 127 additions and 37 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

<!--next-version-placeholder-->

## v5.3.0 (2022-11-16)
### Feature
* Add warning for no api ([`3c91635`](https://github.com/ral-facilities/datagateway-api/commit/3c91635bc0c3465d456a4a85c8d6c8793df408c2))

## v5.2.0 (2022-11-03)
### Feature
* Add warning that tests only work with ICAT 5 ([`d8825fd`](https://github.com/ral-facilities/datagateway-api/commit/d8825fd71740e2b2d9b387dca175110cee1f9915))
* Changes to tests so they pass with icat 5 ([`73f3c77`](https://github.com/ral-facilities/datagateway-api/commit/73f3c777f8d3841cf09537140922a9bbdd8dad7c))

### Documentation
* Update the poetry installation documentation ([`68d4267`](https://github.com/ral-facilities/datagateway-api/commit/68d426722862613358b0b136188d2b61accdc56f))

## v5.1.1 (2022-09-22)
### Fix
* Update to latest dependencies ([`11a0eeb`](https://github.com/ral-facilities/datagateway-api/commit/11a0eeb3cbc4b5db2a0fa8dcd825dbeceb6ac111))
Expand Down
25 changes: 19 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,26 @@ To maintain records of the API's dependencies,
command:

```bash
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
curl -sSL https://install.python-poetry.org | python3 -
```

The installation requires `~/.poetry/env` to be refreshed for changes to be applied.
Open a new terminal or execute the following command to ensure the installation is
completed smoothly:
The installation requires the following to be added to your `~/.bashrc` file so the installation folder is on your path.
```bash
export PATH="~/.local/bin:$PATH"
```
Then run `source ~/.bashrc` or open a new terminal and check poetry works by running `poetry --version`

If you encounter this error when installing poetry:
```
ERROR: No matching distribution found for poetry==1.2.0
```
You can try running the installer with python 3.8 with the command below:
```bash
source ~/.poetry/env
curl -sSL https://install.python-poetry.org | python3.8 -
```
Or you can specify the version you want to install from the listed versions with the command below:
```bash
curl -sSL https://install.python-poetry.org | python3 - --version 1.2.0
```

Before installing the API's dependencies, check the version of `setuptools`:
Expand Down Expand Up @@ -259,7 +270,7 @@ python3.8 --version
pyenv local 3.6.8 3.7.7 3.8.2

# Install Poetry
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
curl -sSL https://install.python-poetry.org | python3 -

# Apply changes made to file when installing Poetry
source ~/.poetry/env
Expand Down Expand Up @@ -427,9 +438,11 @@ but covering only the most used aspects of the API).

The configuration file (`config.yaml`) contains two options that will be used during the
testing of the API. Set `test_user_credentials` and `test_mechanism` appropriately for

your test environment, using `config.yaml.example` as a reference. The tests require a
connection to an instance of ICAT, so set the rest of the config as needed.


By default, this will execute the repo's tests in
Python 3.6, 3.7, 3.8, 3.9 and 3.10. For most cases, running the tests in a single Python
version will be sufficient:
Expand Down
7 changes: 7 additions & 0 deletions datagateway_api/src/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,13 @@ def load(cls, path=Path(__file__).parent.parent.parent / "config.yaml"):
try:
with open(path, encoding="utf-8") as target:
data = yaml.safe_load(target)

if "datagateway_api" not in data and "search_api" not in data:
log.warning(
" WARNING: There is no API specified in the "
"configuration file",
)

return cls(**data)
except (IOError, ValidationError) as error:
sys.exit(f"An error occurred while trying to load the config data: {error}")
Expand Down
2 changes: 2 additions & 0 deletions datagateway_api/src/datagateway_api/database/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,8 @@ class INVESTIGATION(Base, EntityHelper, metaclass=EntityMeta):
typeID = Column(
"TYPE_ID", ForeignKey("INVESTIGATIONTYPE.ID"), nullable=False, index=True,
)
fileSize = Column("FILESIZE", BigInteger)
fileCount = Column("FILECOUNT", BigInteger)

FACILITY = relationship(
"FACILITY",
Expand Down
11 changes: 10 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,16 @@ def safety(session):
f"--output={requirements.name}",
external=True,
)
session.run("safety", "check", f"--file={requirements.name}", "--full-report")
# Ignore 50916 as the latest version of pydantic does not support
# python 3.6 which is still used in production
session.run(
"safety",
"check",
f"--file={requirements.name}",
"--full-report",
"--ignore",
"50916",
)

try:
# Due to delete=False, the file must be deleted manually
Expand Down
84 changes: 58 additions & 26 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "datagateway-api"
version = "5.1.1"
version = "5.3.0"
description = "ICAT API to interface with the DataGateway"
license = "Apache-2.0"
readme = "README.md"
Expand Down Expand Up @@ -34,18 +34,15 @@ Flask-SQLAlchemy = "^2.4.4"
requests = "^2.25.1"
python-dateutil = "^2.8.1"
pydantic = "^1.8.2"
dparse = "0.5.2"

[tool.poetry.dev-dependencies]
pip-tools = "5.3.1"
Faker = "8.5.1"
black = "19.10b0"
flake8 = "^3.8.4"
flake8-bandit = "^2.1.2"
flake8-black = "^0.2.1"
flake8-bugbear = "^20.1.4"
flake8-import-order = "^0.18.1"
safety = "^1.9.0"
flake8-builtins = "^1.5.3"
flake8-broken-line = "^0.3.0"
flake8-commas = "^2.0.0"
Expand All @@ -58,6 +55,8 @@ pytest-cov = "^2.10.1"
pytest-icdiff = "^0.5"
python-semantic-release = "^7.19.2"
coverage-conditional-plugin = "^0.5.0"
safety = "^2.2.0"
flake8-black = "0.2.4"

[tool.poetry.scripts]

Expand Down
2 changes: 2 additions & 0 deletions test/datagateway_api/db/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ def create_investigation_db_data(num_entities=1):
investigation.visitId = str(uuid.uuid1())
investigation.facilityID = 1
investigation.typeID = 1
investigation.fileSize = 1073741824
investigation.fileCount = 3

set_meta_attributes(investigation)

Expand Down
2 changes: 2 additions & 0 deletions test/datagateway_api/db/test_entity_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ def test_valid_to_dict(self, datafile_entity):
"id": None,
"createId": None,
"createTime": None,
"fileCount": None,
"fileSize": None,
"doi": None,
"endDate": None,
"modId": None,
Expand Down
Loading

0 comments on commit 8921643

Please sign in to comment.