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

feat: File management for fetch-binary and fetch-science functions #17

Open
wants to merge 104 commits into
base: main
Choose a base branch
from

Conversation

mfacchinelli
Copy link
Collaborator

@mfacchinelli mfacchinelli commented Aug 9, 2024

Adds OutputManager class to manage output of files to requested output folder and (optionally) database. Currently only supported for fetch-science and fetch-binary methods.

Plenty of unit tests for new classes. See new coverage report in GitHub Actions.

…oid issue with `version=latest` argument"

This reverts commit bddeea8.
…oid issue with `version=latest` argument"

This reverts commit bddeea8.
commit ee06eb9
Author: Michele Facchinelli <[email protected]>
Date:   Fri Aug 16 09:53:09 2024 +0000

    fix: add packages permission

commit d0bac86
Author: Michele Facchinelli <[email protected]>
Date:   Fri Aug 16 09:47:17 2024 +0000

    fix: add checks permissions

commit 80b3b92
Author: Michele Facchinelli <[email protected]>
Date:   Fri Aug 16 09:44:44 2024 +0000

    fix: permissions for CI actions
@mfacchinelli
Copy link
Collaborator Author

@alastairtree, updated to version 0.9.0 of imap-data-access and tests successfully pass!

Copy link
Collaborator

@alastairtree alastairtree left a comment

Choose a reason for hiding this comment

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

Looks great, thank you and sorry it took me ages. A couple of minor things but nothing major so merge when you are happy.

.github/workflows/ci.yml Outdated Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved

def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column("files", sa.Column("version", sa.Integer(), nullable=False))
Copy link
Collaborator

Choose a reason for hiding this comment

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

This upgrade will probably fail if the database contains any existing rows because you cannot add a non-nullable column without a default value to an existing row. Fine for this since we do not care about the data but just flagging this will need us to drop and recreate the data when we deploy this. A good practise is to always provide a default value when adding columns to existing tables, or to add as nullable, populate the data and then update it and make it non nullable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That makes sense. I did not consider that!

Is this any better?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

(sorry - will push changes soon!)

docker = "^7.1.0"
testcontainers = "^4.7.2"
wiremock = {git = "https://github.com/ImperialCollegeLondon/python-wiremock.git", rev = "fix-test-containers-on-windows"}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I just chased on the wiremock Slack to try and get this PR bugfix we need merged but no luck so far.

@@ -40,3 +68,61 @@ def insert_files(self, files: list[File]):
raise e
finally:
session.close()


class DatabaseOutputManager(IOutputManager):
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't really like the name "output manager" because i can't really tell what it is but not sure if there is anything better. Basically just talking to myself here.

tests/test_database.py Show resolved Hide resolved
tests/test_database.py Outdated Show resolved Hide resolved
tests/test_fetchBinary.py Show resolved Hide resolved
tests/test_fetchScience.py Outdated Show resolved Hide resolved
tests/test_outputManager.py Outdated Show resolved Hide resolved
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.

3 participants