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 attempt to download non-existing tables #812

Merged
merged 5 commits into from
Apr 26, 2022
Merged

Conversation

gonzaponte
Copy link
Collaborator

Due to the mutability of lists, this code was modifying all the elements of the dictionary. This resulted in an attempt to download tables that don't exist in the database.

Due to the mutability of lists, this code was modifying all the elements of the dictionary. This resulted in an attempt to download tables that don't exist in the database.
@gonzaponte gonzaponte requested a review from gondiaz March 9, 2022 17:50
Copy link
Collaborator

@jacg jacg left a comment

Choose a reason for hiding this comment

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

I believe that this does what it says on the tin. How difficult would it be to add a test?

If tables were a tuple, instead of a list, the original version would have worked as intended: lhs += rhs mutates lhs for mutable types (e.g. list) but rebinds it to a new object (lhs + rhs) for immutable types (e.g. tuple).

Copy link
Collaborator

@gondiaz gondiaz left a comment

Choose a reason for hiding this comment

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

Good catch, this PR does what it claims. To me is ok if you add a test, but I think changing the lists to tuples would be good enough.

Also, even though the test in download_test.py is skipped due to random misconnections, the dbname and table are fixed inside the function, which is parametrized. Could you fix this either removing the parametrization or the harcoded dbname? We may decide to activate the test in the future.

@gonzaponte
Copy link
Collaborator Author

How difficult would it be to add a test?

I'm thinking of a test that checks for the existence of the corresponding tables for each database. It's not perfect, as @gondiaz mentioned we have issues with the connection to the server. I can think of another test, but it's a bit trivial, I will push it and you can comment on that.

Could you fix this either removing the parametrization or the harcoded dbname?

I will take a look into that, maybe it's the same as mentioned above.

Copy link
Collaborator

@jacg jacg left a comment

Choose a reason for hiding this comment

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

Any reason why the original tables (lines 77-79) can't be a tuple?

@gonzaponte
Copy link
Collaborator Author

No, I had just switching to that (not commited yet).



@mark.parametrize('dbname', db.dbnames)
def test_existing_tables(dbname):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe test_tables_exist is a more descriptive name?

Comment on lines 44 to 45
connMySql = pymysql.connect(host="neutrinos1.ific.uv.es",
user='nextreader',passwd='readonly', db=dbname)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Cosmetics

Suggested change
connMySql = pymysql.connect(host="neutrinos1.ific.uv.es",
user='nextreader',passwd='readonly', db=dbname)
connMySql = pymysql.connect(host="neutrinos1.ific.uv.es",
user='nextreader', passwd='readonly', db=dbname)

Copy link
Collaborator

@gondiaz gondiaz left a comment

Choose a reason for hiding this comment

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

This PR fixes a bug in downloading database tables, good work, aproved!

@halmamol halmamol merged commit 8e041ad into master Apr 26, 2022
@gonzaponte gonzaponte deleted the gonzaponte-patch-1 branch April 29, 2022 07:56
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