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

Feature/tools 10 process imported #382

Draft
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

Luisella21
Copy link
Contributor

Implement the logic used when importing a new set of data for IRAP tools.
It assumes that the new data has already been validated, and it exists in an intermediate table.

@Luisella21 Luisella21 requested a review from marcelkornblum July 5, 2023 08:31
@marcelkornblum marcelkornblum requested a review from CamLamb July 5, 2023 09:33
Copy link
Contributor

@marcelkornblum marcelkornblum left a comment

Choose a reason for hiding this comment

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

Looking good! I didn't review the tests though - do you need me to?

successfully from Data Workspace.
There is no validation on the new records, as any validation will
happen when the data is imported from DW
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm left confused by this docstring I'm afraid. Has the data already been validated at this point or is it still to be validated? "DW" is also confusing in this context :)

@@ -0,0 +1,113 @@
from tools.models import IrapToolData, IrapToolDataImport, Tool
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought the plan was to build this in a way that would easily extensible if/when we want to import from other sources in the future...

Should we be calling this module import.py and making all the methods a bit less specific to IRAP, unless they are specifically and only for IRAP data?

previous_values = {}
for field in new_fields:
new_value = getattr(new, field.name)
old_value = getattr(old, field.name)
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need to catch times when the field list and/or names might have changed? i.e. old might not have a field that exists on new, or the other way around.

return changed, previous_values


def are_field_identical(import_obj: IrapToolDataImport, old_values: dict) -> bool:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
def are_field_identical(import_obj: IrapToolDataImport, old_values: dict) -> bool:
def are_fields_identical(import_obj: IrapToolDataImport, old_values: dict) -> bool:

IrapToolData.objects.update(imported=False)

imported_iraps = IrapToolDataImport.objects.all()
for imported_irap in imported_iraps:
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be great IMO to have all the field names in a configurable mapping object, so that it's easy to update which fields go to which if the column names in the data source change from time to time

@CamLamb
Copy link
Contributor

CamLamb commented Oct 9, 2023

Marking this as a draft as the work hasn't been actively worked on in a while

@CamLamb CamLamb marked this pull request as draft October 9, 2023 16:21
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