Skip to content

Conversation

@antgonza
Copy link
Member

This adds the basic archiving code. @sjanssen2 and @josenavas, could you take a look so we can continue working on it? Thanks!

@codecov-io
Copy link

codecov-io commented Dec 27, 2017

Codecov Report

Merging #2449 into dev will increase coverage by 0.01%.
The diff coverage is 97.45%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev    #2449      +/-   ##
==========================================
+ Coverage   94.15%   94.17%   +0.01%     
==========================================
  Files         164      166       +2     
  Lines       19445    19558     +113     
==========================================
+ Hits        18308    18418     +110     
- Misses       1137     1140       +3
Impacted Files Coverage Δ
qiita_db/handlers/archive.py 100% <100%> (ø) ⬆️
qiita_db/handlers/tests/test_archive.py 84.37% <100%> (+6.11%) ⬆️
qiita_db/handlers/tests/test_processing_job.py 98.71% <100%> (+0.11%) ⬆️
qiita_db/__init__.py 100% <100%> (ø) ⬆️
qiita_db/test/test_archive.py 96.15% <96.15%> (ø)
qiita_db/archive.py 96.66% <96.66%> (ø)

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 67a33dc...376d78f. Read the comment docs.

@sjanssen2
Copy link
Contributor

Hey @antgonza thanks for your efforts. I am travelling with my family right now who will get quite angry if I start staring into my laptop. I might find some time in two days

env:
global:
- PYTHON_VERSION=2.7
- PYTHON_VERSION=3.5
Copy link
Contributor

Choose a reason for hiding this comment

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

?

Copy link
Member Author

Choose a reason for hiding this comment

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

Long story short: there is a bug in conda that the Qiime2 guys reported and this is the best way to install everything. See that these changes are in master and are passing.

Raises
------
ValueError
Copy link
Contributor

Choose a reason for hiding this comment

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

extra tab

Copy link
Member Author

Choose a reason for hiding this comment

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

removing

If the Artifact type is not BIOM
If the artifact doesn't have a biom filepath
"""
with qdb.sql_connection.TRN:
Copy link
Contributor

Choose a reason for hiding this comment

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

seems like most of the logic contained can be done outside of the context?

Copy link
Member Author

Choose a reason for hiding this comment

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

possible but I think it's better to leave it like this as some of these steps are actually accessing the DB so this assures that everything it's in the same transaction.

Copy link
Contributor

Choose a reason for hiding this comment

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

oh. implicit operations remote resource operations? :/ okay.

If the artifact doesn't have a biom filepath
"""
with qdb.sql_connection.TRN:
acmd = job.command
Copy link
Contributor

Choose a reason for hiding this comment

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

same?

Copy link
Member Author

Choose a reason for hiding this comment

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

same ... 😄

Copy link
Contributor

Choose a reason for hiding this comment

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

off topic but how does a developer know whether a given qiita method (or property) will issue a db call?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the safest assumption is that any property/method from a Qiita object will issue a DB call ... as everything is store in there.

Notes
-----
If archive_merging_scheme is None it will return all
Copy link
Contributor

Choose a reason for hiding this comment

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

extra indent

Copy link
Member Author

Choose a reason for hiding this comment

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

removing

feature values
"""
with qdb.sql_connection.TRN:
extras = []
Copy link
Contributor

Choose a reason for hiding this comment

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

same?

Copy link
Member Author

Choose a reason for hiding this comment

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

ya' know, same 😉


# now let's tests that all the inserts happen as expected
exp = {
'featureA4': '{valuesA: vA, int: 1}',
Copy link
Contributor

Choose a reason for hiding this comment

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

are these supposed to be json? if so, they're not as the strings "vA" and "vB" are not quoted, nor are the keys

Copy link
Member Author

Choose a reason for hiding this comment

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

well, they are strings but supposedly represent json, I can change for test if you feel strongly about it.

Copy link
Contributor

Choose a reason for hiding this comment

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

if this is stuff generated from the code, then it certainly is not generating json. if this is supposed to be json, should the data contained in the insertion logic validate that the data are json?

Copy link
Member Author

@antgonza antgonza left a comment

Choose a reason for hiding this comment

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

Thanks @wasade !

env:
global:
- PYTHON_VERSION=2.7
- PYTHON_VERSION=3.5
Copy link
Member Author

Choose a reason for hiding this comment

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

Long story short: there is a bug in conda that the Qiime2 guys reported and this is the best way to install everything. See that these changes are in master and are passing.

Raises
------
ValueError
Copy link
Member Author

Choose a reason for hiding this comment

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

removing

If the Artifact type is not BIOM
If the artifact doesn't have a biom filepath
"""
with qdb.sql_connection.TRN:
Copy link
Member Author

Choose a reason for hiding this comment

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

possible but I think it's better to leave it like this as some of these steps are actually accessing the DB so this assures that everything it's in the same transaction.

If the artifact doesn't have a biom filepath
"""
with qdb.sql_connection.TRN:
acmd = job.command
Copy link
Member Author

Choose a reason for hiding this comment

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

same ... 😄

Notes
-----
If archive_merging_scheme is None it will return all
Copy link
Member Author

Choose a reason for hiding this comment

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

removing

feature values
"""
with qdb.sql_connection.TRN:
extras = []
Copy link
Member Author

Choose a reason for hiding this comment

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

ya' know, same 😉


# now let's tests that all the inserts happen as expected
exp = {
'featureA4': '{valuesA: vA, int: 1}',
Copy link
Member Author

Choose a reason for hiding this comment

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

well, they are strings but supposedly represent json, I can change for test if you feel strongly about it.

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.

Minor comments

"""

@classmethod
def _inserting_main_steps(cls, TRN, ms, features):
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor but there is no need to pass the TRN object by parameter. The system is using the singleton pattern, so using "with ...TRN:" should be good.

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.

Methods
-------
insert_from_biom
Copy link
Contributor

Choose a reason for hiding this comment

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

insert_from_artifact?

Copy link
Member Author

Choose a reason for hiding this comment

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

yup

self.assertEqual(
str(err.exception), 'To archive artifact must be BIOM but FASTQ')

# 7 - to test error due to not filepath biom
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 testing that an artifact of type BIOM doesn't have a BIOM? that seems like it should never happen.

Copy link
Member Author

Choose a reason for hiding this comment

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

right, but I think an extra test never hurts ... anyway, want me to remove it?

Copy link
Member Author

@antgonza antgonza left a comment

Choose a reason for hiding this comment

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

Thanks! @josenavas

Methods
-------
insert_from_biom
Copy link
Member Author

Choose a reason for hiding this comment

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

yup

"""

@classmethod
def _inserting_main_steps(cls, TRN, ms, features):
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.

self.assertEqual(
str(err.exception), 'To archive artifact must be BIOM but FASTQ')

# 7 - to test error due to not filepath biom
Copy link
Member Author

Choose a reason for hiding this comment

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

right, but I think an extra test never hurts ... anyway, want me to remove it?

@josenavas josenavas merged commit c453abe into qiita-spots:dev Jan 12, 2018
@antgonza antgonza deleted the adding-archive 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.

7 participants