Skip to content

Fix 1812 #2371

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
Oct 24, 2017
Merged

Fix 1812 #2371

merged 12 commits into from
Oct 24, 2017

Conversation

antgonza
Copy link
Member

No description provided.

@codecov-io
Copy link

codecov-io commented Oct 22, 2017

Codecov Report

Merging #2371 into dev will decrease coverage by 0.01%.
The diff coverage is 86.88%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev    #2371      +/-   ##
==========================================
- Coverage   93.78%   93.76%   -0.02%     
==========================================
  Files         163      163              
  Lines       18615    18643      +28     
==========================================
+ Hits        17458    17481      +23     
- Misses       1157     1162       +5
Impacted Files Coverage Δ
qiita_db/handlers/processing_job.py 96.92% <ø> (ø) ⬆️
qiita_db/analysis.py 95.96% <ø> (ø) ⬆️
...t/handlers/api_proxy/tests/test_sample_template.py 98.55% <ø> (ø) ⬆️
qiita_pet/handlers/study_handlers/ebi_handlers.py 62.5% <0%> (ø) ⬆️
qiita_pet/handlers/api_proxy/studies.py 86.66% <0%> (ø) ⬆️
...iita_pet/handlers/study_handlers/vamps_handlers.py 21.21% <0%> (ø) ⬆️
qiita_pet/handlers/api_proxy/sample_template.py 95.69% <100%> (ø) ⬆️
qiita_pet/handlers/api_proxy/prep_template.py 90.04% <100%> (ø) ⬆️
...ta_pet/handlers/artifact_handlers/base_handlers.py 93.33% <100%> (ø) ⬆️
qiita_db/processing_job.py 92.75% <100%> (+0.21%) ⬆️
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9fe81b0...aa27112. Read the comment docs.

@antgonza
Copy link
Member Author

This is ready for review: @josenavas, @ElDeveloper and @wasade. I think 2-3 reviews will be great. The main things to consider while reviewing:

  1. The ProcessingJob.create has a new parameter force to force creation, as in some cases is fine to force creation even with duplicated parameters.
  2. Be careful to check that it makes sense to use that flag in the tests, for example: must of our tests create duplicated jobs and @josenavas and I thought this was fine
  3. Sample/Prep/Analysis workflows can still create duplicated jobs, thus adding there.

Copy link
Contributor

@josenavas josenavas left a comment

Choose a reason for hiding this comment

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

Just one comment

existing_jobs = qdb.sql_connection.TRN.execute_fetchindex()
if existing_jobs and not force:
raise ValueError(
'Cannot create job because these jobs:\n%s' % '\n'.join(
Copy link
Contributor

Choose a reason for hiding this comment

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

"Cannot create job because it is a duplicate of these jobs"

Copy link
Contributor

Choose a reason for hiding this comment

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

👍 ... maybe worth including a bit more detail:

Cannot create job because the parameters are the same as jobs that are queued, running or already have succeeded: .....

Copy link
Contributor

@ElDeveloper ElDeveloper left a comment

Choose a reason for hiding this comment

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

Just one comment in the double list comprehension.

WHERE command_id = %s AND processing_job_status IN (
'success', 'waiting', 'running') """
params = " AND ".join(
["command_parameters->>'%s' = '%s'" % (k, v)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is one confusing double conditional list comprehension. for v in v?

Copy link
Contributor

Choose a reason for hiding this comment

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

agree

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, fixing. Note that this wasn't actually working correctly and I also added some explanation on the steps. Let's see what else this breaks.

existing_jobs = qdb.sql_connection.TRN.execute_fetchindex()
if existing_jobs and not force:
raise ValueError(
'Cannot create job because these jobs:\n%s' % '\n'.join(
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 ... maybe worth including a bit more detail:

Cannot create job because the parameters are the same as jobs that are queued, running or already have succeeded: .....

WHERE command_id = %s AND processing_job_status IN (
'success', 'waiting', 'running') """
params = " AND ".join(
["command_parameters->>'%s' = '%s'" % (k, v)
Copy link
Contributor

Choose a reason for hiding this comment

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

agree

@@ -22,7 +22,7 @@
from qiita_core.qiita_settings import qiita_config


def _create_job():
def _create_job(force=True):
Copy link
Contributor

Choose a reason for hiding this comment

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

If we default to True, are there situations in the codebase where this is False?

Copy link
Contributor

Choose a reason for hiding this comment

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

Or rather, this API has changed I believe since the existing functionality would be force=False if I understand the docs above. Will this change be a problem elsewhere?

Copy link
Contributor

Choose a reason for hiding this comment

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

...or was the default behavior previously to force the execution?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a local function to avoid duplication of code that by default always ignores/forces the duplicated jobs. There is a single test (below) that doesn't force this behavior: _create_job(False)

@josenavas
Copy link
Contributor

@antgonza you've test failures here

@antgonza antgonza changed the title Fix 1812 [WIP] Fix 1812 Oct 23, 2017
@antgonza
Copy link
Member Author

Don't merge this as it still needs some work. The code works as expected but the GUI is not catching/working as expected.

@antgonza
Copy link
Member Author

Well, the "fix" was easier than expected, the error now is shown like this:
1812

@antgonza antgonza changed the title [WIP] Fix 1812 Fix 1812 Oct 23, 2017
@antgonza
Copy link
Member Author

@wasade and @ElDeveloper, could you do another pass? Thanks!

for k, v in viewitems(parameters.values):
# this is necessary in case we have an Iterable as a value
# but that is not unicode or string
if isinstance(v, Iterable) and not (isinstance(v, str) or
Copy link
Contributor

Choose a reason for hiding this comment

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

isinstance can take a tuple i.e. isinstance(v, (str, unicode)).

Copy link
Member Author

Choose a reason for hiding this comment

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

k, changing

with self.assertRaisesRegexp(ValueError, 'Cannot create job because '
'the parameters are the same as jobs '
'that are queued, running or already '
'have succeeded:'):
Copy link
Contributor

Choose a reason for hiding this comment

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

How is this passing if this is not a regex, and there's no pattern to match here? Shouldn't there be a job id, or a regex indicating that this should match a job id?

Copy link
Member Author

Choose a reason for hiding this comment

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

cause it behaves as an IN.

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it!

@wasade wasade merged commit 66e3b09 into qiita-spots:dev Oct 24, 2017
@antgonza antgonza deleted the fix-1812 branch February 17, 2018 15:04
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.

5 participants