Skip to content

Commit

Permalink
Improve Discovery Provider IDE Integration (#1626)
Browse files Browse the repository at this point in the history
  • Loading branch information
piazzatron committed Jul 8, 2021
1 parent 0509340 commit cefbc03
Show file tree
Hide file tree
Showing 278 changed files with 11,735 additions and 9,267 deletions.
2 changes: 0 additions & 2 deletions discovery-provider/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,5 @@ cov_html/*

build/

.vscode/

# redis dumps
*_dump
15 changes: 15 additions & 0 deletions discovery-provider/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// With this setup, we get linting via pylint, typechecking via mypy,
// and formatting via black.
"python.linting.pylintEnabled": true, // This enables basic linting
"python.linting.mypyEnabled": true, // This gives us typing
"python.linting.lintOnSave": true, // lint on save
"python.linting.maxNumberOfProblems": 1000, // set high max errors
"python.linting.pylintCategorySeverity.convention": "Warning",
"python.linting.pylintCategorySeverity.refactor": "Warning",
"python.pythonPath": "/usr/bin/python3",
"python.formatting.provider": "black", // This gives us autoforatting
"editor.formatOnSave": true,
"python.analysis.typeCheckingMode": "basic",
"python.languageServer": "Pylance"
}
20 changes: 9 additions & 11 deletions discovery-provider/alembic/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,11 @@ def run_migrations_offline():
"""
url = config.get_main_option("sqlalchemy.url")

audius_db_url = os.getenv('audius_db_url')
audius_db_url = os.getenv("audius_db_url")
if audius_db_url:
url = audius_db_url

context.configure(
url=url, target_metadata=target_metadata, literal_binds=True)
context.configure(url=url, target_metadata=target_metadata, literal_binds=True)

with context.begin_transaction():
context.run_migrations()
Expand All @@ -55,25 +54,24 @@ def run_migrations_online():
and associate a connection with the context.
"""
audius_db_url = os.getenv('audius_db_url')
audius_db_url = os.getenv("audius_db_url")

if audius_db_url:
config.set_main_option('sqlalchemy.url', audius_db_url)
config.set_main_option("sqlalchemy.url", audius_db_url)

connectable = engine_from_config(
config.get_section(config.config_ini_section),
prefix='sqlalchemy.',
poolclass=pool.NullPool)
prefix="sqlalchemy.",
poolclass=pool.NullPool,
)

with connectable.connect() as connection:
context.configure(
connection=connection,
target_metadata=target_metadata
)
context.configure(connection=connection, target_metadata=target_metadata)

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


if context.is_offline_mode():
run_migrations_offline()
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@


# revision identifiers, used by Alembic.
revision = '042c55d0efda'
down_revision = 'e298de2becf2'
revision = "042c55d0efda"
down_revision = "e298de2becf2"
branch_labels = None
depends_on = None


def upgrade():
op.drop_column('users', 'is_ready')
op.drop_column("users", "is_ready")


def downgrade():
op.add_column('users', sa.Column('is_ready', sa.Boolean(), nullable=True))
op.add_column("users", sa.Column("is_ready", sa.Boolean(), nullable=True))
op.execute("UPDATE users SET is_ready = true")
op.alter_column('users', 'is_ready', nullable=False)
op.alter_column("users", "is_ready", nullable=False)
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,19 @@


# revision identifiers, used by Alembic.
revision = '05e2eeb2bd03'
down_revision = '6cf96b71cf3d'
revision = "05e2eeb2bd03"
down_revision = "6cf96b71cf3d"
branch_labels = None
depends_on = None


def upgrade():
# Add the user playlist library column as JSONB, which stores the folder structure
# for a user's favorite playlists
op.add_column('users', sa.Column('playlist_library', postgresql.JSONB(), nullable=True))
op.add_column(
"users", sa.Column("playlist_library", postgresql.JSONB(), nullable=True)
)


def downgrade():
op.drop_column('users', 'playlist_library')
op.drop_column("users", "playlist_library")
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,46 @@
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = '15c49e56770d'
down_revision = 'cc7540f26188'
revision = "15c49e56770d"
down_revision = "cc7540f26188"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('playlists',
sa.Column('blockhash', sa.String(), nullable=False),
sa.Column('blocknumber', sa.Integer(), nullable=False),
sa.Column('playlist_id', sa.Integer(), nullable=False),
sa.Column('playlist_owner_id', sa.Integer(), nullable=False),
sa.Column('is_album', sa.Boolean(), nullable=False),
sa.Column('is_private', sa.Boolean(), nullable=False),
sa.Column('playlist_name', sa.String(), nullable=True),
sa.Column('playlist_contents', postgresql.JSONB(astext_type=sa.Text()), nullable=False),
sa.Column('playlist_image_multihash', sa.String(), nullable=True),
sa.Column('is_current', sa.Boolean(), nullable=False),
sa.Column('is_delete', sa.Boolean(), nullable=False),
sa.Column('timestamp', sa.DateTime(), nullable=False),
sa.ForeignKeyConstraint(['blockhash'], ['blocks.blockhash'], ),
sa.ForeignKeyConstraint(['blocknumber'], ['blocks.number'], ),
sa.PrimaryKeyConstraint('is_current', 'playlist_id', 'playlist_owner_id', 'blockhash')
op.create_table(
"playlists",
sa.Column("blockhash", sa.String(), nullable=False),
sa.Column("blocknumber", sa.Integer(), nullable=False),
sa.Column("playlist_id", sa.Integer(), nullable=False),
sa.Column("playlist_owner_id", sa.Integer(), nullable=False),
sa.Column("is_album", sa.Boolean(), nullable=False),
sa.Column("is_private", sa.Boolean(), nullable=False),
sa.Column("playlist_name", sa.String(), nullable=True),
sa.Column(
"playlist_contents", postgresql.JSONB(astext_type=sa.Text()), nullable=False
),
sa.Column("playlist_image_multihash", sa.String(), nullable=True),
sa.Column("is_current", sa.Boolean(), nullable=False),
sa.Column("is_delete", sa.Boolean(), nullable=False),
sa.Column("timestamp", sa.DateTime(), nullable=False),
sa.ForeignKeyConstraint(
["blockhash"],
["blocks.blockhash"],
),
sa.ForeignKeyConstraint(
["blocknumber"],
["blocks.number"],
),
sa.PrimaryKeyConstraint(
"is_current", "playlist_id", "playlist_owner_id", "blockhash"
),
)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('playlists')
op.drop_table("playlists")
# ### end Alembic commands ###
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,23 @@


# revision identifiers, used by Alembic.
revision = '1b9c292e14b9'
down_revision = '80ed43392e52'
revision = "1b9c292e14b9"
down_revision = "80ed43392e52"
branch_labels = None
depends_on = None


def upgrade():
op.add_column('aggregate_daily_unique_users_metrics', sa.Column('summed_count', sa.Integer(), nullable=True))
op.add_column('aggregate_monthly_unique_users_metrics', sa.Column('summed_count', sa.Integer(), nullable=True))
op.add_column(
"aggregate_daily_unique_users_metrics",
sa.Column("summed_count", sa.Integer(), nullable=True),
)
op.add_column(
"aggregate_monthly_unique_users_metrics",
sa.Column("summed_count", sa.Integer(), nullable=True),
)


def downgrade():
op.drop_column('aggregate_daily_unique_users_metrics', 'summed_count')
op.drop_column('aggregate_monthly_unique_users_metrics', 'summed_count')
op.drop_column("aggregate_daily_unique_users_metrics", "summed_count")
op.drop_column("aggregate_monthly_unique_users_metrics", "summed_count")
105 changes: 65 additions & 40 deletions discovery-provider/alembic/versions/23c4b650ed97_fields_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,55 +10,80 @@
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = '23c4b650ed97'
down_revision = '45e5117f4419'
revision = "23c4b650ed97"
down_revision = "45e5117f4419"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('follows', sa.Column('created_at', sa.DateTime(), nullable=False))
op.drop_column('follows', 'timestamp')
op.add_column('playlists', sa.Column('created_at', sa.DateTime(), nullable=False))
op.add_column('playlists', sa.Column('upc', sa.String(), nullable=True))
op.add_column('playlists', sa.Column('updated_at', sa.DateTime(), nullable=False))
op.drop_column('playlists', 'timestamp')
op.add_column('reposts', sa.Column('created_at', sa.DateTime(), nullable=False))
op.drop_column('reposts', 'timestamp')
op.add_column('saves', sa.Column('created_at', sa.DateTime(), nullable=False))
op.drop_column('saves', 'timestamp')
op.add_column('tracks', sa.Column('created_at', sa.DateTime(), nullable=False))
op.add_column('tracks', sa.Column('description', sa.String(), nullable=True))
op.add_column('tracks', sa.Column('isrc', sa.String(), nullable=True))
op.add_column('tracks', sa.Column('iswc', sa.String(), nullable=True))
op.add_column('tracks', sa.Column('license', sa.String(), nullable=True))
op.add_column('tracks', sa.Column('updated_at', sa.DateTime(), nullable=False))
op.drop_column('tracks', 'timestamp')
op.add_column('users', sa.Column('created_at', sa.DateTime(), nullable=False))
op.add_column('users', sa.Column('updated_at', sa.DateTime(), nullable=False))
op.add_column("follows", sa.Column("created_at", sa.DateTime(), nullable=False))
op.drop_column("follows", "timestamp")
op.add_column("playlists", sa.Column("created_at", sa.DateTime(), nullable=False))
op.add_column("playlists", sa.Column("upc", sa.String(), nullable=True))
op.add_column("playlists", sa.Column("updated_at", sa.DateTime(), nullable=False))
op.drop_column("playlists", "timestamp")
op.add_column("reposts", sa.Column("created_at", sa.DateTime(), nullable=False))
op.drop_column("reposts", "timestamp")
op.add_column("saves", sa.Column("created_at", sa.DateTime(), nullable=False))
op.drop_column("saves", "timestamp")
op.add_column("tracks", sa.Column("created_at", sa.DateTime(), nullable=False))
op.add_column("tracks", sa.Column("description", sa.String(), nullable=True))
op.add_column("tracks", sa.Column("isrc", sa.String(), nullable=True))
op.add_column("tracks", sa.Column("iswc", sa.String(), nullable=True))
op.add_column("tracks", sa.Column("license", sa.String(), nullable=True))
op.add_column("tracks", sa.Column("updated_at", sa.DateTime(), nullable=False))
op.drop_column("tracks", "timestamp")
op.add_column("users", sa.Column("created_at", sa.DateTime(), nullable=False))
op.add_column("users", sa.Column("updated_at", sa.DateTime(), nullable=False))
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('users', 'updated_at')
op.drop_column('users', 'created_at')
op.add_column('tracks', sa.Column('timestamp', postgresql.TIMESTAMP(), autoincrement=False, nullable=False))
op.drop_column('tracks', 'updated_at')
op.drop_column('tracks', 'license')
op.drop_column('tracks', 'iswc')
op.drop_column('tracks', 'isrc')
op.drop_column('tracks', 'description')
op.drop_column('tracks', 'created_at')
op.add_column('saves', sa.Column('timestamp', postgresql.TIMESTAMP(), autoincrement=False, nullable=False))
op.drop_column('saves', 'created_at')
op.add_column('reposts', sa.Column('timestamp', postgresql.TIMESTAMP(), autoincrement=False, nullable=False))
op.drop_column('reposts', 'created_at')
op.add_column('playlists', sa.Column('timestamp', postgresql.TIMESTAMP(), autoincrement=False, nullable=False))
op.drop_column('playlists', 'updated_at')
op.drop_column('playlists', 'upc')
op.drop_column('playlists', 'created_at')
op.add_column('follows', sa.Column('timestamp', postgresql.TIMESTAMP(), autoincrement=False, nullable=False))
op.drop_column('follows', 'created_at')
op.drop_column("users", "updated_at")
op.drop_column("users", "created_at")
op.add_column(
"tracks",
sa.Column(
"timestamp", postgresql.TIMESTAMP(), autoincrement=False, nullable=False
),
)
op.drop_column("tracks", "updated_at")
op.drop_column("tracks", "license")
op.drop_column("tracks", "iswc")
op.drop_column("tracks", "isrc")
op.drop_column("tracks", "description")
op.drop_column("tracks", "created_at")
op.add_column(
"saves",
sa.Column(
"timestamp", postgresql.TIMESTAMP(), autoincrement=False, nullable=False
),
)
op.drop_column("saves", "created_at")
op.add_column(
"reposts",
sa.Column(
"timestamp", postgresql.TIMESTAMP(), autoincrement=False, nullable=False
),
)
op.drop_column("reposts", "created_at")
op.add_column(
"playlists",
sa.Column(
"timestamp", postgresql.TIMESTAMP(), autoincrement=False, nullable=False
),
)
op.drop_column("playlists", "updated_at")
op.drop_column("playlists", "upc")
op.drop_column("playlists", "created_at")
op.add_column(
"follows",
sa.Column(
"timestamp", postgresql.TIMESTAMP(), autoincrement=False, nullable=False
),
)
op.drop_column("follows", "created_at")
# ### end Alembic commands ###

0 comments on commit cefbc03

Please sign in to comment.