Skip to content

Commit 06910e4

Browse files
[io] Reraise error when writer specific library not found
1 parent e7bbace commit 06910e4

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

libs/garf_io/garf_io/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
__version__ = '0.0.3'
15+
__version__ = '0.0.4'

libs/garf_io/garf_io/writer.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,15 @@ def create_writer(
3535
to correctly instantiate it.
3636
3737
Args:
38-
writer_option: Type of writer.
39-
kwargs: Any possible arguments needed o instantiate writer.
38+
writer_option: Type of writer.
39+
kwargs: Any possible arguments needed o instantiate writer.
4040
4141
Returns:
42-
Concrete instantiated writer.
42+
Concrete instantiated writer.
43+
44+
Raises:
45+
ImportError: When writer specific library is not installed.
46+
GarfIoError: When incorrect writer option is specified.
4347
"""
4448
writers = entry_points(group='garf_writer')
4549
found_writers = {}
@@ -51,6 +55,10 @@ def create_writer(
5155
found_writers[writer.name] = getattr(writer_module, name)
5256
except ModuleNotFoundError:
5357
continue
58+
except ImportError as e:
59+
if writer_option == writer.name:
60+
raise e
61+
continue
5462
if concrete_writer := found_writers.get(writer_option):
5563
return concrete_writer(**kwargs)
5664
raise GarfIoWriterError(f'{writer_option} is unknown writer type!')

0 commit comments

Comments
 (0)