Skip to content

Commit

Permalink
Clean up tables
Browse files Browse the repository at this point in the history
  • Loading branch information
anna-parker committed Jul 21, 2024
1 parent 66a7fbe commit 1b95382
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
1 change: 0 additions & 1 deletion ena-submission/flyway/sql/V1__Initial_Schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ CREATE TABLE project_table (
CREATE TABLE sample_table (
accession text not null,
version bigint not null,
organism text not null,
errors jsonb,
warnings jsonb,
status text not null,
Expand Down
5 changes: 3 additions & 2 deletions ena-submission/scripts/create_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def create_sample(log_level, config_file):
)
else:
# If not: create sample_entry, change status to SUBMITTING_SAMPLE
sample_table_entry = SampleTableEntry(**seq_key, center_name=row["center_name"])
sample_table_entry = SampleTableEntry(**seq_key)
add_to_sample_table(db_config, sample_table_entry)
update_values = {"status_all": StatusAll.SUBMITTING_SAMPLE.name}
number_rows_updated = update_db_where_conditions(
Expand Down Expand Up @@ -196,13 +196,14 @@ def create_sample(log_level, config_file):
f"Found {len(ready_to_submit_sample)} entries in sample_table in status READY"
)
for row in ready_to_submit_sample:
organism_metadata = config.organisms[row["organism"]]["ingest"]
seq_key = {"accession": row["accession"], "version": row["version"]}
sample_data_in_submission_table = find_conditions_in_db(
db_config, table_name="submission_table", conditions=seq_key
)
sample_metadata = sample_data_in_submission_table[0]["metadata"]
center_name = sample_data_in_submission_table[0]["center_name"]
organism = sample_data_in_submission_table[0]["organism"]
organism_metadata = config.organisms[organism]["ingest"]

sample_set = construct_sample_set_object(
config, organism_metadata, sample_metadata, center_name, row
Expand Down
4 changes: 1 addition & 3 deletions ena-submission/scripts/submission_db_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ class ProjectTableEntry:
class SampleTableEntry:
accession: str
version: int
organism: str
errors: str | None = None
warnings: str | None = None
status: Status = Status.READY
Expand Down Expand Up @@ -208,11 +207,10 @@ def add_to_sample_table(db_config: DBConfig, sample_table_entry: SampleTableEntr
sample_table_entry.started_at = datetime.now(tz=pytz.utc)

cur.execute(
"insert into sample_table values(%s,%s,%s,%s,%s,%s,%s,%s,%s)",
"insert into sample_table values(%s,%s,%s,%s,%s,%s,%s,%s)",
(
sample_table_entry.accession,
sample_table_entry.version,
sample_table_entry.organism,
sample_table_entry.errors,
sample_table_entry.warnings,
sample_table_entry.status.name,
Expand Down

0 comments on commit 1b95382

Please sign in to comment.