Skip to content

Commit

Permalink
Refactoring and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikWin committed Jan 25, 2025
1 parent 38f1aef commit d851156
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 110 deletions.
174 changes: 86 additions & 88 deletions vidformer-igni/src/frame_block.rs → vidformer-igni/src/feb.rs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion vidformer-igni/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use rand::Rng;
use sqlx::postgres::PgPoolOptions;
use tabled::{Table, Tabled};

mod frame_block;
mod feb;
mod ops;
mod schema;
mod segment;
Expand Down
8 changes: 2 additions & 6 deletions vidformer-igni/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,11 +491,7 @@ async fn igni_http_req_api(
.get("Authorization")
.and_then(|header| header.to_str().ok())
.and_then(|header| {
if header.starts_with("Bearer ") {
Some(header[7..].to_string())
} else {
None
}
header.strip_prefix("Bearer ")
});

let api_key = match api_key {
Expand All @@ -510,7 +506,7 @@ async fn igni_http_req_api(
};

let user: Option<schema::UserRow> = sqlx::query_as("SELECT * FROM \"user\" WHERE api_key = $1")
.bind(&api_key)
.bind(api_key)
.fetch_optional(&global.pool)
.await?;

Expand Down
8 changes: 4 additions & 4 deletions vidformer-igni/src/server/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ pub(crate) async fn search_source(
"Error reading request body",
)))?);
}
Ok(req) => match serde_json::from_slice(&req.to_bytes().to_vec()) {
Ok(req) => match serde_json::from_slice(&req.to_bytes()) {
Err(err) => {
error!("Error parsing request body");
return Ok(hyper::Response::builder()
Expand Down Expand Up @@ -758,7 +758,7 @@ pub(crate) async fn push_part_block(
}
};

let frame_block: crate::frame_block::FrameBlock =
let frame_block: crate::feb::FrameBlock =
match serde_json::from_slice(&body_uncompresed) {
Err(err) => {
return Ok(hyper::Response::builder()
Expand Down Expand Up @@ -815,7 +815,7 @@ async fn push_frame_req(
)))?);
}

let pos = req.0 as i32;
let pos = req.0;
let n_frames = req.2.len();

// Check if we're pushing too many framesreq
Expand All @@ -837,7 +837,7 @@ async fn push_frame_req(

insert_pos.push(pos + frame_idx as i32);
if let Some(expr) = frame {
let mut feb = crate::frame_block::FrameBlock::new();
let mut feb = crate::feb::FrameBlock::new();
feb.insert_frame(expr).map_err(|err| {
IgniError::General(format!("Error inserting value to FEB: {:?}", err))
})?;
Expand Down
2 changes: 1 addition & 1 deletion vidformer-igni/src/server/vod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ pub(crate) async fn get_segment(
for (_, frame) in rows {
let frame_reader = std::io::Cursor::new(frame);
let frame_uncompressed = zstd::stream::decode_all(frame_reader).unwrap();
let feb: crate::frame_block::FrameBlock =
let feb: crate::feb::FrameBlock =
serde_json::from_slice(&frame_uncompressed).unwrap();
let mut f_collection = feb.frames().map_err(|err| {
IgniError::General(format!("Error decoding frame block: {:?}", err))
Expand Down
12 changes: 2 additions & 10 deletions vidformer-py/vidformer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1330,15 +1330,9 @@ def _json_arg(arg, skip_data_anot=False):
class Filter:
"""A video filter."""

def __init__(self, name: str, tl_func=None, **kwargs):
def __init__(self, name: str, **kwargs):
self._name = name

# tl_func is the top level func, which is the true implementation, not just a pretty name
if tl_func is None:
self._func = name
else:
self._func = tl_func

# filter infra args, not invocation args
for k, v in kwargs.items():
if type(v) is not str:
Expand Down Expand Up @@ -1416,9 +1410,7 @@ def into_filter(self):
target=_run_udf_host, args=(self, self._socket_path)
)
self._p.start()
return Filter(
name=self._name, tl_func="IPC", socket=self._socket_path, func=self._name
)
return Filter(name=self._name, socket=self._socket_path, func=self._name)

def _handle_connection(self, connection):
try:
Expand Down

0 comments on commit d851156

Please sign in to comment.