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

Python 3 fixes for set_metadata.py #4607

Merged
merged 2 commits into from Sep 13, 2017

Conversation

Projects
None yet
3 participants
@natefoo
Copy link
Member

commented Sep 13, 2017

You won't actually be able to run set_metadata.py under Python 3 until all the things it imports are also updated for Python 3.

xref. #1715

@@ -131,7 +130,7 @@ def set_metadata():
file_dict = existing_job_metadata_dict.get(dataset.dataset.id, {})
set_meta_with_tool_provided(dataset, file_dict, set_meta_kwds, datatypes_registry)
if max_metadata_value_size:
for k, v in dataset.metadata.items():
for k, v in list(dataset.metadata.items()):

This comment has been minimized.

Copy link
@nsoranzo

nsoranzo Sep 13, 2017

Member

That's a "nice" example where adding list() is required (because of the remove_key() call inside the loop)!

@nsoranzo

This comment has been minimized.

Copy link
Member

commented Sep 13, 2017

I think you also need this change:

@@ -152,7 +152,7 @@
         file_dict['metadata'] = json.loads(new_dataset_instance.metadata.to_JSON_dict())  # storing metadata in external form, need to turn back into dict, then later jsonify
     if existing_job_metadata_dict or new_job_metadata_dict:
         with open(job_metadata, 'wb') as job_metadata_fh:
-            for value in existing_job_metadata_dict.values() + new_job_metadata_dict.values():
+            for value in list(existing_job_metadata_dict.values()) + list(new_job_metadata_dict.values()):
                 job_metadata_fh.write("%s\n" % (json.dumps(value)))
 
     clear_mappers()

because you cannot sum dict_values objects:

d.values() + d.values()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-5-395819ec95f9> in <module>()
----> 1 d.values() + d.values()

TypeError: unsupported operand type(s) for +: 'dict_values' and 'dict_values'
@natefoo

This comment has been minimized.

Copy link
Member Author

commented Sep 13, 2017

Fixed, thanks!

@nsoranzo nsoranzo added this to the 17.09 milestone Sep 13, 2017

@dannon

This comment has been minimized.

Copy link
Member

commented Sep 13, 2017

Restarted API test, wasn't obvious why it failed.

@dannon dannon merged commit a6acf11 into galaxyproject:dev Sep 13, 2017

5 of 6 checks passed

continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
api test Build finished. 292 tests run, 4 skipped, 0 failed.
Details
framework test Build finished. 161 tests run, 0 skipped, 0 failed.
Details
integration test Build finished. 45 tests run, 0 skipped, 0 failed.
Details
lgtm analysis: JavaScript No alert changes
Details
toolshed test Build finished. 579 tests run, 0 skipped, 0 failed.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.