-
Notifications
You must be signed in to change notification settings - Fork 80
Changing how artifact visibility works #2098
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -260,9 +260,11 @@ def create(cls, filepaths, artifact_type, name=None, prep_template=None, | |
|
||
Notes | ||
----- | ||
The visibility of the artifact is set by default to `sandbox` | ||
The timestamp of the artifact is set by default to `datetime.now()` | ||
The value of `submitted_to_vamps` is set by default to `False` | ||
The visibility of the artifact is set by default to `sandbox` if | ||
prep_template is passed but if parents is passed we will inherit the | ||
most closed visibility. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. most closed -> closest? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand now, what you mean here. |
||
The timestamp of the artifact is set by default to `datetime.now()`. | ||
The value of `submitted_to_vamps` is set by default to `False`. | ||
""" | ||
# We need at least one file | ||
if not filepaths: | ||
|
@@ -617,19 +619,21 @@ def visibility(self, value): | |
only applies when the new visibility is more open than before. | ||
""" | ||
with qdb.sql_connection.TRN: | ||
# In order to correctly propagate the visibility we need to find | ||
# the root of this artifact and then propagate to all the artifacts | ||
sql = "SELECT * FROM qiita.find_artifact_roots(%s)" | ||
qdb.sql_connection.TRN.add(sql, [self.id]) | ||
root_id = qdb.sql_connection.TRN.execute_fetchlast() | ||
root = qdb.artifact.Artifact(root_id) | ||
# these are the ids of all the children from the root | ||
ids = [a.id for a in root.descendants.nodes()] | ||
|
||
sql = """UPDATE qiita.artifact | ||
SET visibility_id = %s | ||
WHERE artifact_id = %s""" | ||
qdb.sql_connection.TRN.add( | ||
sql, [qdb.util.convert_to_id(value, "visibility"), self.id]) | ||
WHERE artifact_id IN %s""" | ||
vis_id = qdb.util.convert_to_id(value, "visibility") | ||
qdb.sql_connection.TRN.add(sql, [vis_id, tuple(ids)]) | ||
qdb.sql_connection.TRN.execute() | ||
# In order to correctly propagate the visibility upstream, we need | ||
# to go one step at a time. By setting up the visibility of our | ||
# parents first, we accomplish that, since they will propagate | ||
# the changes to its parents | ||
for p in self.parents: | ||
visibilites = [[d.visibility] for d in p.descendants.nodes()] | ||
p.visibility = qdb.util.infer_status(visibilites) | ||
|
||
@property | ||
def artifact_type(self): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
-- Apr 1, 2017 | ||
-- setting visibility of all artifacts to be the most open of the full | ||
-- processing tree | ||
|
||
SELECT 42; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from qiita_db.study import Study | ||
|
||
studies = Study.get_by_status('private').union( | ||
Study.get_by_status('public')).union(Study.get_by_status('sandbox')) | ||
raw_data = [pt.artifact for s in studies for pt in s.prep_templates()] | ||
|
||
for rd in raw_data: | ||
# getting the most open visibility of all the children in the pipeline | ||
children = rd.descendants.nodes() | ||
vis = [a.visibility for a in children] | ||
vis.append(rd.visibility) | ||
|
||
new_vis = 'sandbox' | ||
if 'public' in vis: | ||
new_vis = 'public' | ||
elif 'private' in vis: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are there situations where an artifact was bumped to private but where the user expects all other artifacts to remain sandboxed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in praxis no ... at least based on what we have seen so far ... |
||
new_vis = 'private' | ||
|
||
rd.visibility = new_vis |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is passed but
->is passed and if
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I also understand this as well.