Skip to content

Issue 835 #845

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

Merged
merged 12 commits into from
Feb 13, 2015
Merged

Issue 835 #845

merged 12 commits into from
Feb 13, 2015

Conversation

squirrelo
Copy link
Contributor

This fixes the analysis filepath issues and adds a test to make sure it doesn't happen again.

@ElDeveloper
Copy link
Contributor

@squirrelo, there are legitimate flake8 errors in this build.

@squirrelo
Copy link
Contributor Author

Not any more.

@ElDeveloper
Copy link
Contributor

💥 💥

@coveralls
Copy link

Coverage Status

Coverage increased (+0.0%) to 78.61% when pulling ab3ac5c on squirrelo:issue-835 into 32d6d8e on biocore:master.

@@ -427,6 +428,26 @@ def test_build_files_raises_value_error(self):
with self.assertRaises(ValueError):
self.analysis.build_files(-10)

def test_add_file(self):
fp = join(get_mountpoint('analysis')[0][1], 'testfile.txt')
try:
Copy link
Contributor

Choose a reason for hiding this comment

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

If I understand correctly: if you can write to the file path you add it to the analysis and regardless of the result of these two lines you check if it exists and if it exists you remove it? Should that fp be removed in the teardown method of the test class? So we can guarantee that it is removed, the finally block here is kinda confusing.

@ElDeveloper
Copy link
Contributor

This PR looks ok but I'm not super familiar with this codebase so it would be nice if someone else could review it in depth.

@squirrelo
Copy link
Contributor Author

Yes, the finally makes it so the test always removes the file created
regardless of if the test errors or not. I can move it to teardown I guess,
I just hate having test specific things in teardown instead of in the test.

On Tue, Feb 10, 2015 at 4:14 PM, Yoshiki Vázquez Baeza <
notifications@github.com> wrote:

This PR looks ok but I'm not super familiar with this codebase so it would
be nice if someone else could review it in depth.


Reply to this email directly or view it on GitHub
#845 (comment).

@ElDeveloper
Copy link
Contributor

Ah got it. IMHO it's clearer if it's part of the teardown method (maybe
because that's what I'm used to see) than as an inline try/except block.
teardown methods are supposed to be dealing with these kind of things so
it's really up to you.

On (Feb-10-15|20:38), Joshua Shorenstein wrote:

Yes, the finally makes it so the test always removes the file created
regardless of if the test errors or not. I can move it to teardown I guess,
I just hate having test specific things in teardown instead of in the test.

On Tue, Feb 10, 2015 at 4:14 PM, Yoshiki Vázquez Baeza <
notifications@github.com> wrote:

This PR looks ok but I'm not super familiar with this codebase so it would
be nice if someone else could review it in depth.


Reply to this email directly or view it on GitHub
#845 (comment).


Reply to this email directly or view it on GitHub:
#845 (comment)

@coveralls
Copy link

Coverage Status

Coverage increased (+0.0%) to 78.61% when pulling 7e13efe on squirrelo:issue-835 into 32d6d8e on biocore:master.

@@ -608,8 +608,8 @@ def get_mountpoint(mount_type, conn_handler=None, retrieve_all=False):
"SELECT data_directory_id, mountpoint, subdirectory FROM "
"qiita.data_directory WHERE data_type='%s' and active=true"
% mount_type)]

return [(d, join(get_db_files_base_dir(), m, s)) for d, m, s in result]
basedir = get_db_files_base_dir()
Copy link
Member

Choose a reason for hiding this comment

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

I do not understand this change, is it required or is for clarity?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The function does an SQL select every time it's called, so this makes it happen 1 time instead of N times.

Copy link
Member

Choose a reason for hiding this comment

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

Excellent point! Thanks for catching that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Should this use get_db_files_base_dir or should we move to the get_mountpoint function that @antgonza added a while ago?

Copy link
Member

Choose a reason for hiding this comment

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

This line is within the get_mountpoint function ....

Copy link
Contributor

Choose a reason for hiding this comment

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

Ooops, I just saw that this is actually the get_mountpoint function... 😅😇

@josenavas
Copy link
Contributor

Few comments @squirrelo

'SELECT f.* from qiita.filepath f JOIN qiita.analysis_filepath afp ON '
'f.filepath_id = afp.filepath_id')
for filepath in filepaths:
filename = basename(filepath['filepath'])
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to verify: these files are still relative to a unique directory associated with a study or a meta-analysis, correct?

@antgonza
Copy link
Member

Pull from upstream master.

@squirrelo
Copy link
Contributor Author

ready for review again.

@antgonza
Copy link
Member

The patch is not working in my machine because the mountpoint has an ending / and the file path doesn't

Traceback (most recent call last):
  File "qiita_db/support_files/patches/python_patches/14.py", line 23, in <module>
    mp_id = mountpoints[dirname(filepath['filepath'])]
KeyError: '/Users/antoniog/Desktop/CurrentWork/largeFiles/qiita/base_dir/analysis'

and I have these values in filepath, mountpoints

[308L, '/Users/antoniog/Desktop/CurrentWork/largeFiles/qiita/base_dir/analysis/1_analysis_mapping.txt', 9L, '833932644', 1L, 1L]
{'/Users/antoniog/Desktop/CurrentWork/largeFiles/qiita/base_dir/analysis/': 1L}

@wasade
Copy link
Contributor

wasade commented Feb 12, 2015

Should the mount points have a trailing '/'? That technically refers to the contents of the path, not that path

@antgonza
Copy link
Member

antgonza commented Feb 12, 2015 via email

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.02%) to 78.58% when pulling 77b311c on squirrelo:issue-835 into 1ca033a on biocore:master.

@antgonza
Copy link
Member

👍

@antgonza
Copy link
Member

@squirrelo conflicts, @ElDeveloper could you merge after conflicts are solved? Thanks.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.02%) to 78.48% when pulling 5a38e03 on squirrelo:issue-835 into 559556e on biocore:master.

ElDeveloper added a commit that referenced this pull request Feb 13, 2015
@ElDeveloper ElDeveloper merged commit 17da9c2 into qiita-spots:master Feb 13, 2015
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.

6 participants