We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
`pfnopt.minimize` fails under `strorage=None` (default)
```python
import pfnopt


def obj(client):
    x = client.sample_uniform('x', 0.1, 0.2)
    return x


def main():
    pfnopt.minimize(obj, n_trials=2)


if __name__ == '__main__':
    main()
```

```
AttributeError: 'NoneType' object has no attribute 'get_study_uuid_from_id'
```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `pfnopt/study.py`
Content:
```
1 import datetime
2 import multiprocessing
3 import multiprocessing.pool
4 from typing import Any  # NOQA
5 from typing import Callable  # NOQA
6 from typing import Dict  # NOQA
7 from typing import Iterable  # NOQA
8 from typing import List  # NOQA
9 from typing import Optional  # NOQA
10 
11 from pfnopt import client as client_module
12 from pfnopt import pruners
13 from pfnopt import samplers
14 from pfnopt import storages
15 from pfnopt import trial  # NOQA
16 
17 ObjectiveFuncType = Callable[[client_module.BaseClient], float]
18 
19 
20 class Study(object):
21 
22     def __init__(
23             self,
24             study_uuid,  # type: str
25             storage,  # type: storages.BaseStorage
26             sampler=None,  # type: samplers.BaseSampler
27             pruner=None,  # type: pruners.BasePruner
28     ):
29         # type: (...) -> None
30 
31         self.study_uuid = study_uuid
32         self.storage = storage
33         self.sampler = sampler or samplers.TPESampler()
34         self.pruner = pruner or pruners.MedianPruner()
35 
36         self.study_id = storage.get_study_id_from_uuid(study_uuid)
37 
38     @property
39     def best_params(self):
40         # type: () -> Dict[str, Any]
41 
42         return self.best_trial.params
43 
44     @property
45     def best_value(self):
46         # type: () -> float
47 
48         return self.best_trial.value
49 
50     @property
51     def best_trial(self):
52         # type: () -> trial.Trial
53 
54         return self.storage.get_best_trial(self.study_id)
55 
56     @property
57     def trials(self):
58         # type: () -> List[trial.Trial]
59 
60         return self.storage.get_all_trials(self.study_id)
61 
62     def run(self, func, n_trials=None, timeout_seconds=None, n_jobs=1):
63         # type: (ObjectiveFuncType, Optional[int], Optional[float], int) -> None
64 
65         if n_jobs == 1:
66             self._run_sequential(func, n_trials, timeout_seconds)
67         else:
68             self._run_parallel(func, n_trials, timeout_seconds, n_jobs)
69 
70     def _run_sequential(self, func, n_trials, timeout_seconds):
71         # type: (ObjectiveFuncType, Optional[int], Optional[float]) -> None
72 
73         i_trial = 0
74         time_start = datetime.datetime.now()
75         while True:
76             if n_trials is not None:
77                 if i_trial >= n_trials:
78                     break
79                 i_trial += 1
80 
81             if timeout_seconds is not None:
82                 elapsed_seconds = (datetime.datetime.now() - time_start).total_seconds()
83                 if elapsed_seconds >= timeout_seconds:
84                     break
85 
86             trial_id = self.storage.create_new_trial_id(self.study_id)
87             client = client_module.LocalClient(self, trial_id)
88             result = func(client)
89             client.complete(result)
90 
91     def _run_parallel(self, func, n_trials, timeout_seconds, n_jobs):
92         # type: (ObjectiveFuncType, Optional[int], Optional[float], int) -> None
93 
94         if isinstance(self.storage, storages.RDBStorage):
95             raise TypeError('Parallel run with RDBStorage is not supported.')
96 
97         if n_jobs == -1:
98             n_jobs = multiprocessing.cpu_count()
99 
100         pool = multiprocessing.pool.ThreadPool(n_jobs)  # type: ignore
101 
102         def f(_):
103             trial_id = self.storage.create_new_trial_id(self.study_id)
104             client = client_module.LocalClient(self, trial_id)
105             result = func(client)
106             client.complete(result)
107 
108         self.start_datetime = datetime.datetime.now()
109 
110         if n_trials is not None:
111             ite = range(n_trials)  # type: Iterable[int]
112         else:
113             ite = iter(int, 1)  # Infinite iterator
114 
115         imap_ite = pool.imap(f, ite, chunksize=1)
116         while True:
117             if timeout_seconds is None:
118                 to = None
119             else:
120                 elapsed_timedelta = datetime.datetime.now() - self.start_datetime
121                 elapsed_seconds = elapsed_timedelta.total_seconds()
122                 to = (timeout_seconds - elapsed_seconds)
123 
124             try:
125                 imap_ite.next(timeout=to)  # type: ignore
126             except (StopIteration, multiprocessing.TimeoutError):  # type: ignore
127                 break
128 
129         pool.terminate()
130 
131 
132 def minimize(
133         func,  # type: ObjectiveFuncType
134         n_trials=None,  # type: Optional[int]
135         timeout_seconds=None,  # type: Optional[float]
136         n_jobs=1,  # type: int
137         storage=None,  # type: storages.BaseStorage
138         sampler=None,  # type: samplers.BaseSampler
139         pruner=None,  # type: pruners.BasePruner
140         study=None,  # type: Study
141 ):
142     # type: (...) -> Study
143 
144     study = study or create_new_study(storage=storage, sampler=sampler, pruner=pruner)
145     study.run(func, n_trials, timeout_seconds, n_jobs)
146     return study
147 
148 
149 # TODO(akiba): implement me
150 def maximize():
151     raise NotImplementedError
152 
153 
154 def create_new_study(storage, sampler=None, pruner=None):
155     # type: (storages.BaseStorage, samplers.BaseSampler, pruners.BasePruner) -> Study
156     study_uuid = storage.get_study_uuid_from_id(storage.create_new_study_id())
157     return Study(study_uuid=study_uuid, storage=storage, sampler=sampler, pruner=pruner)
158
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/pfnopt/study.py b/pfnopt/study.py
--- a/pfnopt/study.py
+++ b/pfnopt/study.py
@@ -140,7 +140,7 @@
         study=None,  # type: Study
 ):
     # type: (...) -> Study
-
+    storage = storage or storages.InMemoryStorage()
     study = study or create_new_study(storage=storage, sampler=sampler, pruner=pruner)
     study.run(func, n_trials, timeout_seconds, n_jobs)
     return study

{"golden_diff": "diff --git a/pfnopt/study.py b/pfnopt/study.py\n--- a/pfnopt/study.py\n+++ b/pfnopt/study.py\n@@ -140,7 +140,7 @@\n         study=None,  # type: Study\n ):\n     # type: (...) -> Study\n-\n+    storage = storage or storages.InMemoryStorage()\n     study = study or create_new_study(storage=storage, sampler=sampler, pruner=pruner)\n     study.run(func, n_trials, timeout_seconds, n_jobs)\n     return study\n", "issue": "`pfnopt.minimize` fails under `strorage=None` (default)\n```python\r\nimport pfnopt\r\n\r\n\r\ndef obj(client):\r\n    x = client.sample_uniform('x', 0.1, 0.2)\r\n    return x\r\n\r\n\r\ndef main():\r\n    pfnopt.minimize(obj, n_trials=2)\r\n\r\n\r\nif __name__ == '__main__':\r\n    main()\r\n```\r\n\r\n```\r\nAttributeError: 'NoneType' object has no attribute 'get_study_uuid_from_id'\r\n```\n", "before_files": [{"content": "import datetime\nimport multiprocessing\nimport multiprocessing.pool\nfrom typing import Any  # NOQA\nfrom typing import Callable  # NOQA\nfrom typing import Dict  # NOQA\nfrom typing import Iterable  # NOQA\nfrom typing import List  # NOQA\nfrom typing import Optional  # NOQA\n\nfrom pfnopt import client as client_module\nfrom pfnopt import pruners\nfrom pfnopt import samplers\nfrom pfnopt import storages\nfrom pfnopt import trial  # NOQA\n\nObjectiveFuncType = Callable[[client_module.BaseClient], float]\n\n\nclass Study(object):\n\n    def __init__(\n            self,\n            study_uuid,  # type: str\n            storage,  # type: storages.BaseStorage\n            sampler=None,  # type: samplers.BaseSampler\n            pruner=None,  # type: pruners.BasePruner\n    ):\n        # type: (...) -> None\n\n        self.study_uuid = study_uuid\n        self.storage = storage\n        self.sampler = sampler or samplers.TPESampler()\n        self.pruner = pruner or pruners.MedianPruner()\n\n        self.study_id = storage.get_study_id_from_uuid(study_uuid)\n\n    @property\n    def best_params(self):\n        # type: () -> Dict[str, Any]\n\n        return self.best_trial.params\n\n    @property\n    def best_value(self):\n        # type: () -> float\n\n        return self.best_trial.value\n\n    @property\n    def best_trial(self):\n        # type: () -> trial.Trial\n\n        return self.storage.get_best_trial(self.study_id)\n\n    @property\n    def trials(self):\n        # type: () -> List[trial.Trial]\n\n        return self.storage.get_all_trials(self.study_id)\n\n    def run(self, func, n_trials=None, timeout_seconds=None, n_jobs=1):\n        # type: (ObjectiveFuncType, Optional[int], Optional[float], int) -> None\n\n        if n_jobs == 1:\n            self._run_sequential(func, n_trials, timeout_seconds)\n        else:\n            self._run_parallel(func, n_trials, timeout_seconds, n_jobs)\n\n    def _run_sequential(self, func, n_trials, timeout_seconds):\n        # type: (ObjectiveFuncType, Optional[int], Optional[float]) -> None\n\n        i_trial = 0\n        time_start = datetime.datetime.now()\n        while True:\n            if n_trials is not None:\n                if i_trial >= n_trials:\n                    break\n                i_trial += 1\n\n            if timeout_seconds is not None:\n                elapsed_seconds = (datetime.datetime.now() - time_start).total_seconds()\n                if elapsed_seconds >= timeout_seconds:\n                    break\n\n            trial_id = self.storage.create_new_trial_id(self.study_id)\n            client = client_module.LocalClient(self, trial_id)\n            result = func(client)\n            client.complete(result)\n\n    def _run_parallel(self, func, n_trials, timeout_seconds, n_jobs):\n        # type: (ObjectiveFuncType, Optional[int], Optional[float], int) -> None\n\n        if isinstance(self.storage, storages.RDBStorage):\n            raise TypeError('Parallel run with RDBStorage is not supported.')\n\n        if n_jobs == -1:\n            n_jobs = multiprocessing.cpu_count()\n\n        pool = multiprocessing.pool.ThreadPool(n_jobs)  # type: ignore\n\n        def f(_):\n            trial_id = self.storage.create_new_trial_id(self.study_id)\n            client = client_module.LocalClient(self, trial_id)\n            result = func(client)\n            client.complete(result)\n\n        self.start_datetime = datetime.datetime.now()\n\n        if n_trials is not None:\n            ite = range(n_trials)  # type: Iterable[int]\n        else:\n            ite = iter(int, 1)  # Infinite iterator\n\n        imap_ite = pool.imap(f, ite, chunksize=1)\n        while True:\n            if timeout_seconds is None:\n                to = None\n            else:\n                elapsed_timedelta = datetime.datetime.now() - self.start_datetime\n                elapsed_seconds = elapsed_timedelta.total_seconds()\n                to = (timeout_seconds - elapsed_seconds)\n\n            try:\n                imap_ite.next(timeout=to)  # type: ignore\n            except (StopIteration, multiprocessing.TimeoutError):  # type: ignore\n                break\n\n        pool.terminate()\n\n\ndef minimize(\n        func,  # type: ObjectiveFuncType\n        n_trials=None,  # type: Optional[int]\n        timeout_seconds=None,  # type: Optional[float]\n        n_jobs=1,  # type: int\n        storage=None,  # type: storages.BaseStorage\n        sampler=None,  # type: samplers.BaseSampler\n        pruner=None,  # type: pruners.BasePruner\n        study=None,  # type: Study\n):\n    # type: (...) -> Study\n\n    study = study or create_new_study(storage=storage, sampler=sampler, pruner=pruner)\n    study.run(func, n_trials, timeout_seconds, n_jobs)\n    return study\n\n\n# TODO(akiba): implement me\ndef maximize():\n    raise NotImplementedError\n\n\ndef create_new_study(storage, sampler=None, pruner=None):\n    # type: (storages.BaseStorage, samplers.BaseSampler, pruners.BasePruner) -> Study\n    study_uuid = storage.get_study_uuid_from_id(storage.create_new_study_id())\n    return Study(study_uuid=study_uuid, storage=storage, sampler=sampler, pruner=pruner)\n", "path": "pfnopt/study.py"}], "after_files": [{"content": "import datetime\nimport multiprocessing\nimport multiprocessing.pool\nfrom typing import Any  # NOQA\nfrom typing import Callable  # NOQA\nfrom typing import Dict  # NOQA\nfrom typing import Iterable  # NOQA\nfrom typing import List  # NOQA\nfrom typing import Optional  # NOQA\n\nfrom pfnopt import client as client_module\nfrom pfnopt import pruners\nfrom pfnopt import samplers\nfrom pfnopt import storages\nfrom pfnopt import trial  # NOQA\n\nObjectiveFuncType = Callable[[client_module.BaseClient], float]\n\n\nclass Study(object):\n\n    def __init__(\n            self,\n            study_uuid,  # type: str\n            storage,  # type: storages.BaseStorage\n            sampler=None,  # type: samplers.BaseSampler\n            pruner=None,  # type: pruners.BasePruner\n    ):\n        # type: (...) -> None\n\n        self.study_uuid = study_uuid\n        self.storage = storage\n        self.sampler = sampler or samplers.TPESampler()\n        self.pruner = pruner or pruners.MedianPruner()\n\n        self.study_id = storage.get_study_id_from_uuid(study_uuid)\n\n    @property\n    def best_params(self):\n        # type: () -> Dict[str, Any]\n\n        return self.best_trial.params\n\n    @property\n    def best_value(self):\n        # type: () -> float\n\n        return self.best_trial.value\n\n    @property\n    def best_trial(self):\n        # type: () -> trial.Trial\n\n        return self.storage.get_best_trial(self.study_id)\n\n    @property\n    def trials(self):\n        # type: () -> List[trial.Trial]\n\n        return self.storage.get_all_trials(self.study_id)\n\n    def run(self, func, n_trials=None, timeout_seconds=None, n_jobs=1):\n        # type: (ObjectiveFuncType, Optional[int], Optional[float], int) -> None\n\n        if n_jobs == 1:\n            self._run_sequential(func, n_trials, timeout_seconds)\n        else:\n            self._run_parallel(func, n_trials, timeout_seconds, n_jobs)\n\n    def _run_sequential(self, func, n_trials, timeout_seconds):\n        # type: (ObjectiveFuncType, Optional[int], Optional[float]) -> None\n\n        i_trial = 0\n        time_start = datetime.datetime.now()\n        while True:\n            if n_trials is not None:\n                if i_trial >= n_trials:\n                    break\n                i_trial += 1\n\n            if timeout_seconds is not None:\n                elapsed_seconds = (datetime.datetime.now() - time_start).total_seconds()\n                if elapsed_seconds >= timeout_seconds:\n                    break\n\n            trial_id = self.storage.create_new_trial_id(self.study_id)\n            client = client_module.LocalClient(self, trial_id)\n            result = func(client)\n            client.complete(result)\n\n    def _run_parallel(self, func, n_trials, timeout_seconds, n_jobs):\n        # type: (ObjectiveFuncType, Optional[int], Optional[float], int) -> None\n\n        if isinstance(self.storage, storages.RDBStorage):\n            raise TypeError('Parallel run with RDBStorage is not supported.')\n\n        if n_jobs == -1:\n            n_jobs = multiprocessing.cpu_count()\n\n        pool = multiprocessing.pool.ThreadPool(n_jobs)  # type: ignore\n\n        def f(_):\n            trial_id = self.storage.create_new_trial_id(self.study_id)\n            client = client_module.LocalClient(self, trial_id)\n            result = func(client)\n            client.complete(result)\n\n        self.start_datetime = datetime.datetime.now()\n\n        if n_trials is not None:\n            ite = range(n_trials)  # type: Iterable[int]\n        else:\n            ite = iter(int, 1)  # Infinite iterator\n\n        imap_ite = pool.imap(f, ite, chunksize=1)\n        while True:\n            if timeout_seconds is None:\n                to = None\n            else:\n                elapsed_timedelta = datetime.datetime.now() - self.start_datetime\n                elapsed_seconds = elapsed_timedelta.total_seconds()\n                to = (timeout_seconds - elapsed_seconds)\n\n            try:\n                imap_ite.next(timeout=to)  # type: ignore\n            except (StopIteration, multiprocessing.TimeoutError):  # type: ignore\n                break\n\n        pool.terminate()\n\n\ndef minimize(\n        func,  # type: ObjectiveFuncType\n        n_trials=None,  # type: Optional[int]\n        timeout_seconds=None,  # type: Optional[float]\n        n_jobs=1,  # type: int\n        storage=None,  # type: storages.BaseStorage\n        sampler=None,  # type: samplers.BaseSampler\n        pruner=None,  # type: pruners.BasePruner\n        study=None,  # type: Study\n):\n    # type: (...) -> Study\n    storage = storage or storages.InMemoryStorage()\n    study = study or create_new_study(storage=storage, sampler=sampler, pruner=pruner)\n    study.run(func, n_trials, timeout_seconds, n_jobs)\n    return study\n\n\n# TODO(akiba): implement me\ndef maximize():\n    raise NotImplementedError\n\n\ndef create_new_study(storage, sampler=None, pruner=None):\n    # type: (storages.BaseStorage, samplers.BaseSampler, pruners.BasePruner) -> Study\n    study_uuid = storage.get_study_uuid_from_id(storage.create_new_study_id())\n    return Study(study_uuid=study_uuid, storage=storage, sampler=sampler, pruner=pruner)\n", "path": "pfnopt/study.py"}]}