)]}'
{"mistral/services/workflows.py":[{"author":{"_account_id":8731,"name":"Renat Akhmerov","email":"renat.akhmerov@gmail.com","username":"rakhmerov"},"change_message_id":"7f252519640421f4b6e33b3d6983b952b360568a","unresolved":false,"context_lines":[{"line_number":85,"context_line":""},{"line_number":86,"context_line":"def _append_all_workflows(definition, is_system, scope, namespace,"},{"line_number":87,"context_line":"                          wf_list_spec, db_wfs):"},{"line_number":88,"context_line":"    wfs \u003d wf_list_spec.get_workflows()"},{"line_number":89,"context_line":"    if len(wfs) \u003d\u003d 1:"},{"line_number":90,"context_line":"        db_wfs.append("},{"line_number":91,"context_line":"            _create_workflow("},{"line_number":92,"context_line":"                wfs[0],"},{"line_number":93,"context_line":"                definition,"},{"line_number":94,"context_line":"                scope,"},{"line_number":95,"context_line":"                namespace,"},{"line_number":96,"context_line":"                is_system"},{"line_number":97,"context_line":"            )"},{"line_number":98,"context_line":"        )"},{"line_number":99,"context_line":"    else:"},{"line_number":100,"context_line":"        wfs_yaml \u003d yaml.load(definition)"},{"line_number":101,"context_line":"        for wf_spec in wfs:"},{"line_number":102,"context_line":"            db_wfs.append("},{"line_number":103,"context_line":"                _create_workflow("},{"line_number":104,"context_line":"                    wf_spec,"},{"line_number":105,"context_line":"                    _cut_wf_def_from_all(wfs_yaml, wf_spec.get_name()),"},{"line_number":106,"context_line":"                    scope,"},{"line_number":107,"context_line":"                    namespace,"},{"line_number":108,"context_line":"                    is_system"},{"line_number":109,"context_line":"                )"},{"line_number":110,"context_line":"            )"},{"line_number":111,"context_line":""},{"line_number":112,"context_line":""},{"line_number":113,"context_line":"def update_workflows(definition, scope\u003d\u0027private\u0027, identifier\u003dNone,"}],"source_content_type":"text/x-python","patch_set":1,"id":"3f79a3b5_ae8d61d5","line":110,"range":{"start_line":88,"start_character":4,"end_line":110,"end_character":13},"updated":"2018-10-09 09:24:28.000000000","message":"I would propose one change. IMO it\u0027s better to leave this loop simple, w/o checking a special case (when the length is one) and just make the function _cut_wf_def_from_all() more intelligent so that it could work with any number of workflows in YAML definition.","commit_id":"869ff8c6a86d42258200aa65621dc9a8716aaa0f"},{"author":{"_account_id":8731,"name":"Renat Akhmerov","email":"renat.akhmerov@gmail.com","username":"rakhmerov"},"change_message_id":"7f252519640421f4b6e33b3d6983b952b360568a","unresolved":false,"context_lines":[{"line_number":129,"context_line":"    db_wfs \u003d []"},{"line_number":130,"context_line":""},{"line_number":131,"context_line":"    with db_api.transaction():"},{"line_number":132,"context_line":"        if len(wfs) \u003d\u003d 1:"},{"line_number":133,"context_line":"            db_wfs.append(_update_workflow("},{"line_number":134,"context_line":"                wfs[0],"},{"line_number":135,"context_line":"                definition,"},{"line_number":136,"context_line":"                scope,"},{"line_number":137,"context_line":"                namespace\u003dnamespace,"},{"line_number":138,"context_line":"                identifier\u003didentifier"},{"line_number":139,"context_line":"            ))"},{"line_number":140,"context_line":"        else:"},{"line_number":141,"context_line":"            wfs_yaml \u003d yaml.load(definition)"},{"line_number":142,"context_line":"            for wf_spec in wfs:"},{"line_number":143,"context_line":"                db_wfs.append(_update_workflow("},{"line_number":144,"context_line":"                    wf_spec,"},{"line_number":145,"context_line":"                    _cut_wf_def_from_all(wfs_yaml, wf_spec.get_name()),"},{"line_number":146,"context_line":"                    scope,"},{"line_number":147,"context_line":"                    namespace\u003dnamespace,"},{"line_number":148,"context_line":"                    identifier\u003didentifier"},{"line_number":149,"context_line":"                ))"},{"line_number":150,"context_line":""},{"line_number":151,"context_line":"    return db_wfs"},{"line_number":152,"context_line":""}],"source_content_type":"text/x-python","patch_set":1,"id":"3f79a3b5_8e618513","line":149,"range":{"start_line":132,"start_character":8,"end_line":149,"end_character":18},"updated":"2018-10-09 09:24:28.000000000","message":"Same here. And that would be good especially because you\u0027d move this check for len() \u003d\u003d 1 to one place instead of having it twice, if it\u0027s needed at all.","commit_id":"869ff8c6a86d42258200aa65621dc9a8716aaa0f"},{"author":{"_account_id":21970,"name":"Andras Kovi","email":"akovi@nokia.com","username":"andras.kovi"},"change_message_id":"f2c85aa9ce3558d43fc346f3db38396a50a56aa4","unresolved":false,"context_lines":[{"line_number":86,"context_line":"def _append_all_workflows(definition, is_system, scope, namespace,"},{"line_number":87,"context_line":"                          wf_list_spec, db_wfs):"},{"line_number":88,"context_line":"    wfs \u003d wf_list_spec.get_workflows()"},{"line_number":89,"context_line":"    wfs_yaml \u003d yaml.load(definition)"},{"line_number":90,"context_line":"    for wf_spec in wfs:"},{"line_number":91,"context_line":"        db_wfs.append("},{"line_number":92,"context_line":"            _create_workflow("}],"source_content_type":"text/x-python","patch_set":2,"id":"3f79a3b5_cbdad648","line":89,"range":{"start_line":89,"start_character":4,"end_line":89,"end_character":36},"updated":"2018-10-11 07:20:54.000000000","message":"actually, the definition may contain comments or intentional formatting that gets lost this way","commit_id":"eaf92ab93187056d1b538068cc2347c7b25815dd"},{"author":{"_account_id":21970,"name":"Andras Kovi","email":"akovi@nokia.com","username":"andras.kovi"},"change_message_id":"9cf73a68284c79199a942eed6f90d0fc41bf4a54","unresolved":false,"context_lines":[{"line_number":86,"context_line":"def _append_all_workflows(definition, is_system, scope, namespace,"},{"line_number":87,"context_line":"                          wf_list_spec, db_wfs):"},{"line_number":88,"context_line":"    wfs \u003d wf_list_spec.get_workflows()"},{"line_number":89,"context_line":"    wfs_yaml \u003d yaml.load(definition)"},{"line_number":90,"context_line":"    for wf_spec in wfs:"},{"line_number":91,"context_line":"        db_wfs.append("},{"line_number":92,"context_line":"            _create_workflow("}],"source_content_type":"text/x-python","patch_set":2,"id":"3f79a3b5_21ecc9ba","line":89,"range":{"start_line":89,"start_character":4,"end_line":89,"end_character":36},"in_reply_to":"3f79a3b5_8e638cdd","updated":"2018-10-11 09:05:36.000000000","message":":)","commit_id":"eaf92ab93187056d1b538068cc2347c7b25815dd"},{"author":{"_account_id":8731,"name":"Renat Akhmerov","email":"renat.akhmerov@gmail.com","username":"rakhmerov"},"change_message_id":"215b152524c618dc34afb32f144d911c0ae066fc","unresolved":false,"context_lines":[{"line_number":86,"context_line":"def _append_all_workflows(definition, is_system, scope, namespace,"},{"line_number":87,"context_line":"                          wf_list_spec, db_wfs):"},{"line_number":88,"context_line":"    wfs \u003d wf_list_spec.get_workflows()"},{"line_number":89,"context_line":"    wfs_yaml \u003d yaml.load(definition)"},{"line_number":90,"context_line":"    for wf_spec in wfs:"},{"line_number":91,"context_line":"        db_wfs.append("},{"line_number":92,"context_line":"            _create_workflow("}],"source_content_type":"text/x-python","patch_set":2,"id":"3f79a3b5_a1545957","line":89,"range":{"start_line":89,"start_character":4,"end_line":89,"end_character":36},"in_reply_to":"3f79a3b5_8e638cdd","updated":"2018-10-11 09:15:09.000000000","message":"Andras, I believe that it\u0027s not a big issue. The way it works now is totally wrong, it\u0027s better to split it up in chunks even losing some comments rather than not doing it at all.","commit_id":"eaf92ab93187056d1b538068cc2347c7b25815dd"},{"author":{"_account_id":29124,"name":"Oleg Ovcharuk","email":"vgvoleg@gmail.com","username":"vgvoleg"},"change_message_id":"0fcc36094fac0e2f11716172c630a76a8d4a5595","unresolved":false,"context_lines":[{"line_number":86,"context_line":"def _append_all_workflows(definition, is_system, scope, namespace,"},{"line_number":87,"context_line":"                          wf_list_spec, db_wfs):"},{"line_number":88,"context_line":"    wfs \u003d wf_list_spec.get_workflows()"},{"line_number":89,"context_line":"    wfs_yaml \u003d yaml.load(definition)"},{"line_number":90,"context_line":"    for wf_spec in wfs:"},{"line_number":91,"context_line":"        db_wfs.append("},{"line_number":92,"context_line":"            _create_workflow("}],"source_content_type":"text/x-python","patch_set":2,"id":"3f79a3b5_8e638cdd","line":89,"range":{"start_line":89,"start_character":4,"end_line":89,"end_character":36},"in_reply_to":"3f79a3b5_cbdad648","updated":"2018-10-11 08:25:29.000000000","message":"from this point this issue looks like impossible to solve","commit_id":"eaf92ab93187056d1b538068cc2347c7b25815dd"},{"author":{"_account_id":21970,"name":"Andras Kovi","email":"akovi@nokia.com","username":"andras.kovi"},"change_message_id":"f2c85aa9ce3558d43fc346f3db38396a50a56aa4","unresolved":false,"context_lines":[{"line_number":179,"context_line":"    )"},{"line_number":180,"context_line":""},{"line_number":181,"context_line":""},{"line_number":182,"context_line":"def _cut_wf_def_from_all(wfs_yaml, wf_name, wf_count, original_def):"},{"line_number":183,"context_line":"    if wf_count \u003d\u003d 1:"},{"line_number":184,"context_line":"        return original_def"},{"line_number":185,"context_line":""},{"line_number":186,"context_line":"    return yaml.dump({"},{"line_number":187,"context_line":"        \u0027version\u0027: wfs_yaml[\u0027version\u0027],"},{"line_number":188,"context_line":"        wf_name: wfs_yaml[wf_name]"},{"line_number":189,"context_line":"    })"}],"source_content_type":"text/x-python","patch_set":2,"id":"3f79a3b5_12ba5670","line":189,"range":{"start_line":182,"start_character":0,"end_line":189,"end_character":6},"updated":"2018-10-11 07:20:54.000000000","message":"I guess, this can be rewritten as:\n\ndef _cut_wf_def_from_all(wfs_yaml, wf_name):\n    return yaml.dump({\n        \u0027version\u0027: wfs_yaml[\u0027version\u0027],\n        wf_name: wfs_yaml[wf_name]\n    })\n\nSeems to work fine and we can get rid of the last two parameters.","commit_id":"eaf92ab93187056d1b538068cc2347c7b25815dd"},{"author":{"_account_id":21970,"name":"Andras Kovi","email":"akovi@nokia.com","username":"andras.kovi"},"change_message_id":"5d102b3f7dc497090ed709268f86f3fb58767dab","unresolved":false,"context_lines":[{"line_number":179,"context_line":"    )"},{"line_number":180,"context_line":""},{"line_number":181,"context_line":""},{"line_number":182,"context_line":"def _cut_wf_def_from_all(wfs_yaml, wf_name, wf_count, original_def):"},{"line_number":183,"context_line":"    if wf_count \u003d\u003d 1:"},{"line_number":184,"context_line":"        return original_def"},{"line_number":185,"context_line":""},{"line_number":186,"context_line":"    return yaml.dump({"},{"line_number":187,"context_line":"        \u0027version\u0027: wfs_yaml[\u0027version\u0027],"},{"line_number":188,"context_line":"        wf_name: wfs_yaml[wf_name]"},{"line_number":189,"context_line":"    })"}],"source_content_type":"text/x-python","patch_set":2,"id":"3f79a3b5_bf0790c8","line":189,"range":{"start_line":182,"start_character":0,"end_line":189,"end_character":6},"in_reply_to":"3f79a3b5_04019b04","updated":"2018-10-11 10:34:02.000000000","message":"I see no reason to optimize something that has practically zero yield in real life scenarios. I ran another test with 1.6MB file. 11 sec for unmarshalling and marshalling again. Which may be optimized to 5 sec. I still don\u0027t think it\u0027s sane to optimize here but hey, this is why this project has several contributors. We have different opinions on stuff.","commit_id":"eaf92ab93187056d1b538068cc2347c7b25815dd"},{"author":{"_account_id":29124,"name":"Oleg Ovcharuk","email":"vgvoleg@gmail.com","username":"vgvoleg"},"change_message_id":"0fcc36094fac0e2f11716172c630a76a8d4a5595","unresolved":false,"context_lines":[{"line_number":179,"context_line":"    )"},{"line_number":180,"context_line":""},{"line_number":181,"context_line":""},{"line_number":182,"context_line":"def _cut_wf_def_from_all(wfs_yaml, wf_name, wf_count, original_def):"},{"line_number":183,"context_line":"    if wf_count \u003d\u003d 1:"},{"line_number":184,"context_line":"        return original_def"},{"line_number":185,"context_line":""},{"line_number":186,"context_line":"    return yaml.dump({"},{"line_number":187,"context_line":"        \u0027version\u0027: wfs_yaml[\u0027version\u0027],"},{"line_number":188,"context_line":"        wf_name: wfs_yaml[wf_name]"},{"line_number":189,"context_line":"    })"}],"source_content_type":"text/x-python","patch_set":2,"id":"3f79a3b5_4ebfb4c9","line":189,"range":{"start_line":182,"start_character":0,"end_line":189,"end_character":6},"in_reply_to":"3f79a3b5_12ba5670","updated":"2018-10-11 08:25:29.000000000","message":"I want to avoid useless convertation in the most frequent case - 1 request for creating 1 workflow. This workflow could be huge, and this simple check could save a lot of time.","commit_id":"eaf92ab93187056d1b538068cc2347c7b25815dd"},{"author":{"_account_id":8731,"name":"Renat Akhmerov","email":"renat.akhmerov@gmail.com","username":"rakhmerov"},"change_message_id":"215b152524c618dc34afb32f144d911c0ae066fc","unresolved":false,"context_lines":[{"line_number":179,"context_line":"    )"},{"line_number":180,"context_line":""},{"line_number":181,"context_line":""},{"line_number":182,"context_line":"def _cut_wf_def_from_all(wfs_yaml, wf_name, wf_count, original_def):"},{"line_number":183,"context_line":"    if wf_count \u003d\u003d 1:"},{"line_number":184,"context_line":"        return original_def"},{"line_number":185,"context_line":""},{"line_number":186,"context_line":"    return yaml.dump({"},{"line_number":187,"context_line":"        \u0027version\u0027: wfs_yaml[\u0027version\u0027],"},{"line_number":188,"context_line":"        wf_name: wfs_yaml[wf_name]"},{"line_number":189,"context_line":"    })"}],"source_content_type":"text/x-python","patch_set":2,"id":"3f79a3b5_81591d5c","line":189,"range":{"start_line":182,"start_character":0,"end_line":189,"end_character":6},"in_reply_to":"3f79a3b5_4ebfb4c9","updated":"2018-10-11 09:15:09.000000000","message":"I think I agree with Oleg. Why not have this optimization?","commit_id":"eaf92ab93187056d1b538068cc2347c7b25815dd"},{"author":{"_account_id":21970,"name":"Andras Kovi","email":"akovi@nokia.com","username":"andras.kovi"},"change_message_id":"9cf73a68284c79199a942eed6f90d0fc41bf4a54","unresolved":false,"context_lines":[{"line_number":179,"context_line":"    )"},{"line_number":180,"context_line":""},{"line_number":181,"context_line":""},{"line_number":182,"context_line":"def _cut_wf_def_from_all(wfs_yaml, wf_name, wf_count, original_def):"},{"line_number":183,"context_line":"    if wf_count \u003d\u003d 1:"},{"line_number":184,"context_line":"        return original_def"},{"line_number":185,"context_line":""},{"line_number":186,"context_line":"    return yaml.dump({"},{"line_number":187,"context_line":"        \u0027version\u0027: wfs_yaml[\u0027version\u0027],"},{"line_number":188,"context_line":"        wf_name: wfs_yaml[wf_name]"},{"line_number":189,"context_line":"    })"}],"source_content_type":"text/x-python","patch_set":2,"id":"3f79a3b5_61f64193","line":189,"range":{"start_line":182,"start_character":0,"end_line":189,"end_character":6},"in_reply_to":"3f79a3b5_4ebfb4c9","updated":"2018-10-11 09:05:36.000000000","message":"well, the def is already loaded into memory. To check, I tried with a 144K yaml. It took 0.65 seconds to load the stuff. Same duration to dump the whole thing. 144K is a 4200 lines long ansible playbook without empty lines (playbooks/docker-buildimage/run.yaml with uncountably repeated last action). I found a large workbook in our code base: 31K, 700 lines, several workflows. Converting the whole doc: 0.13 seconds. If we couple this with the fact that this API is called rarely, I\u0027d say we take the simplification route and not worry about the performance penalty here.\n\nPS: I used this to test\n\ntimeit.timeit(\"import yaml; d \u003d yaml.load(open(\u0027someyamlfile.yaml\u0027)); s \u003d [yaml.dump(d) for i in range(1)]\", number\u003d100)","commit_id":"eaf92ab93187056d1b538068cc2347c7b25815dd"},{"author":{"_account_id":8731,"name":"Renat Akhmerov","email":"renat.akhmerov@gmail.com","username":"rakhmerov"},"change_message_id":"f55a0a578f4cdc3f8bf30c776b938e9c4c28d5cf","unresolved":false,"context_lines":[{"line_number":179,"context_line":"    )"},{"line_number":180,"context_line":""},{"line_number":181,"context_line":""},{"line_number":182,"context_line":"def _cut_wf_def_from_all(wfs_yaml, wf_name, wf_count, original_def):"},{"line_number":183,"context_line":"    if wf_count \u003d\u003d 1:"},{"line_number":184,"context_line":"        return original_def"},{"line_number":185,"context_line":""},{"line_number":186,"context_line":"    return yaml.dump({"},{"line_number":187,"context_line":"        \u0027version\u0027: wfs_yaml[\u0027version\u0027],"},{"line_number":188,"context_line":"        wf_name: wfs_yaml[wf_name]"},{"line_number":189,"context_line":"    })"}],"source_content_type":"text/x-python","patch_set":2,"id":"3f79a3b5_04019b04","line":189,"range":{"start_line":182,"start_character":0,"end_line":189,"end_character":6},"in_reply_to":"3f79a3b5_81591d5c","updated":"2018-10-11 09:17:42.000000000","message":"Well, 144 K is a pretty small YAML :)\n\nBut anyway, the optimization is fairly simple and saves some CPU. I see no harm in having it :)\n\nBut if you insist, I\u0027m ok.","commit_id":"eaf92ab93187056d1b538068cc2347c7b25815dd"}]}
