Skip to content

Commit

Permalink
Merge pull request #383 from ral-facilities/minor-changes-from-object…
Browse files Browse the repository at this point in the history
…-storage-api

Changes from object-storage-api repo setup
  • Loading branch information
joelvdavies authored Sep 23, 2024
2 parents e75104d + 535bca4 commit a4deafc
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ replacing `<hostname>` with the actual hostname for the replica set.
For docker you may use
```bash
docker exec -i mongodb_container mongosh --username 'root' --password 'example' --authenticationDatabase=admin --eval "rs.initiate({ _id : 'rs0', members: [{ _id: 0, host: 'mongodb_container:27017' }]})"
docker exec -i ims_api_mongodb_container mongosh --username 'root' --password 'example' --authenticationDatabase=admin --eval "rs.initiate({ _id : 'rs0', members: [{ _id: 0, host: 'ims_api_mongodb_container:27017' }]})"
```
### Using mock data for testing [Optional]
Expand All @@ -242,7 +242,7 @@ to populate the database with mock data.
If you wish to do this manually the full command is
```bash
docker exec -i mongodb_container mongorestore --username "root" --password "example" --authenticationDatabase=admin --db ims --archive < ./data/mock_data.dump
docker exec -i ims_api_mongodb_container mongorestore --username "root" --password "example" --authenticationDatabase=admin --db ims --archive < ./data/mock_data.dump
```
Otherwise there is a script to generate mock data for testing purposes given in `./scripts/generate_mock_data.py`. To use it from your development environment first ensure the API is running and then execute it with
Expand Down Expand Up @@ -274,13 +274,13 @@ to update the `./data/mock_data.dump` file and commit the changes.
The parameters at the top of the file can be used to change the generated data. NOTE: This script will simply add to the existing database instance. So if you wish to update the `mock_data.dump`, you should first clear the database e.g. using
```bash
docker exec -i mongodb_container mongosh ims --username "root" --password "example" --authenticationDatabase=admin --eval "db.dropDatabase()"
docker exec -i ims_api_mongodb_container mongosh ims --username "root" --password "example" --authenticationDatabase=admin --eval "db.dropDatabase()"
```
Then generate the mock data, import the units and then update the `./data/mock_data.dump` file using `mongodump` via
```bash
docker exec -i mongodb_container mongodump --username "root" --password "example" --authenticationDatabase=admin --db ims --archive > ./data/mock_data.dump
docker exec -i ims_api_mongodb_container mongodump --username "root" --password "example" --authenticationDatabase=admin --db ims --archive > ./data/mock_data.dump
```
## Notes
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ services:

mongo-db:
image: mongo:7.0-jammy
container_name: mongodb_container
container_name: ims_api_mongodb_container
command: ["--replSet", "rs0", "--keyFile", "/etc/mongodb/keys/rs_keyfile"]
volumes:
- ./mongodb/data:/data/db
Expand Down
10 changes: 5 additions & 5 deletions inventory_management_system_api/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
"""

from pathlib import Path
from typing import Optional, List
from typing import List, Optional

from pydantic import BaseModel, ConfigDict, Field, SecretStr, field_validator
from pydantic_core.core_schema import ValidationInfo
from pydantic_settings import SettingsConfigDict, BaseSettings
from pydantic_settings import BaseSettings, SettingsConfigDict


class APIConfig(BaseModel):
Expand Down Expand Up @@ -69,9 +69,9 @@ class Config(BaseSettings):
"""
Overall configuration model for the application.
It includes attributes for the API and database configurations. The class inherits from `BaseSettings` and
automatically reads environment variables. If values are not passed in form of system environment variables at
runtime, it will attempt to read them from the .env file.
It includes attributes for the API, authentication and database configurations. The class inherits from
`BaseSettings` and automatically reads environment variables. If values are not passed in form of system environment
variables at runtime, it will attempt to read them from the .env file.
"""

api: APIConfig
Expand Down
2 changes: 1 addition & 1 deletion scripts/dev_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def run_mongodb_command(args: list[str], stdin: Optional[TextIOWrapper] = None,
"docker",
"exec",
"-i",
"mongodb_container",
"ims_api_mongodb_container",
]
+ args,
stdin=stdin,
Expand Down

0 comments on commit a4deafc

Please sign in to comment.