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

Refactor isatab loader #555

Merged
merged 8 commits into from
Apr 12, 2024
Merged

Refactor isatab loader #555

merged 8 commits into from
Apr 12, 2024

Conversation

terazus
Copy link
Collaborator

@terazus terazus commented Mar 19, 2024

@ptth222 first pass at the refactoring

@coveralls
Copy link

coveralls commented Mar 19, 2024

Coverage Status

coverage: 81.281% (+0.07%) from 81.212%
when pulling e3c1912 on DomRefactorTabLoader
into d7aa027 on issue-511.

@ptth222
Copy link

ptth222 commented Mar 20, 2024

So you are basically just turning most of the code that's there into classes?

I figured out what I was talking about in the meeting when I said that there were different loaders.

  1. In convert/isatab2json.py if you use the old parser it uses the parser in io/isatab_parser.py.
  2. In convert/isatab2json.py if you use the new parser it uses isatab.load(), but in isatab/validate/core.py it uses load_investigation(). Both of these end up using read_investigation_file() from isatab/load/read.py though. Validation works with the df_dicts version while the converter uses the object version that load() creates. I got confused because all the nesting functions say "load" or "read" so it seemed like they were independent.

@terazus
Copy link
Collaborator Author

terazus commented Mar 20, 2024

So you are basically just turning most of the code that's there into classes?

Yes. I really dislike these nested functions and these huges block of codes. I've split the logic in dedicated methods and typed variables to 1. respect separation of concerns 2. make it easier to identify what is going on in code blocks.

I figured out what I was talking about in the meeting when I said that there were different loaders.
In convert/isatab2json.py if you use the old parser it uses the parser in io/isatab_parser.py.

You are right. The class here https://github.com/ISA-tools/isa-api/blob/master/isatools/convert/isatab2json.py#L65 should be deprecated. I will discuss with @proccaserra to see what we should do here. How about raising a DeprecationWarning ?

In convert/isatab2json.py if you use the new parser it uses isatab.load(), but in isatab/validate/core.py it uses load_investigation(). Both of these end up using read_investigation_file() from isatab/load/read.py though. Validation works with the df_dicts version while the converter uses the object version that load() creates. I got confused because all the nesting functions say "load" or "read" so it seemed like they were independent.

I agree that the naming is questionable. However the way it works make sense: the object creation through the load() function may 1. Crash or 2. Not build properly but be silent about it. This is why the validation is at the dataframe level.

@ptth222
Copy link

ptth222 commented Mar 20, 2024

You are right. The class here https://github.com/ISA-tools/isa-api/blob/master/isatools/convert/isatab2json.py#L65 should be deprecated. I will discuss with @proccaserra to see what we should do here. How about raising a DeprecationWarning ?

That class is still being used by the function above it. I assumed it was essentially left in to be compatible with older versions. Having the new version as a parameter may be enough of an indication. A deprecation warning would make it more explicit though. Might also consider changing the "use_new_parser" default to True or change it to "use_old_parser", so that the default is not using deprecated things.

I agree that the naming is questionable. However the way it works make sense: the object creation through the load() function may 1. Crash or 2. Not build properly but be silent about it. This is why the validation is at the dataframe level.

I wasn't trying to suggest any of this needed changing. I was just explaining what was brought up and why I got confused. I think the way things are is appropriate. Maybe a name change or adding to the function documentation could make things clearer, but it's not completely necessary

@terazus terazus marked this pull request as ready for review April 2, 2024 14:51
@terazus terazus requested a review from proccaserra April 2, 2024 14:51
@proccaserra proccaserra merged commit abcb82c into issue-511 Apr 12, 2024
10 checks passed
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.

4 participants