{"action":"created","issue":{"url":"https://api.github.com/repos/crest-cassia/oacis/issues/516","repository_url":"https://api.github.com/repos/crest-cassia/oacis","labels_url":"https://api.github.com/repos/crest-cassia/oacis/issues/516/labels{/name}","comments_url":"https://api.github.com/repos/crest-cassia/oacis/issues/516/comments","events_url":"https://api.github.com/repos/crest-cassia/oacis/issues/516/events","html_url":"https://github.com/crest-cassia/oacis/pull/516","id":196606648,"number":516,"title":"[WIP] Add Python API","user":{"login":"yohm","id":718731,"avatar_url":"https://avatars.githubusercontent.com/u/718731?v=3","gravatar_id":"","url":"https://api.github.com/users/yohm","html_url":"https://github.com/yohm","followers_url":"https://api.github.com/users/yohm/followers","following_url":"https://api.github.com/users/yohm/following{/other_user}","gists_url":"https://api.github.com/users/yohm/gists{/gist_id}","starred_url":"https://api.github.com/users/yohm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yohm/subscriptions","organizations_url":"https://api.github.com/users/yohm/orgs","repos_url":"https://api.github.com/users/yohm/repos","events_url":"https://api.github.com/users/yohm/events{/privacy}","received_events_url":"https://api.github.com/users/yohm/received_events","type":"User","site_admin":false},"labels":[{"id":59053908,"url":"https://api.github.com/repos/crest-cassia/oacis/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-12-20T07:45:22Z","updated_at":"2016-12-21T06:17:39Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/crest-cassia/oacis/pulls/516","html_url":"https://github.com/crest-cassia/oacis/pull/516","diff_url":"https://github.com/crest-cassia/oacis/pull/516.diff","patch_url":"https://github.com/crest-cassia/oacis/pull/516.patch"},"body":"Python API is introduced. To call OACIS APIs implemented in Ruby, we developed [rb_call](https://github.com/yohm/rb_call) library.\r\nrb_call is a small library that let you call Ruby methods from Python.\r\n\r\nA sample code would look like the following.\r\nYou can run the code after you import `oacis.rb` file, which is located in the top directory of oacis.\r\n\r\n```py3\r\nimport oacis\r\n\r\nsim = oacis.Simulator.where( {'name':'sample_simulator'} ).first()\r\nprint( sim.name() )\r\nprint( sim.command() )\r\nprint( [h.name() for h in sim.executable_on()] )\r\n\r\nprint( len( sim.runs() ) )\r\nprint( len(sim.runs().where({'status':'finished'})) )\r\n\r\nps = sim.find_parameter_set( {'p1':1.0, 'p2':2.0, 'p3':3.0} )\r\nprint( ps.id(), ps.v(), ps.runs().count(), ps.runs().where({'status':'finished'}).count() )\r\nprint( ps.runs_status_count() )\r\nprint( ps.average_result(\"sum\") )\r\n\r\nrun = ps.runs().first()\r\n\r\nprint( run.id(), run.status(), run.result(), run.cpu_time(), run.finished_at(), run.dir() )\r\n\r\n# See http://www.rubydoc.info/github/mongoid/origin/Origin/Selectable\r\nprint(\"p2 == 10.0 and p3 == 3.0\")\r\nfound = sim.parameter_sets().where({\"v.p2\":10.0, \"v.p3\":3.0}).asc(\"v.p1\")\r\nfor ps in found:\r\n    print( ps.v() )\r\n\r\nprint(\"p1 <= 2 and p2 > 15.0 and p3 == 3.0\")\r\nfound = sim.parameter_sets().lte( {\"v.p1\":2} ).gt( {\"v.p2\":15.0} ).where( {\"v.p3\":3.0} )\r\nfor ps in found:\r\n    print( ps.v() )\r\n\r\nprint(\"p1 is in [2,4] and p2==20\")\r\nfound = sim.parameter_sets().send('in', {\"v.p1\":[2,4]} ).where( {\"v.p2\":20} )\r\nfor ps in found:\r\n    print( ps.v() )\r\n\r\nprint(\"p1 <= 3 and p2 <= 6.0, ordered by p1 in ascending order and p2 in descending order\")\r\nfound = sim.parameter_sets().lte( {\"v.p1\":3, \"v.p2\": 6.0} ).order_by( {\"v.p1\":'asc', \"v.p2\":'desc'} )\r\nfor ps in found:\r\n    print( ps.v() )\r\n```\r\n\r\nDocuments are in preparation.\r\n"},"comment":{"url":"https://api.github.com/repos/crest-cassia/oacis/issues/comments/268445455","html_url":"https://github.com/crest-cassia/oacis/pull/516#issuecomment-268445455","issue_url":"https://api.github.com/repos/crest-cassia/oacis/issues/516","id":268445455,"user":{"login":"takeshi-uchitane","id":5600507,"avatar_url":"https://avatars.githubusercontent.com/u/5600507?v=3","gravatar_id":"","url":"https://api.github.com/users/takeshi-uchitane","html_url":"https://github.com/takeshi-uchitane","followers_url":"https://api.github.com/users/takeshi-uchitane/followers","following_url":"https://api.github.com/users/takeshi-uchitane/following{/other_user}","gists_url":"https://api.github.com/users/takeshi-uchitane/gists{/gist_id}","starred_url":"https://api.github.com/users/takeshi-uchitane/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/takeshi-uchitane/subscriptions","organizations_url":"https://api.github.com/users/takeshi-uchitane/orgs","repos_url":"https://api.github.com/users/takeshi-uchitane/repos","events_url":"https://api.github.com/users/takeshi-uchitane/events{/privacy}","received_events_url":"https://api.github.com/users/takeshi-uchitane/received_events","type":"User","site_admin":false},"created_at":"2016-12-21T06:17:39Z","updated_at":"2016-12-21T06:17:39Z","body":"it works!"}}
{"actor":{"display_login":"takeshi-uchitane"}}