Skip to content

Commit

Permalink
Merge pull request #11 from JBorrow/local-storage
Browse files Browse the repository at this point in the history
[DRAFT] Librarian V2
  • Loading branch information
JBorrow authored Jan 10, 2024
2 parents 954e3b8 + 5d33295 commit f607d2c
Show file tree
Hide file tree
Showing 102 changed files with 6,207 additions and 4,026 deletions.
66 changes: 0 additions & 66 deletions .circleci/config.yml

This file was deleted.

12 changes: 0 additions & 12 deletions .coveragerc

This file was deleted.

19 changes: 19 additions & 0 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Tests

on: [push, pull_request, pull_request_target]

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: "pip"

- run: pip install -e ".[dev]"

- run: pytest --cov
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ eggs/
.eggs/
*.egg
container/secrets
env/*
env*/*
*.DS_Store*
18 changes: 18 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Run Librarian Server",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/scripts/runserver.py",
"justMyCode": true,
"env": {
"LIBRARIAN_CONFIG_PATH": "${workspaceFolder}/env/server-config.json"
}
}
]
}
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"python.REPL.enableREPLSmartSend": false,
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"python.testing.pytestPath": "/Users/borrow-adm/Documents/SimonsObs/librarian/env311/bin/pytest",
}
31 changes: 18 additions & 13 deletions alembic/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,23 @@
config = context.config
fileConfig(config.config_file_name)

from librarian_server import app, db
target_metadata = db.metadata
from librarian_server import app, engine

from librarian_server.settings import server_settings
from librarian_server.database import Base, engine

target_metadata = Base.metadata

def run_migrations_offline():
"""Run migrations in 'offline' mode -- all we need is a URL.
"""
url = app.config['SQLALCHEMY_DATABASE_URI']
url = server_settings.sqlalchemy_database_uri
context.configure(
url=url,
target_metadata=target_metadata,
literal_binds=True
literal_binds=True,
render_as_batch=True,
)

with app.app_context():
Expand All @@ -43,15 +47,16 @@ def run_migrations_online():
connection.
"""
with app.app_context():
with db.engine.connect() as connection:
context.configure(
connection=connection,
target_metadata=target_metadata
)

with context.begin_transaction():
context.run_migrations()

with engine.connect() as connection:
context.configure(
connection=connection,
target_metadata=target_metadata,
render_as_batch=True,
)

with context.begin_transaction():
context.run_migrations()


if context.is_offline_mode():
Expand Down
Loading

0 comments on commit f607d2c

Please sign in to comment.