Skip to content

Commit

Permalink
Merge branch 'ui-v2' of https://github.com/IGS/gEAR into ui-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
adkinsrs committed Sep 9, 2024
2 parents ad890c5 + b3b903d commit 43c2cfc
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 24 deletions.
13 changes: 1 addition & 12 deletions lib/gear/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ def __init__(self, metadata=None, file_path=None):


def read_file(self, file_path=None):
print(f'DEBUG: Reading metadata file: {file_path}', file=sys.stderr)
"""
Reads dataset_metadata.xlsx or dataset_metadata.json into a pandas dataframe
Expand Down Expand Up @@ -267,7 +266,7 @@ def get_field_value(self, field=None):

return fv

def save_to_mysql(self, status=None):
def save_to_mysql(self, status=None, is_public=0):
"""
Saves metadata to gEAR MySQL table 'dataset'. If present, also saves tags.
Expand Down Expand Up @@ -302,16 +301,6 @@ def save_to_mysql(self, status=None):
organism_id = id

geo_id = str( get_value_from_df(df, 'geo_accession') ).strip()

# Make all datasets private if not specified in the metadata
try:
is_public = get_value_from_df(df, 'is_public')

if is_public != 1:
is_public = 0
except:
is_public = 0

ldesc = get_value_from_df(df, 'summary')
dtype = get_value_from_df(df, 'dataset_type')
schematic_image = get_value_from_df(df, 'schematic_image')
Expand Down
33 changes: 26 additions & 7 deletions www/cgi/finalize_uploaded_expression_dataset.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ result = {
import cgi
import json
import os, sys
import shutil

lib_path = os.path.abspath(os.path.join('..', '..', 'lib'))
sys.path.append(lib_path)
Expand All @@ -50,6 +51,16 @@ def main():
share_uid = form.getvalue('share_uid')
session_id = form.getvalue('session_id')
dataset_id = form.getvalue('dataset_uid')
dataset_visibility = form.getvalue('dataset_visibility')

if dataset_visibility == 'private':
is_public = 0
elif dataset_visibility == 'public':
is_public = 1
else:
result['message'] = 'Invalid dataset visibility.'
print(json.dumps(result))
sys.exit(0)

user = geardb.get_user_from_session_id(session_id)
if user is None:
Expand Down Expand Up @@ -78,7 +89,7 @@ def main():
# Load the metadata into the database
metadata = Metadata(file_path=metadata_file)
try:
metadata.save_to_mysql(status='complete')
metadata.save_to_mysql(status='complete', is_public=is_public)
result['metadata_loaded'] = 1
except Exception as e:
result['message'] = 'Error saving metadata to MySQL: {}'.format(str(e))
Expand All @@ -87,13 +98,12 @@ def main():

# migrate the H5AD file
h5ad_file = os.path.join(dataset_upload_dir, f'{share_uid}.h5ad')
h5ad_dest = os.path.join(dataset_final_dir, f'{dataset_id}.h5ad')
if not os.path.exists(h5ad_file):
result['message'] = 'H5AD file not found: {}'.format(h5ad_file)
print(json.dumps(result))
sys.exit(0)

h5ad_dest = os.path.join(dataset_final_dir, f'{dataset_id}.h5ad')

try:
os.rename(h5ad_file, h5ad_dest)
result['h5ad_migrated'] = 1
Expand All @@ -102,16 +112,25 @@ def main():
print(json.dumps(result))
sys.exit(0)

# migrate the tarball
tarball_file = os.path.join(dataset_upload_dir, f'{share_uid}.tar.gz')
tarball_dest = os.path.join(dataset_final_dir, f'{dataset_id}.tar.gz')

try:
os.rename(tarball_file, tarball_dest)
result['tarball_migrated'] = 1
except Exception as e:
result['message'] = 'Error migrating tarball file: {}'.format(str(e))
print(json.dumps(result))
sys.exit(0)

# if we made it this far, all is well, so return success
result['success'] = 1
result['message'] = 'All steps completed successfully.'
print(json.dumps(result))





# now delete the entire upload directory
shutil.rmtree(dataset_upload_dir)

if __name__ == '__main__':
main()
4 changes: 2 additions & 2 deletions www/include/primary_nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
</a>
</span>
</li>
<!--

<li>
<span class="icon-text is-align-items-center is-flex">
<a class="icon-link-part" tool="upload_dataset" href="./upload_dataset.html">
Expand All @@ -137,7 +137,7 @@
</a>
</span>
</li>
-->

</ul>
<p class="menu-label mb-0 is-capitalized has-text-primary-light">
<span class="menu-label-text">Support</span>
Expand Down
16 changes: 14 additions & 2 deletions www/js/upload_dataset.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ window.onload=function() {
stepTo('finalize-dataset');
});

document.getElementById('dataset-curate-submit').addEventListener('click', (event) => {
event.preventDefault();

let url = `/dataset_curator.html?dataset_id=${dataset_uid}`;
window.location.href = url;
});

document.getElementById('metadata-form-submit').addEventListener('click', (event) => {
event.preventDefault();
let errored_fields = validateMetadataForm();
Expand Down Expand Up @@ -195,6 +202,9 @@ const finalizeUpload = async () => {
formData.append('session_id', CURRENT_USER.session_id);
formData.append('dataset_uid', dataset_uid);

const dataset_visibility = document.querySelector('input[name=dataset-visibility]:checked').value;
formData.append('dataset_visibility', dataset_visibility);

const data = await apiCallsMixin.finalizeExpressionUpload(formData);

if (data['metadata_loaded']) {
Expand All @@ -214,8 +224,10 @@ const finalizeUpload = async () => {
}

if (data.success) {
console.log("SUCCESS");
console.log(data);
// Not actually doing anything further with access rights after the initial insert,
// so can set it as successful here
document.getElementById('finalize-setting-access').classList.remove('mdi-checkbox-blank-outline');
document.getElementById('finalize-setting-access').classList.add('mdi-checkbox-marked');
document.getElementById('dataset-finalize-next-step').disabled = false;
} else {
console.log("ERROR");
Expand Down
26 changes: 25 additions & 1 deletion www/upload_dataset.html
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ <h3>Steps being performed:</h3>
<li>
<span class="icon-text">
<span class="icon">
<i class="mdi mdi-checkbox-blank-outline"></i>
<i id="finalize-setting-access" class="mdi mdi-checkbox-blank-outline"></i>
</span>
<span>Setting access rights</span>
</span>
Expand All @@ -881,6 +881,30 @@ <h3>Steps being performed:</h3>
</div>
</div>
<div id="step-curate-dataset-c" class="step-c is-hidden">
<h1>Step - Curate dataset</h1>
<p>
Your dataset has been submitted and is now available in the Dataset Explorer.
</p>
<hr />
<div class="columns">
<div class="column">
<h3>What is curation?</h3>
<p>
Right now your dataset is stored in the system but there
are no visualizations created so users can explore it. Curation is the process
of creating these visualizations, which can include things like bar charts, UMAPs,
heatmaps, etc.
</p>
<div class="field mt-6">
<div class="control">
<button class="button is-primary" id="dataset-curate-submit">Curate dataset</button>
</div>
</div>
</div>
<div class="column">
<img class="img-fluid" src="/img/gear_plot_type_examples.png" alt="Dataset curation examples" />
</div>
</div>
</div>
</div>
</div> <!-- end #logged-in-c -->
Expand Down

0 comments on commit 43c2cfc

Please sign in to comment.