Skip to content

Commit

Permalink
add ruff formatting and minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
guzmanlopez committed Nov 5, 2024
1 parent fb7a2aa commit d59ad6c
Show file tree
Hide file tree
Showing 28 changed files with 337 additions and 255 deletions.
4 changes: 3 additions & 1 deletion gps_fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ def gps_fetch(cpool: SimpleConnectionPool, thalos_dir: Path):
new_file: Path = dt_index[new_dt.astimezone(UTC)]
with new_file.open() as data:
line = data.readline()
m = re.match(r"([+-]?(\d+(\.\d*)?|\.\d+)).*,.*?([+-]?(\d+(\.\d*)?|\.\d+))", line)
m = re.match(
r"([+-]?(\d+(\.\d*)?|\.\d+)).*,.*?([+-]?(\d+(\.\d*)?|\.\d+))", line
)
if m:
lat = m[1]
lon = m[4]
Expand Down
5 changes: 2 additions & 3 deletions migrations/versions/04eaff9bcc55_.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
"""first
Revision ID: 04eaff9bcc55
Revises:
Revises:
Create Date: 2023-04-10 12:56:26.377798
"""


# revision identifiers, used by Alembic.
revision = '04eaff9bcc55'
revision = "04eaff9bcc55"
down_revision = None
branch_labels = None
depends_on = None
Expand Down
20 changes: 10 additions & 10 deletions migrations/versions/17911f3ffb3b_new_vector_rows_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
Create Date: 2023-06-02 14:22:38.910122
"""

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = '17911f3ffb3b'
down_revision = 'f835aa8c569a'
revision = "17911f3ffb3b"
down_revision = "f835aa8c569a"
branch_labels = None
depends_on = None

Expand All @@ -23,16 +24,15 @@ def upgrade() -> None:
found_id = row[0]

if found_id is None:
op.get_bind().execute('insert into vectors (name, configblob) values (\'InternetVector\', \'{"target_ips":["8.8.8.8","1.1.1.1","208.67.222.222","9.9.9.9"],"run_traceroute":false}\');')


op.get_bind().execute(
'insert into vectors (name, configblob) values (\'InternetVector\', \'{"target_ips":["8.8.8.8","1.1.1.1","208.67.222.222","9.9.9.9"],"run_traceroute":false}\');'
)


def downgrade() -> None:
op.get_bind().execute(
"delete from tests where vector_id = (select id from vectors where name = 'InternetVector');"
)

op.get_bind().execute("delete from tests where vector_id = (select id from vectors where name = 'InternetVector');")

t = sa.table('vectors')
t = sa.table("vectors")
op.get_bind().execute("delete from vectors where name = 'InternetVector';")


9 changes: 5 additions & 4 deletions migrations/versions/47ff3fca73a4_vector_schedulestring.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,24 @@
Create Date: 2023-06-06 13:07:09.704169
"""

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = '47ff3fca73a4'
down_revision = '5e4898954923'
revision = "47ff3fca73a4"
down_revision = "5e4898954923"
branch_labels = None
depends_on = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('vectors', sa.Column('schedule_string', sa.String(), nullable=True))
op.add_column("vectors", sa.Column("schedule_string", sa.String(), nullable=True))
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('vectors', 'schedule_string')
op.drop_column("vectors", "schedule_string")
# ### end Alembic commands ###
11 changes: 5 additions & 6 deletions migrations/versions/495235ece5f0_ondeckdata_unique.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
Create Date: 2023-10-10 15:43:07.752816
"""

from alembic import op

# revision identifiers, used by Alembic.
revision = '495235ece5f0'
down_revision = 'f48359cf7456'
revision = "495235ece5f0"
down_revision = "f48359cf7456"
branch_labels = None
depends_on = None


def upgrade() -> None:

op.execute("""
with duped as (
select distinct on (video_uri) video_uri, id
Expand All @@ -26,9 +26,8 @@ def upgrade() -> None:
where video_uri in (select video_uri from duped)
and id not in (select id from duped)
;""")
op.create_unique_constraint(None, 'ondeckdata', ['video_uri'])

op.create_unique_constraint(None, "ondeckdata", ["video_uri"])


def downgrade() -> None:
op.drop_constraint(None, 'ondeckdata', type_='unique')
op.drop_constraint(None, "ondeckdata", type_="unique")
24 changes: 13 additions & 11 deletions migrations/versions/58dd42108a22_new_vid_file_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,30 @@
Create Date: 2023-06-16 18:15:23.314916
"""

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = '58dd42108a22'
down_revision = 'f9dbf07180af'
revision = "58dd42108a22"
down_revision = "f9dbf07180af"
branch_labels = None
depends_on = None


def upgrade() -> None:
op.create_table('video_files',
sa.Column('original_path', sa.String(), nullable=False),
sa.Column('last_modified', sa.DateTime(timezone=True), nullable=False),
sa.Column('decrypted_path', sa.String(), nullable=True),
sa.Column('decrypted_datetime', sa.DateTime(timezone=True), nullable=True),
sa.Column('stdout', sa.String(), nullable=True),
sa.Column('stderr', sa.String(), nullable=True),
sa.PrimaryKeyConstraint('original_path')
op.create_table(
"video_files",
sa.Column("original_path", sa.String(), nullable=False),
sa.Column("last_modified", sa.DateTime(timezone=True), nullable=False),
sa.Column("decrypted_path", sa.String(), nullable=True),
sa.Column("decrypted_datetime", sa.DateTime(timezone=True), nullable=True),
sa.Column("stdout", sa.String(), nullable=True),
sa.Column("stderr", sa.String(), nullable=True),
sa.PrimaryKeyConstraint("original_path"),
)
pass


def downgrade() -> None:
op.drop_table('video_files')
op.drop_table("video_files")
22 changes: 13 additions & 9 deletions migrations/versions/5e4898954923_ondeckdata_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,33 @@
Create Date: 2023-06-05 14:09:26.594081
"""

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = '5e4898954923'
down_revision = '17911f3ffb3b'
revision = "5e4898954923"
down_revision = "17911f3ffb3b"
branch_labels = None
depends_on = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('ondeckdata',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('video_uri', sa.String(), nullable=True),
sa.Column('cocoannotations_uri', sa.String(), nullable=True),
sa.Column('datetime', sa.DateTime(), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=True),
sa.PrimaryKeyConstraint('id')
op.create_table(
"ondeckdata",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("video_uri", sa.String(), nullable=True),
sa.Column("cocoannotations_uri", sa.String(), nullable=True),
sa.Column(
"datetime", sa.DateTime(), server_default=sa.text("CURRENT_TIMESTAMP"), nullable=True
),
sa.PrimaryKeyConstraint("id"),
)
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('ondeckdata')
op.drop_table("ondeckdata")
# ### end Alembic commands ###
65 changes: 40 additions & 25 deletions migrations/versions/5fdb864a1bbb_refactor_aifish.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,58 @@
Create Date: 2023-12-12 12:43:34.309532
"""

import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = '5fdb864a1bbb'
down_revision = 'e718ddd7c0bd'
revision = "5fdb864a1bbb"
down_revision = "e718ddd7c0bd"
branch_labels = None
depends_on = None


def upgrade() -> None:

op.create_table('aifishdata',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('video_uri', sa.String(), nullable=True),
sa.Column('processing_uri', sa.String(), nullable=True),
sa.Column('output_uri', sa.String(), nullable=True),
sa.Column('datetime', sa.DateTime(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=True),
sa.Column('count', sa.Integer(), nullable=True),
sa.Column('runtimems', sa.REAL(), nullable=True),
sa.Column('detection_confidence', sa.REAL(), nullable=True),
sa.Column('status', sa.String(), nullable=True),
sa.ForeignKeyConstraint(['video_uri'], ['video_files.decrypted_path'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('video_uri')
op.create_table(
"aifishdata",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("video_uri", sa.String(), nullable=True),
sa.Column("processing_uri", sa.String(), nullable=True),
sa.Column("output_uri", sa.String(), nullable=True),
sa.Column(
"datetime",
sa.DateTime(timezone=True),
server_default=sa.text("CURRENT_TIMESTAMP"),
nullable=True,
),
sa.Column("count", sa.Integer(), nullable=True),
sa.Column("runtimems", sa.REAL(), nullable=True),
sa.Column("detection_confidence", sa.REAL(), nullable=True),
sa.Column("status", sa.String(), nullable=True),
sa.ForeignKeyConstraint(
["video_uri"],
["video_files.decrypted_path"],
),
sa.PrimaryKeyConstraint("id"),
sa.UniqueConstraint("video_uri"),
)
op.drop_table('fishaidata')

op.drop_table("fishaidata")


def downgrade() -> None:
op.create_table('fishaidata',
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
sa.Column('video_uri', sa.VARCHAR(), autoincrement=False, nullable=True),
sa.Column('cocoannotations_uri', sa.VARCHAR(), autoincrement=False, nullable=True),
sa.Column('datetime', postgresql.TIMESTAMP(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), autoincrement=False, nullable=True),
sa.PrimaryKeyConstraint('id', name='fishaidata_pkey')
op.create_table(
"fishaidata",
sa.Column("id", sa.INTEGER(), autoincrement=True, nullable=False),
sa.Column("video_uri", sa.VARCHAR(), autoincrement=False, nullable=True),
sa.Column("cocoannotations_uri", sa.VARCHAR(), autoincrement=False, nullable=True),
sa.Column(
"datetime",
postgresql.TIMESTAMP(timezone=True),
server_default=sa.text("CURRENT_TIMESTAMP"),
autoincrement=False,
nullable=True,
),
sa.PrimaryKeyConstraint("id", name="fishaidata_pkey"),
)
op.drop_table('aifishdata')
op.drop_table("aifishdata")
10 changes: 5 additions & 5 deletions migrations/versions/643148911953_deckhand_json_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
Create Date: 2023-08-16 11:38:18.120705
"""

from alembic import op

# revision identifiers, used by Alembic.
revision = '643148911953'
down_revision = '677a2f2884e1'
revision = "643148911953"
down_revision = "677a2f2884e1"
branch_labels = None
depends_on = None

Expand Down Expand Up @@ -50,8 +51,7 @@ def upgrade() -> None:
""")



def downgrade() -> None:
op.get_bind().execute('DROP VIEW deckhandevents_mostrecentlonglineevent_jsonextracted;')
op.get_bind().execute('DROP VIEW deckhandevents_mostrecenteventid_nophoto;')
op.get_bind().execute("DROP VIEW deckhandevents_mostrecentlonglineevent_jsonextracted;")
op.get_bind().execute("DROP VIEW deckhandevents_mostrecenteventid_nophoto;")
pass
14 changes: 8 additions & 6 deletions migrations/versions/677a2f2884e1_s3uploadstable.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,29 @@
Create Date: 2023-08-02 17:08:34.590190
"""

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = '677a2f2884e1'
down_revision = '97b633de0899'
revision = "677a2f2884e1"
down_revision = "97b633de0899"
branch_labels = None
depends_on = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###

op.create_table('s3uploads',
sa.Column('datetime', sa.DateTime(timezone=True), nullable=False),
sa.Column('tablename', sa.String(), nullable=False),
op.create_table(
"s3uploads",
sa.Column("datetime", sa.DateTime(timezone=True), nullable=False),
sa.Column("tablename", sa.String(), nullable=False),
)
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('s3uploads')
op.drop_table("s3uploads")
# ### end Alembic commands ###
Loading

0 comments on commit d59ad6c

Please sign in to comment.