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

Fix display issues #22

Merged
merged 4 commits into from
Jun 4, 2024
Merged
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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,9 @@ When running, it will default to using a SQLite3 database located in the root of
## Using the library

The `sample_registry` library can be installed and run anywhere by following the instructions in Development (you don't need to do the `create_test_db` and running the site (bottom two commands)). To connect it to a Postgres backend, you'll need to also set the environment variables `DB_HOST`, `DB_USER`, `DB_NAME`, and `DB_PSWD`.

## Manually build Docker image

If you want to iterate over a feature you can only test on the K8s deployment, you can manually build the Docker image instead of relying on the release workflow. Use `docker build -t ctbushman/sample_registry:latest -f Dockerfile .` to build the image and then `docker push ctbushman/sample_registry:latest` to push it to DockerHub. You can then trigger the K8s deployment to grab the new image.

N.B. You might want to use a different tag than `latest` if you're testing something volatile so that if someone else is trying to use the image as you're developing, they won't pull your wonky changes.
12 changes: 12 additions & 0 deletions app/sample_registry/src/sample_registry/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ def unregister_samples(argv=None, session: Session = None, out=sys.stdout):
samples_removed = registry.remove_samples(args.run_accession)
out.write("Removed {0} samples: {1}".format(len(samples_removed), samples_removed))

session.commit()


def register_samples():
return register_sample_annotations(None, True)
Expand Down Expand Up @@ -78,6 +80,8 @@ def register_sample_annotations(
registry.register_samples(args.run_accession, sample_table)
registry.register_annotations(args.run_accession, sample_table)

session.commit()


def parse_tsv_ncol(f, ncol: int) -> Generator[tuple[str], None, None]:
assert ncol > 0
Expand Down Expand Up @@ -107,6 +111,8 @@ def register_sample_types(argv=None, session: Session = None):
registry.remove_standard_sample_types()
registry.register_standard_sample_types(sample_types)

session.commit()


def register_host_species(argv=None, session: Session = None):
p = argparse.ArgumentParser(
Expand All @@ -120,6 +126,8 @@ def register_host_species(argv=None, session: Session = None):
registry.remove_standard_host_species()
registry.register_standard_host_species(host_species)

session.commit()


def register_illumina_file(argv=None, session: Session = None, out=sys.stdout):
p = argparse.ArgumentParser(
Expand All @@ -136,6 +144,8 @@ def register_illumina_file(argv=None, session: Session = None, out=sys.stdout):
)
out.write("Registered run {0} in the database\n".format(acc))

session.commit()


def register_run(argv=None, session: Session = None, out=sys.stdout):
p = argparse.ArgumentParser(description="Add a new run to the registry")
Expand All @@ -156,3 +166,5 @@ def register_run(argv=None, session: Session = None, out=sys.stdout):
args.date, args.type, "Nextera XT", args.lane, args.file, args.comment
)
out.write("Registered run %s in the database\n" % acc)

session.commit()
18 changes: 2 additions & 16 deletions app/sample_registry/src/sample_registry/registrar.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def register_run(
data_uri: str,
comment: str,
) -> int:
run_acc = self.session.scalar(
return self.session.scalar(
insert(Run)
.returning(Run.run_accession)
.values(
Expand All @@ -58,9 +58,6 @@ def register_run(
)
)

self.session.commit()
return run_acc

def register_samples(
self, run_accession: int, sample_table: SampleTable
) -> list[int]:
Expand All @@ -79,7 +76,7 @@ def register_samples(
).first():
raise ValueError("Samples already registered for run %s" % run_accession)

sample_accs = self.session.scalars(
return self.session.scalars(
insert(Sample)
.returning(Sample.sample_accession)
.values(
Expand All @@ -94,9 +91,6 @@ def register_samples(
)
)

self.session.commit()
return sample_accs

def remove_samples(self, run_accession: int) -> list[int]:
samples = self.session.scalars(
select(Sample.sample_accession).where(Sample.run_accession == run_accession)
Expand All @@ -108,7 +102,6 @@ def remove_samples(self, run_accession: int) -> list[int]:
delete(Sample).where(Sample.run_accession == run_accession)
)

self.session.commit()
return samples

def register_annotations(self, run_accession: int, sample_table: SampleTable):
Expand Down Expand Up @@ -152,7 +145,6 @@ def register_annotations(self, run_accession: int, sample_table: SampleTable):
)
)

self.session.commit()
return annotation_keys

def _get_sample_accessions(
Expand Down Expand Up @@ -182,7 +174,6 @@ def _get_sample_accessions(

def remove_standard_sample_types(self):
self.session.execute(delete(StandardSampleType))
self.session.commit()

def register_standard_sample_types(self, sample_types: list[tuple[str, str, bool]]):
self.session.execute(
Expand All @@ -198,11 +189,8 @@ def register_standard_sample_types(self, sample_types: list[tuple[str, str, bool
)
)

self.session.commit()

def remove_standard_host_species(self):
self.session.execute(delete(StandardHostSpecies))
self.session.commit()

def register_standard_host_species(
self, host_species
Expand All @@ -219,5 +207,3 @@ def register_standard_host_species(
]
)
)

self.session.commit()
Loading