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

Scottx611x/auto import of data fix #1188

Merged
merged 3 commits into from
Jun 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion refinery/analysis_manager/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ def get_galaxy_download_tasks(analysis):
# TODO: when changing permanent=True, fix update of % download
# of file
filestore_uuid = create(
source=download_url, filetype=file_type, permanent=False)
source=download_url, filetype=file_type)
# adding history files to django model
temp_file = AnalysisResult(
analysis_uuid=analysis.uuid,
Expand Down
7 changes: 2 additions & 5 deletions refinery/data_set_manager/isa_tab_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1014,19 +1014,16 @@ def run(self, path, isa_archive=None, preisa_archive=None):
raise Exception()
# 5. assign ISA-Tab archive and pre-ISA-Tab archive if present
try:
self._current_investigation.isarchive_file = \
create(isa_archive, permanent=True)
self._current_investigation.isarchive_file = create(isa_archive)
import_file(self._current_investigation.isarchive_file,
permanent=True,
refresh=True)
except:
pass

if preisa_archive:
self._current_investigation.pre_isarchive_file = \
create(preisa_archive, permanent=True)
create(preisa_archive)
import_file(self._current_investigation.pre_isarchive_file,
permanent=True,
refresh=True)

self._current_investigation.save()
Expand Down
16 changes: 10 additions & 6 deletions refinery/data_set_manager/single_file_column_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def run(self):
# FIXME: this will not create a FileStoreItem if self.metadata_file
# does not exist on disk (e.g., a file object like TemporaryFile)
investigation.pre_isarchive_file = create(
self.metadata_file.name, permanent=True)
self.metadata_file.name)
import_file(investigation.pre_isarchive_file, refresh=True)
investigation.save()

Expand All @@ -203,14 +203,14 @@ def run(self):
data_file_path = self.file_source_translator(
row[self.file_column_index])
data_file_uuid = create(
source=data_file_path, permanent=self.file_permanent)
source=data_file_path)
data_files.append(data_file_uuid)
# add auxiliary file to file store
if self.auxiliary_file_column_index:
auxiliary_file_path = self.file_source_translator(
row[self.auxiliary_file_column_index])
auxiliary_file_uuid = create(
source=auxiliary_file_path, permanent=self.file_permanent)
source=auxiliary_file_path)
data_files.append(auxiliary_file_uuid)
else:
auxiliary_file_uuid = None
Expand Down Expand Up @@ -259,9 +259,13 @@ def run(self):
subtype=self.headers[column_index].strip().lower(),
value=row[column_index].strip()
)
# kick off data file importing tasks
for uuid in data_files:
import_file.delay(uuid)

# Start remote file import tasks if `Data File Permanent` flag set
# by the user
if self.file_permanent:
for uuid in data_files:
import_file.delay(uuid)

return investigation


Expand Down
15 changes: 2 additions & 13 deletions refinery/file_store/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,15 @@


@task()
def create(source, sharename='', filetype='', permanent=False, file_size=1):
def create(source, sharename='', filetype='', file_size=1):
"""Create a FileStoreItem instance and return its UUID
Important: source must be either an absolute file system path or a URL

:param source: URL or absolute file system path to a file.
:type source: str.
:param sharename: Group share name.
:type sharename: str.
:param filetype: File extension
:type filetype: str.
:param permanent: Flag indicating whether to add this instance to the cache
or not.
:type permanent: bool.
:param file_size: For cases when the remote site specified by source URL
doesn't provide file size in the HTTP headers.
:type file_size: int.
Expand All @@ -48,17 +44,12 @@ def create(source, sharename='', filetype='', permanent=False, file_size=1):

logger.info("FileStoreItem created with UUID %s", item.uuid)

# TODO: don't add to cache if permanent

return item.uuid


@task(track_started=True)
def import_file(uuid, permanent=False, refresh=False, file_size=0):
def import_file(uuid, refresh=False, file_size=0):
"""Download or copy file specified by UUID.

:param permanent: Flag for adding the FileStoreItem to cache.
:type permanent: bool.
:param refresh: Flag for forcing update of the file.
:type refresh: bool.
:param file_size: size of the remote file.
Expand Down Expand Up @@ -195,8 +186,6 @@ def import_file(uuid, permanent=False, refresh=False, file_size=0):
# save the model instance
item.save()

# TODO: if permanent is False then add to cache

return item


Expand Down
12 changes: 6 additions & 6 deletions refinery/visualization_manager/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ def createIGVsession(genome, uuids, is_file_uuid=False):
tempfilename.write(doc.toprettyxml(indent=" "))
tempfilename.close()
# getting file_store_uuid
filestore_uuid = create(tempfilename.name, permanent=True, filetype="xml")
filestore_item = import_file(filestore_uuid, permanent=True, refresh=True)
filestore_uuid = create(tempfilename.name, filetype="xml")
filestore_item = import_file(filestore_uuid, refresh=True)
# file to rename
temp_name = filestore_item.datafile.name.split('/')
temp_name = temp_name[len(temp_name) - 1] + '.xml'
Expand Down Expand Up @@ -358,8 +358,8 @@ def createIGVsessionAnnot(genome, uuids, annot_uuids=None, samp_file=None):
tempfilename.close()

# getting file_store_uuid
filestore_uuid = create(tempfilename.name, permanent=True, filetype="xml")
filestore_item = import_file(filestore_uuid, permanent=True, refresh=True)
filestore_uuid = create(tempfilename.name, filetype="xml")
filestore_item = import_file(filestore_uuid, refresh=True)

# file to rename
temp_name = filestore_item.datafile.name.split('/')
Expand Down Expand Up @@ -449,8 +449,8 @@ def addIGVSamples(fields, results_samp, annot_samples=None):
tempsampname.close()

# getting file_store_uuid
filestore_uuid = create(tempsampname.name, permanent=True, filetype="txt")
filestore_item = import_file(filestore_uuid, permanent=True, refresh=True)
filestore_uuid = create(tempsampname.name, filetype="txt")
filestore_item = import_file(filestore_uuid, refresh=True)

# file to rename
temp_file = filestore_item.datafile.name.split('/')
Expand Down