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

Use as a Python library #5

Merged
merged 3 commits into from
Oct 31, 2024
Merged

Use as a Python library #5

merged 3 commits into from
Oct 31, 2024

Conversation

SandyRogers
Copy link
Member

@SandyRogers SandyRogers commented Oct 30, 2024

This PR:

  • refactors the code a bit so that steps 1-3 can be done from a Python script, i.e. use assembly_uploader as a Python library
  • adds a test suite for the python library usage
  • tweaks the assembly study title/abstract generation (just formatting issues)
  • clarifies a few other points in the README

In short it makes this possible:

from assembly_uploader.study_xmls import StudyXMLGenerator, METAGENOME
from assembly_uploader.submit_study import submit_study
from assembly_uploader.assembly_manifest import AssemblyManifestGenerator

StudyXMLGenerator(
    study="SRP272267",
    center_name="EMG",
    library=METAGENOME,
    tpa=True,
    output_dir=Path("my-study"),
).write()

new_study_accession = submit_study("SRP272267", is_test=True, directory=Path("my-study"))

AssemblyManifestGenerator(
    study="SRP272267",
    assembly_study=new_study_accession,
    assemblies_csv=Path("/path/to/my/assemblies.csv"),
    output_dir=Path("my-study"),
).write()

@SandyRogers SandyRogers changed the base branch from main to dev October 30, 2024 08:54
@SandyRogers SandyRogers requested review from mberacochea and Vkale1 and removed request for mberacochea October 30, 2024 08:57
Copy link
Collaborator

@Vkale1 Vkale1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much ⭐

self.center = center_name
self.hold_date = hold_date

assert library in [METAGENOME, METATRANSCRIPTOME]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it okay to assert in a non test script?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good q – sort of. I think it makes sense here because: in CLI mode, the user input of library is already validated because I added choices= to the argparse. (Generally you should not use assertions to check user input, because assertion checks can be disabled at runtime by running python in "optimise" mode.) So here the assertion can only fail through programming error – where assertions are useful to sanity check things that should always be true. Would be slightly better if the "library user" input was validated differently (e.g. a Pydantic type or explicit check) but in my opinion this kind of check is okay for that, and the stacktrace for this failing should be self explanatory.



def test_submit_study(study_submission_xml_dir, monkeypatch):
ena_dropbopx = responses.add(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'dropbox'? and below

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thkna yuo!

@SandyRogers SandyRogers merged commit 76e8a0f into dev Oct 31, 2024
5 checks passed
@SandyRogers SandyRogers deleted the feature/use-as-lib branch October 31, 2024 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants