Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add array column in sqlalchemy plugin #2566

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Updated llm_finetuning template
- Add sql table length exceed limit and uuid truncation.
- Add ci workflow to test templates
- Add array column in sqlalchemy plugin

#### Bug Fixes

Expand Down
11 changes: 2 additions & 9 deletions plugins/sqlalchemy/superduper_sqlalchemy/db_helper.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import json
from typing import Tuple

from sqlalchemy import (
Boolean,
DateTime,
Integer,
String,
Text,
TypeDecorator,
)
from sqlalchemy import ARRAY, Boolean, DateTime, Integer, String, Text, TypeDecorator

DEFAULT_LENGTH = 255

Expand Down Expand Up @@ -59,7 +52,7 @@ class DefaultConfig:
"""Default configuration for database types # noqa."""

type_string = String(DEFAULT_LENGTH)
type_string_long = String(1000)
type_array = ARRAY(String)
type_json_as_string = JsonAsString
type_json_as_text = JsonAsText
type_integer = Integer
Expand Down
8 changes: 2 additions & 6 deletions plugins/sqlalchemy/superduper_sqlalchemy/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def _init_tables(self):
DBConfig = get_db_config(self.dialect)

type_string = DBConfig.type_string
type_string_long = DBConfig.type_string_long
type_array = DBConfig.type_array
type_json_as_string = DBConfig.type_json_as_string
type_json_as_text = DBConfig.type_json_as_text
type_integer = DBConfig.type_integer
Expand Down Expand Up @@ -99,7 +99,7 @@ def _init_tables(self):
Column('genus', type_string),
Column('queue', type_string),
Column('status', type_string),
Column('dependencies', type_string_long),
Column('dependencies', type_array),
*job_table_args,
)

Expand Down Expand Up @@ -573,10 +573,6 @@ def create_job(self, info: t.Dict):

:param info: The information used to create the job
"""
if 'dependencies' in info:
import json

info['dependencies'] = json.dumps(info['dependencies'])
with self.session_context() as session:
stmt = insert(self.job_table).values(**info)
session.execute(stmt)
Expand Down
Loading