{"action":"created","comment":{"url":"https://api.github.com/repos/SciTools/iris/pulls/comments/111231808","pull_request_review_id":32463141,"id":111231808,"diff_hunk":"@@ -154,3 +168,267 @@ def get_dir_option(section, option, default=None):\n \n \n IMPORT_LOGGER = get_option(_LOGGING_SECTION, 'import_logger')\n+\n+\n+#################\n+# Runtime options\n+\n+class Option(object):\n+    \"\"\"\n+    An abstract superclass to enforce certain key behaviours for all `Option`\n+    classes.\n+\n+    \"\"\"\n+    @property\n+    def _defaults_dict(self):\n+        raise NotImplementedError\n+\n+    def __setattr__(self, name, value):\n+        if name not in self.__dict__:\n+            # Can't add new names.\n+            msg = \"'Option' object has no attribute {!r}\".format(name)\n+            raise AttributeError(msg)\n+        if value is None:\n+            # Set an explicitly unset value to the default value for the name.\n+            value = self._defaults_dict[name]['default']\n+        if self._defaults_dict[name]['options'] is not None:\n+            # Replace a bad value with the default if there is a defined set of\n+            # specified good values.\n+            if value not in self._defaults_dict[name]['options']:\n+                good_value = self._defaults_dict[name]['default']\n+                wmsg = ('Attempting to set bad value {!r} for attribute {!r}. '\n+                        'Defaulting to {!r}.')\n+                warnings.warn(wmsg.format(value, name, good_value))\n+                value = good_value\n+        self.__dict__[name] = value\n+\n+    def context(self):\n+        raise NotImplementedError\n+\n+\n+class Parallel(Option):\n+    \"\"\"\n+    Control dask parallel processing options for Iris.\n+\n+    \"\"\"\n+    def __init__(self, scheduler=None, num_workers=None):\n+        \"\"\"\n+        Set up options for dask parallel processing.\n+\n+        Currently accepted kwargs:\n+\n+        * scheduler:\n+            The scheduler used to run a dask graph. Must be set to one of:\n+\n+            * 'threaded': (default)\n+                The scheduler processes the graph in parallel using a\n+                thread pool. Good for processing dask arrays and dataframes.\n+            * 'multiprocessing':\n+                The scheduler processes the graph in parallel using a\n+                process pool. Good for processing dask bags.\n+            * 'async':\n+                The scheduler runs synchronously (not in parallel). Good for\n+                debugging.\n+            * The IP address and port of a distributed scheduler:\n+                Specifies the location of a distributed scheduler that has\n+                already been set up. The distributed scheduler will process the\n+                graph.\n+\n+            For more information see\n+            http://dask.pydata.org/en/latest/scheduler-overview.html.\n+\n+        * num_workers:\n+            The number of worker threads or processess to use to run the dask\n+            graph in parallel. Defaults to 1 (that is, processed serially).\n+\n+            .. note::\n+                The value for `num_workers` cannot be set to greater than the\n+                number of CPUs available on the host system. If such a value is\n+                requested, `num_workers` is automatically set to 1 less than\n+                the number of CPUs available on the host system.\n+\n+            .. note::\n+                Only the 'threaded' and 'multiprocessing' schedulers support\n+                the `num_workers` kwarg. If it is specified with the `async` or\n+                `distributed` scheduler, the kwarg is ignored:\n+\n+                * The 'async' scheduler runs serially so will only use a single\n+                worker.\n+                * The number of workers for the 'distributed' scheduler must be\n+                defined when setting up the distributed scheduler. For more\n+                information on setting up distributed schedulers, see\n+                https://distributed.readthedocs.io/en/latest/index.html.\n+\n+        Example usages:\n+\n+        * Specify that we want to load a cube with dask parallel processing\n+        using multiprocessing with six worker processes::\n+\n+            iris.options.parallel(scheduler='multiprocessing', num_workers=6)\n+            iris.load('my_dataset.nc')\n+\n+        * Specify, with a context manager, that we want to load a cube with\n+        dask parallel processing using four worker threads::\n+\n+            with iris.options.parallel(scheduler='threaded', num_workers=4):","path":"lib/iris/config.py","position":139,"original_position":139,"commit_id":"60aebe8e96e84068cb757680bdf6f4166e712e17","original_commit_id":"60aebe8e96e84068cb757680bdf6f4166e712e17","user":{"login":"bjlittle","id":2051656,"avatar_url":"https://avatars1.githubusercontent.com/u/2051656?v=3","gravatar_id":"","url":"https://api.github.com/users/bjlittle","html_url":"https://github.com/bjlittle","followers_url":"https://api.github.com/users/bjlittle/followers","following_url":"https://api.github.com/users/bjlittle/following{/other_user}","gists_url":"https://api.github.com/users/bjlittle/gists{/gist_id}","starred_url":"https://api.github.com/users/bjlittle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bjlittle/subscriptions","organizations_url":"https://api.github.com/users/bjlittle/orgs","repos_url":"https://api.github.com/users/bjlittle/repos","events_url":"https://api.github.com/users/bjlittle/events{/privacy}","received_events_url":"https://api.github.com/users/bjlittle/received_events","type":"User","site_admin":false},"body":"@dkillick `iris.config.parallel`","created_at":"2017-04-12T18:53:15Z","updated_at":"2017-04-12T18:53:15Z","html_url":"https://github.com/SciTools/iris/pull/2462#discussion_r111231808","pull_request_url":"https://api.github.com/repos/SciTools/iris/pulls/2462","_links":{"self":{"href":"https://api.github.com/repos/SciTools/iris/pulls/comments/111231808"},"html":{"href":"https://github.com/SciTools/iris/pull/2462#discussion_r111231808"},"pull_request":{"href":"https://api.github.com/repos/SciTools/iris/pulls/2462"}}},"pull_request":{"url":"https://api.github.com/repos/SciTools/iris/pulls/2462","id":112959184,"html_url":"https://github.com/SciTools/iris/pull/2462","diff_url":"https://github.com/SciTools/iris/pull/2462.diff","patch_url":"https://github.com/SciTools/iris/pull/2462.patch","issue_url":"https://api.github.com/repos/SciTools/iris/issues/2462","number":2462,"state":"open","locked":false,"title":"Iris options (dask parallel processing)","user":{"login":"dkillick","id":3473068,"avatar_url":"https://avatars1.githubusercontent.com/u/3473068?v=3","gravatar_id":"","url":"https://api.github.com/users/dkillick","html_url":"https://github.com/dkillick","followers_url":"https://api.github.com/users/dkillick/followers","following_url":"https://api.github.com/users/dkillick/following{/other_user}","gists_url":"https://api.github.com/users/dkillick/gists{/gist_id}","starred_url":"https://api.github.com/users/dkillick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dkillick/subscriptions","organizations_url":"https://api.github.com/users/dkillick/orgs","repos_url":"https://api.github.com/users/dkillick/repos","events_url":"https://api.github.com/users/dkillick/events{/privacy}","received_events_url":"https://api.github.com/users/dkillick/received_events","type":"User","site_admin":false},"body":"Introduces a new module; `iris.options`. Within this module we can provide classes that control certain elements of Iris' behaviour within a limited scope, such as the lifetime of the session, or within a context manager.\r\n\r\nSpecifically, this PR introduces the `Parallel` class, used to control dask parallel processing options for Iris. The `Parallel` class allows for control of:\r\n\r\n* the **dask scheduler** used to process dask graphs when `compute` is called (defaults to `threaded`), and\r\n* the **number of workers** used to process graphs in parallel (defaults to 1, only available for the `threaded` and `multiprocessing` scheduler options).\r\n\r\nNote: no tests yet (I'll do them next); I was keen to get eyes on the functional code I've proposed here.\r\n\r\nThe pattern proposed here also has an obvious application to the proposal in #2457. \r\n\r\nAddresses #2403. ","created_at":"2017-03-28T12:36:23Z","updated_at":"2017-04-12T18:53:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0c1cb7a88f3232387bef77eef9e85aeaf87519a2","assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/SciTools/iris/milestones/30","html_url":"https://github.com/SciTools/iris/milestone/30","labels_url":"https://api.github.com/repos/SciTools/iris/milestones/30/labels","id":2320122,"number":30,"title":"dask","description":"","creator":{"login":"QuLogic","id":302469,"avatar_url":"https://avatars1.githubusercontent.com/u/302469?v=3","gravatar_id":"","url":"https://api.github.com/users/QuLogic","html_url":"https://github.com/QuLogic","followers_url":"https://api.github.com/users/QuLogic/followers","following_url":"https://api.github.com/users/QuLogic/following{/other_user}","gists_url":"https://api.github.com/users/QuLogic/gists{/gist_id}","starred_url":"https://api.github.com/users/QuLogic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/QuLogic/subscriptions","organizations_url":"https://api.github.com/users/QuLogic/orgs","repos_url":"https://api.github.com/users/QuLogic/repos","events_url":"https://api.github.com/users/QuLogic/events{/privacy}","received_events_url":"https://api.github.com/users/QuLogic/received_events","type":"User","site_admin":false},"open_issues":53,"closed_issues":50,"state":"open","created_at":"2017-02-13T21:29:54Z","updated_at":"2017-04-12T14:01:48Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/SciTools/iris/pulls/2462/commits","review_comments_url":"https://api.github.com/repos/SciTools/iris/pulls/2462/comments","review_comment_url":"https://api.github.com/repos/SciTools/iris/pulls/comments{/number}","comments_url":"https://api.github.com/repos/SciTools/iris/issues/2462/comments","statuses_url":"https://api.github.com/repos/SciTools/iris/statuses/60aebe8e96e84068cb757680bdf6f4166e712e17","head":{"label":"dkillick:iris_options","ref":"iris_options","sha":"60aebe8e96e84068cb757680bdf6f4166e712e17","user":{"login":"dkillick","id":3473068,"avatar_url":"https://avatars1.githubusercontent.com/u/3473068?v=3","gravatar_id":"","url":"https://api.github.com/users/dkillick","html_url":"https://github.com/dkillick","followers_url":"https://api.github.com/users/dkillick/followers","following_url":"https://api.github.com/users/dkillick/following{/other_user}","gists_url":"https://api.github.com/users/dkillick/gists{/gist_id}","starred_url":"https://api.github.com/users/dkillick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dkillick/subscriptions","organizations_url":"https://api.github.com/users/dkillick/orgs","repos_url":"https://api.github.com/users/dkillick/repos","events_url":"https://api.github.com/users/dkillick/events{/privacy}","received_events_url":"https://api.github.com/users/dkillick/received_events","type":"User","site_admin":false},"repo":{"id":8197320,"name":"iris","full_name":"dkillick/iris","owner":{"login":"dkillick","id":3473068,"avatar_url":"https://avatars1.githubusercontent.com/u/3473068?v=3","gravatar_id":"","url":"https://api.github.com/users/dkillick","html_url":"https://github.com/dkillick","followers_url":"https://api.github.com/users/dkillick/followers","following_url":"https://api.github.com/users/dkillick/following{/other_user}","gists_url":"https://api.github.com/users/dkillick/gists{/gist_id}","starred_url":"https://api.github.com/users/dkillick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dkillick/subscriptions","organizations_url":"https://api.github.com/users/dkillick/orgs","repos_url":"https://api.github.com/users/dkillick/repos","events_url":"https://api.github.com/users/dkillick/events{/privacy}","received_events_url":"https://api.github.com/users/dkillick/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dkillick/iris","description":"A powerful, easy to use, and community-driven Python library for analysing and visualising meteorological and oceanographic data sets.","fork":true,"url":"https://api.github.com/repos/dkillick/iris","forks_url":"https://api.github.com/repos/dkillick/iris/forks","keys_url":"https://api.github.com/repos/dkillick/iris/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dkillick/iris/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dkillick/iris/teams","hooks_url":"https://api.github.com/repos/dkillick/iris/hooks","issue_events_url":"https://api.github.com/repos/dkillick/iris/issues/events{/number}","events_url":"https://api.github.com/repos/dkillick/iris/events","assignees_url":"https://api.github.com/repos/dkillick/iris/assignees{/user}","branches_url":"https://api.github.com/repos/dkillick/iris/branches{/branch}","tags_url":"https://api.github.com/repos/dkillick/iris/tags","blobs_url":"https://api.github.com/repos/dkillick/iris/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dkillick/iris/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dkillick/iris/git/refs{/sha}","trees_url":"https://api.github.com/repos/dkillick/iris/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dkillick/iris/statuses/{sha}","languages_url":"https://api.github.com/repos/dkillick/iris/languages","stargazers_url":"https://api.github.com/repos/dkillick/iris/stargazers","contributors_url":"https://api.github.com/repos/dkillick/iris/contributors","subscribers_url":"https://api.github.com/repos/dkillick/iris/subscribers","subscription_url":"https://api.github.com/repos/dkillick/iris/subscription","commits_url":"https://api.github.com/repos/dkillick/iris/commits{/sha}","git_commits_url":"https://api.github.com/repos/dkillick/iris/git/commits{/sha}","comments_url":"https://api.github.com/repos/dkillick/iris/comments{/number}","issue_comment_url":"https://api.github.com/repos/dkillick/iris/issues/comments{/number}","contents_url":"https://api.github.com/repos/dkillick/iris/contents/{+path}","compare_url":"https://api.github.com/repos/dkillick/iris/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dkillick/iris/merges","archive_url":"https://api.github.com/repos/dkillick/iris/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dkillick/iris/downloads","issues_url":"https://api.github.com/repos/dkillick/iris/issues{/number}","pulls_url":"https://api.github.com/repos/dkillick/iris/pulls{/number}","milestones_url":"https://api.github.com/repos/dkillick/iris/milestones{/number}","notifications_url":"https://api.github.com/repos/dkillick/iris/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dkillick/iris/labels{/name}","releases_url":"https://api.github.com/repos/dkillick/iris/releases{/id}","deployments_url":"https://api.github.com/repos/dkillick/iris/deployments","created_at":"2013-02-14T10:14:43Z","updated_at":"2014-06-24T09:07:10Z","pushed_at":"2017-04-12T15:38:41Z","git_url":"git://github.com/dkillick/iris.git","ssh_url":"git@github.com:dkillick/iris.git","clone_url":"https://github.com/dkillick/iris.git","svn_url":"https://github.com/dkillick/iris","homepage":"http://scitools.org.uk/iris/","size":104746,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"SciTools:dask","ref":"dask","sha":"c0a77b7ce2e4a5175037b985fd7a6ca51699ff7c","user":{"login":"SciTools","id":1391487,"avatar_url":"https://avatars0.githubusercontent.com/u/1391487?v=3","gravatar_id":"","url":"https://api.github.com/users/SciTools","html_url":"https://github.com/SciTools","followers_url":"https://api.github.com/users/SciTools/followers","following_url":"https://api.github.com/users/SciTools/following{/other_user}","gists_url":"https://api.github.com/users/SciTools/gists{/gist_id}","starred_url":"https://api.github.com/users/SciTools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SciTools/subscriptions","organizations_url":"https://api.github.com/users/SciTools/orgs","repos_url":"https://api.github.com/users/SciTools/repos","events_url":"https://api.github.com/users/SciTools/events{/privacy}","received_events_url":"https://api.github.com/users/SciTools/received_events","type":"Organization","site_admin":false},"repo":{"id":5312648,"name":"iris","full_name":"SciTools/iris","owner":{"login":"SciTools","id":1391487,"avatar_url":"https://avatars0.githubusercontent.com/u/1391487?v=3","gravatar_id":"","url":"https://api.github.com/users/SciTools","html_url":"https://github.com/SciTools","followers_url":"https://api.github.com/users/SciTools/followers","following_url":"https://api.github.com/users/SciTools/following{/other_user}","gists_url":"https://api.github.com/users/SciTools/gists{/gist_id}","starred_url":"https://api.github.com/users/SciTools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SciTools/subscriptions","organizations_url":"https://api.github.com/users/SciTools/orgs","repos_url":"https://api.github.com/users/SciTools/repos","events_url":"https://api.github.com/users/SciTools/events{/privacy}","received_events_url":"https://api.github.com/users/SciTools/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/SciTools/iris","description":"A powerful, easy to use, and community-driven Python library for analysing and visualising meteorological and oceanographic data sets.","fork":false,"url":"https://api.github.com/repos/SciTools/iris","forks_url":"https://api.github.com/repos/SciTools/iris/forks","keys_url":"https://api.github.com/repos/SciTools/iris/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SciTools/iris/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SciTools/iris/teams","hooks_url":"https://api.github.com/repos/SciTools/iris/hooks","issue_events_url":"https://api.github.com/repos/SciTools/iris/issues/events{/number}","events_url":"https://api.github.com/repos/SciTools/iris/events","assignees_url":"https://api.github.com/repos/SciTools/iris/assignees{/user}","branches_url":"https://api.github.com/repos/SciTools/iris/branches{/branch}","tags_url":"https://api.github.com/repos/SciTools/iris/tags","blobs_url":"https://api.github.com/repos/SciTools/iris/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SciTools/iris/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SciTools/iris/git/refs{/sha}","trees_url":"https://api.github.com/repos/SciTools/iris/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SciTools/iris/statuses/{sha}","languages_url":"https://api.github.com/repos/SciTools/iris/languages","stargazers_url":"https://api.github.com/repos/SciTools/iris/stargazers","contributors_url":"https://api.github.com/repos/SciTools/iris/contributors","subscribers_url":"https://api.github.com/repos/SciTools/iris/subscribers","subscription_url":"https://api.github.com/repos/SciTools/iris/subscription","commits_url":"https://api.github.com/repos/SciTools/iris/commits{/sha}","git_commits_url":"https://api.github.com/repos/SciTools/iris/git/commits{/sha}","comments_url":"https://api.github.com/repos/SciTools/iris/comments{/number}","issue_comment_url":"https://api.github.com/repos/SciTools/iris/issues/comments{/number}","contents_url":"https://api.github.com/repos/SciTools/iris/contents/{+path}","compare_url":"https://api.github.com/repos/SciTools/iris/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SciTools/iris/merges","archive_url":"https://api.github.com/repos/SciTools/iris/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SciTools/iris/downloads","issues_url":"https://api.github.com/repos/SciTools/iris/issues{/number}","pulls_url":"https://api.github.com/repos/SciTools/iris/pulls{/number}","milestones_url":"https://api.github.com/repos/SciTools/iris/milestones{/number}","notifications_url":"https://api.github.com/repos/SciTools/iris/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SciTools/iris/labels{/name}","releases_url":"https://api.github.com/repos/SciTools/iris/releases{/id}","deployments_url":"https://api.github.com/repos/SciTools/iris/deployments","created_at":"2012-08-06T10:09:14Z","updated_at":"2017-04-12T18:00:09Z","pushed_at":"2017-04-12T15:38:42Z","git_url":"git://github.com/SciTools/iris.git","ssh_url":"git@github.com:SciTools/iris.git","clone_url":"https://github.com/SciTools/iris.git","svn_url":"https://github.com/SciTools/iris","homepage":"http://scitools.org.uk/iris/","size":103252,"stargazers_count":161,"watchers_count":161,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":113,"mirror_url":null,"open_issues_count":341,"forks":113,"open_issues":341,"watchers":161,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/SciTools/iris/pulls/2462"},"html":{"href":"https://github.com/SciTools/iris/pull/2462"},"issue":{"href":"https://api.github.com/repos/SciTools/iris/issues/2462"},"comments":{"href":"https://api.github.com/repos/SciTools/iris/issues/2462/comments"},"review_comments":{"href":"https://api.github.com/repos/SciTools/iris/pulls/2462/comments"},"review_comment":{"href":"https://api.github.com/repos/SciTools/iris/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/SciTools/iris/pulls/2462/commits"},"statuses":{"href":"https://api.github.com/repos/SciTools/iris/statuses/60aebe8e96e84068cb757680bdf6f4166e712e17"}}}}
{"actor":{"display_login":"bjlittle"}}