Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for docker-based mongo #200

Merged
merged 21 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
### Added

- Add DB/API methods for retrieving all cards at once ([#172](https://github.com/arcavios/scooze/pull/172))
- Add Docker support for starting MongoDB via the CLI ([#200](https://github.com/arcavios/scooze/pull/200))

### Changed

Expand Down
32 changes: 22 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,41 @@ A flexible data layer for applications working with Magic: the Gathering cards,
pip install scooze
```

2. Download and install [MongoDB](https://www.mongodb.com/docs/manual/installation/).
2. Setup the database
- Using Docker:

Scooze depends on MongoDB to run your local database.
*Make sure [Docker Desktop](https://www.docker.com/products/docker-desktop/) is running.*

*You can use scooze without MongoDB if you don't intend to use any of its database-related features.*
```
scooze setup docker
```
* This will pull the latest MongoDB issued image for your machine's distribution, and spin up the container with port 27017 bound to the host's port 27017.
iambroadband marked this conversation as resolved.
Show resolved Hide resolved
* After this, you can continue to (3) below.

3. Run the MongoDB server.
- Running MongoDB locally:

```
mongod --dbpath path/to/db/
```
Scooze depends on MongoDB to run your local database.
Download and install [MongoDB](https://www.mongodb.com/docs/manual/installation/).

*You can use scooze without MongoDB if you don't intend to use any of its database-related features.*

*Your local database can be stored wherever you want, but make sure you create the directory first. This is commonly stored at `/data/db`*

Run the MongoDB server with

*Your local database can be stored wherever you want, but make sure you create the directory first. This is commonly stored at `/data/db`*
```
mongod --dbpath path/to/db/
```

4. Run the scooze CLI tool (installed with pip install) to add some data to your local database.
3. Run the scooze CLI tool (installed with pip install) to add some data to your local database.

```
scooze -h
scooze load-cards oracle
scooze run
```

5. Use scooze in your application code!
4. Use scooze in your application code!

```
from scooze.api import ScoozeApi
Expand Down
118 changes: 106 additions & 12 deletions poetry.lock

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

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ motor = "^3.2.0"
requests = "^2.31.0"
frozendict = "^2.3.8"
ijson = "^3.2.3"
docker = "^6.1.3"

[tool.poetry.group.dev.dependencies]
pytest = "^7.4.0"
Expand Down
2 changes: 1 addition & 1 deletion src/scooze/bulkdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def download_bulk_data_file(
# TODO(#74): flag for check vs existing file; don't overwrite with same file or older version
with requests.get(uri, stream=True) as r:
r.raise_for_status()
os.makedirs(os.path.dirname(bulk_file_dir), exist_ok=True)
os.makedirs(bulk_file_dir, exist_ok=True)
file_name = f"{bulk_file_dir}/{bulk_file_type}.json"
with open(file_name, "wb") as f:
for chunk in r.iter_content(chunk_size=None):
Expand Down
Loading