-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from nimh-dsst/add-work-in-doc
Generate work for document
- Loading branch information
Showing
20 changed files
with
369 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,5 @@ _version.py | |
pdfs/* | ||
test-pdf/*.pdf | ||
dsst_etl.egg-info/* | ||
uv.lock | ||
uv.lock | ||
.coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
alembic/versions/4a908d10b459_update_non_null_of_document_in_works_.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
"""update non-null of document in works table | ||
Revision ID: 4a908d10b459 | ||
Revises: 360c65a62392 | ||
Create Date: 2024-11-21 16:40:56.966690 | ||
""" | ||
from typing import Sequence, Union | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = '4a908d10b459' | ||
down_revision: Union[str, None] = '360c65a62392' | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.alter_column('works', 'initial_document_id', | ||
existing_type=sa.INTEGER(), | ||
nullable=True) | ||
op.alter_column('works', 'primary_document_id', | ||
existing_type=sa.INTEGER(), | ||
nullable=True) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.alter_column('works', 'primary_document_id', | ||
existing_type=sa.INTEGER(), | ||
nullable=False) | ||
op.alter_column('works', 'initial_document_id', | ||
existing_type=sa.INTEGER(), | ||
nullable=False) | ||
# ### end Alembic commands ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import os | ||
from .config import config | ||
|
||
|
||
def get_compute_context_id(): | ||
return hash(f"{os.environ.get('HOSTNAME')}_{os.environ.get('USERNAME')}") | ||
return hash(f"{config.HOSTNAME}_{config.USERNAME}") | ||
|
||
|
||
def get_bucket_name(): | ||
bucket_name = os.getenv('S3_BUCKET_NAME') | ||
bucket_name = config.S3_BUCKET_NAME | ||
if not bucket_name: | ||
raise ValueError("S3_BUCKET_NAME environment variable is not set") | ||
return bucket_name | ||
return bucket_name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from dotenv import dotenv_values | ||
|
||
|
||
class Config: | ||
def __init__(self, config_dict): | ||
for key, value in config_dict.items(): | ||
setattr(self, key, value) | ||
|
||
|
||
# Load the environment variables from the .env file | ||
config = Config(dotenv_values(".env")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,25 @@ | ||
import os | ||
import logging | ||
|
||
from dsst_etl import get_db_engine | ||
from sqlalchemy import create_engine | ||
from sqlalchemy.orm import sessionmaker | ||
from sqlalchemy_utils import create_database, database_exists | ||
|
||
from dsst_etl import get_db_engine | ||
|
||
from .models import Base | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def get_db_session(): | ||
engine = get_db_engine() | ||
def get_db_session(is_test=False): | ||
engine = get_db_engine(is_test) | ||
Session = sessionmaker(bind=engine) | ||
return Session() | ||
|
||
|
||
def init_db(): | ||
engine = get_db_engine() | ||
def init_db(is_test=False): | ||
engine = get_db_engine(is_test) | ||
|
||
if not database_exists(engine.url): | ||
logger.info("Creating database.....") | ||
create_database(engine.url) | ||
Base.metadata.create_all(engine) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.