We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Avoid error when working with subtypes for SemanticSegmentationRasterSource
Here: https://github.com/azavea/raster-vision/blob/f6ea64a37fd4d09375da1838cd679e6cbce5b35b/rastervision/data/label_source/semantic_segmentation_raster_source_config.py#L123

We check for the type explicitly. We should use `isinstance` instead to allow for subclasses to pass this check - or figure out a more general way of not having other types and allowing them to bypass having to set the rgb class map.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `rastervision/data/label_source/semantic_segmentation_raster_source_config.py`
Content:
```
1 from copy import deepcopy
2 
3 import rastervision as rv
4 from rastervision.core.class_map import ClassMap
5 from rastervision.data.label_source import (LabelSourceConfig,
6                                             LabelSourceConfigBuilder,
7                                             SemanticSegmentationRasterSource)
8 from rastervision.protos.label_source_pb2 import LabelSourceConfig as LabelSourceConfigMsg
9 from rastervision.data.raster_source import RasterSourceConfig, GeoJSONSourceConfig
10 
11 
12 class SemanticSegmentationRasterSourceConfig(LabelSourceConfig):
13     def __init__(self, source, rgb_class_map=None):
14         super().__init__(source_type=rv.SEMANTIC_SEGMENTATION_RASTER)
15         self.source = source
16         self.rgb_class_map = rgb_class_map
17 
18     def to_proto(self):
19         msg = super().to_proto()
20 
21         rgb_class_items = None
22         if self.rgb_class_map is not None:
23             rgb_class_items = self.rgb_class_map.to_proto()
24         opts = LabelSourceConfigMsg.SemanticSegmentationRasterSource(
25             source=self.source.to_proto(), rgb_class_items=rgb_class_items)
26         msg.semantic_segmentation_raster_source.CopyFrom(opts)
27         return msg
28 
29     def create_source(self, task_config, extent, crs_transformer, tmp_dir):
30         return SemanticSegmentationRasterSource(
31             self.source.create_source(tmp_dir, extent, crs_transformer),
32             self.rgb_class_map)
33 
34     def update_for_command(self, command_type, experiment_config, context=[]):
35         if context is None:
36             context = []
37         context = context + [self]
38         io_def = rv.core.CommandIODefinition()
39 
40         b = self.to_builder()
41 
42         (new_raster_source, sub_io_def) = self.source.update_for_command(
43             command_type, experiment_config, context)
44 
45         io_def.merge(sub_io_def)
46         b = b.with_raster_source(new_raster_source)
47 
48         return (b.build(), io_def)
49 
50 
51 class SemanticSegmentationRasterSourceConfigBuilder(LabelSourceConfigBuilder):
52     def __init__(self, prev=None):
53         config = {}
54         if prev:
55             config = {
56                 'source': prev.source,
57                 'rgb_class_map': prev.rgb_class_map
58             }
59 
60         super().__init__(SemanticSegmentationRasterSourceConfig, config)
61 
62     def from_proto(self, msg):
63         b = SemanticSegmentationRasterSourceConfigBuilder()
64 
65         raster_source_config = rv.RasterSourceConfig.from_proto(
66             msg.semantic_segmentation_raster_source.source)
67 
68         b = b.with_raster_source(raster_source_config)
69         rgb_class_items = msg.semantic_segmentation_raster_source.rgb_class_items
70         if rgb_class_items:
71             b = b.with_rgb_class_map(
72                 ClassMap.construct_from(list(rgb_class_items)))
73 
74         return b
75 
76     def with_raster_source(self, source, channel_order=None):
77         """Set raster_source.
78 
79         Args:
80             source: (RasterSourceConfig) A RasterSource assumed to have RGB values that
81                 are mapped to class_ids using the rgb_class_map.
82 
83         Returns:
84             SemanticSegmentationRasterSourceConfigBuilder
85         """
86         b = deepcopy(self)
87         if isinstance(source, RasterSourceConfig):
88             b.config['source'] = source
89         elif isinstance(source, str):
90             provider = rv._registry.get_raster_source_default_provider(source)
91             source = provider.construct(source, channel_order=channel_order)
92             b.config['source'] = source
93         else:
94             raise rv.ConfigError(
95                 'source must be either string or RasterSourceConfig, '
96                 ' not {}'.format(str(type(source))))
97 
98         return b
99 
100     def with_rgb_class_map(self, rgb_class_map):
101         """Set rgb_class_map.
102 
103         Args:
104             rgb_class_map: (something accepted by ClassMap.construct_from) a class
105                 map with color values used to map RGB values to class ids
106 
107         Returns:
108             SemanticSegmentationRasterSourceConfigBuilder
109         """
110         b = deepcopy(self)
111         b.config['rgb_class_map'] = ClassMap.construct_from(rgb_class_map)
112         return b
113 
114     def validate(self):
115         source = self.config.get('source')
116         rgb_class_map = self.config.get('rgb_class_map')
117 
118         if source is None:
119             raise rv.ConfigError(
120                 'You must set the source for SemanticSegmentationRasterSourceConfig'
121                 ' Use "with_raster_source".')
122 
123         if type(source) != GeoJSONSourceConfig and rgb_class_map is None:
124             raise rv.ConfigError(
125                 'You must set the rgb_class_map for '
126                 'SemanticSegmentationRasterSourceConfig. Use "with_rgb_class_map".'
127             )
128
```
--- 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/rastervision/data/label_source/semantic_segmentation_raster_source_config.py b/rastervision/data/label_source/semantic_segmentation_raster_source_config.py
--- a/rastervision/data/label_source/semantic_segmentation_raster_source_config.py
+++ b/rastervision/data/label_source/semantic_segmentation_raster_source_config.py
@@ -6,7 +6,7 @@
                                             LabelSourceConfigBuilder,
                                             SemanticSegmentationRasterSource)
 from rastervision.protos.label_source_pb2 import LabelSourceConfig as LabelSourceConfigMsg
-from rastervision.data.raster_source import RasterSourceConfig, GeoJSONSourceConfig
+from rastervision.data.raster_source import RasterSourceConfig
 
 
 class SemanticSegmentationRasterSourceConfig(LabelSourceConfig):
@@ -113,15 +113,8 @@
 
     def validate(self):
         source = self.config.get('source')
-        rgb_class_map = self.config.get('rgb_class_map')
 
         if source is None:
             raise rv.ConfigError(
                 'You must set the source for SemanticSegmentationRasterSourceConfig'
                 ' Use "with_raster_source".')
-
-        if type(source) != GeoJSONSourceConfig and rgb_class_map is None:
-            raise rv.ConfigError(
-                'You must set the rgb_class_map for '
-                'SemanticSegmentationRasterSourceConfig. Use "with_rgb_class_map".'
-            )

{"golden_diff": "diff --git a/rastervision/data/label_source/semantic_segmentation_raster_source_config.py b/rastervision/data/label_source/semantic_segmentation_raster_source_config.py\n--- a/rastervision/data/label_source/semantic_segmentation_raster_source_config.py\n+++ b/rastervision/data/label_source/semantic_segmentation_raster_source_config.py\n@@ -6,7 +6,7 @@\n                                             LabelSourceConfigBuilder,\n                                             SemanticSegmentationRasterSource)\n from rastervision.protos.label_source_pb2 import LabelSourceConfig as LabelSourceConfigMsg\n-from rastervision.data.raster_source import RasterSourceConfig, GeoJSONSourceConfig\n+from rastervision.data.raster_source import RasterSourceConfig\n \n \n class SemanticSegmentationRasterSourceConfig(LabelSourceConfig):\n@@ -113,15 +113,8 @@\n \n     def validate(self):\n         source = self.config.get('source')\n-        rgb_class_map = self.config.get('rgb_class_map')\n \n         if source is None:\n             raise rv.ConfigError(\n                 'You must set the source for SemanticSegmentationRasterSourceConfig'\n                 ' Use \"with_raster_source\".')\n-\n-        if type(source) != GeoJSONSourceConfig and rgb_class_map is None:\n-            raise rv.ConfigError(\n-                'You must set the rgb_class_map for '\n-                'SemanticSegmentationRasterSourceConfig. Use \"with_rgb_class_map\".'\n-            )\n", "issue": "Avoid error when working with subtypes for SemanticSegmentationRasterSource\nHere: https://github.com/azavea/raster-vision/blob/f6ea64a37fd4d09375da1838cd679e6cbce5b35b/rastervision/data/label_source/semantic_segmentation_raster_source_config.py#L123\r\n\r\nWe check for the type explicitly. We should use `isinstance` instead to allow for subclasses to pass this check - or figure out a more general way of not having other types and allowing them to bypass having to set the rgb class map.\n", "before_files": [{"content": "from copy import deepcopy\n\nimport rastervision as rv\nfrom rastervision.core.class_map import ClassMap\nfrom rastervision.data.label_source import (LabelSourceConfig,\n                                            LabelSourceConfigBuilder,\n                                            SemanticSegmentationRasterSource)\nfrom rastervision.protos.label_source_pb2 import LabelSourceConfig as LabelSourceConfigMsg\nfrom rastervision.data.raster_source import RasterSourceConfig, GeoJSONSourceConfig\n\n\nclass SemanticSegmentationRasterSourceConfig(LabelSourceConfig):\n    def __init__(self, source, rgb_class_map=None):\n        super().__init__(source_type=rv.SEMANTIC_SEGMENTATION_RASTER)\n        self.source = source\n        self.rgb_class_map = rgb_class_map\n\n    def to_proto(self):\n        msg = super().to_proto()\n\n        rgb_class_items = None\n        if self.rgb_class_map is not None:\n            rgb_class_items = self.rgb_class_map.to_proto()\n        opts = LabelSourceConfigMsg.SemanticSegmentationRasterSource(\n            source=self.source.to_proto(), rgb_class_items=rgb_class_items)\n        msg.semantic_segmentation_raster_source.CopyFrom(opts)\n        return msg\n\n    def create_source(self, task_config, extent, crs_transformer, tmp_dir):\n        return SemanticSegmentationRasterSource(\n            self.source.create_source(tmp_dir, extent, crs_transformer),\n            self.rgb_class_map)\n\n    def update_for_command(self, command_type, experiment_config, context=[]):\n        if context is None:\n            context = []\n        context = context + [self]\n        io_def = rv.core.CommandIODefinition()\n\n        b = self.to_builder()\n\n        (new_raster_source, sub_io_def) = self.source.update_for_command(\n            command_type, experiment_config, context)\n\n        io_def.merge(sub_io_def)\n        b = b.with_raster_source(new_raster_source)\n\n        return (b.build(), io_def)\n\n\nclass SemanticSegmentationRasterSourceConfigBuilder(LabelSourceConfigBuilder):\n    def __init__(self, prev=None):\n        config = {}\n        if prev:\n            config = {\n                'source': prev.source,\n                'rgb_class_map': prev.rgb_class_map\n            }\n\n        super().__init__(SemanticSegmentationRasterSourceConfig, config)\n\n    def from_proto(self, msg):\n        b = SemanticSegmentationRasterSourceConfigBuilder()\n\n        raster_source_config = rv.RasterSourceConfig.from_proto(\n            msg.semantic_segmentation_raster_source.source)\n\n        b = b.with_raster_source(raster_source_config)\n        rgb_class_items = msg.semantic_segmentation_raster_source.rgb_class_items\n        if rgb_class_items:\n            b = b.with_rgb_class_map(\n                ClassMap.construct_from(list(rgb_class_items)))\n\n        return b\n\n    def with_raster_source(self, source, channel_order=None):\n        \"\"\"Set raster_source.\n\n        Args:\n            source: (RasterSourceConfig) A RasterSource assumed to have RGB values that\n                are mapped to class_ids using the rgb_class_map.\n\n        Returns:\n            SemanticSegmentationRasterSourceConfigBuilder\n        \"\"\"\n        b = deepcopy(self)\n        if isinstance(source, RasterSourceConfig):\n            b.config['source'] = source\n        elif isinstance(source, str):\n            provider = rv._registry.get_raster_source_default_provider(source)\n            source = provider.construct(source, channel_order=channel_order)\n            b.config['source'] = source\n        else:\n            raise rv.ConfigError(\n                'source must be either string or RasterSourceConfig, '\n                ' not {}'.format(str(type(source))))\n\n        return b\n\n    def with_rgb_class_map(self, rgb_class_map):\n        \"\"\"Set rgb_class_map.\n\n        Args:\n            rgb_class_map: (something accepted by ClassMap.construct_from) a class\n                map with color values used to map RGB values to class ids\n\n        Returns:\n            SemanticSegmentationRasterSourceConfigBuilder\n        \"\"\"\n        b = deepcopy(self)\n        b.config['rgb_class_map'] = ClassMap.construct_from(rgb_class_map)\n        return b\n\n    def validate(self):\n        source = self.config.get('source')\n        rgb_class_map = self.config.get('rgb_class_map')\n\n        if source is None:\n            raise rv.ConfigError(\n                'You must set the source for SemanticSegmentationRasterSourceConfig'\n                ' Use \"with_raster_source\".')\n\n        if type(source) != GeoJSONSourceConfig and rgb_class_map is None:\n            raise rv.ConfigError(\n                'You must set the rgb_class_map for '\n                'SemanticSegmentationRasterSourceConfig. Use \"with_rgb_class_map\".'\n            )\n", "path": "rastervision/data/label_source/semantic_segmentation_raster_source_config.py"}], "after_files": [{"content": "from copy import deepcopy\n\nimport rastervision as rv\nfrom rastervision.core.class_map import ClassMap\nfrom rastervision.data.label_source import (LabelSourceConfig,\n                                            LabelSourceConfigBuilder,\n                                            SemanticSegmentationRasterSource)\nfrom rastervision.protos.label_source_pb2 import LabelSourceConfig as LabelSourceConfigMsg\nfrom rastervision.data.raster_source import RasterSourceConfig\n\n\nclass SemanticSegmentationRasterSourceConfig(LabelSourceConfig):\n    def __init__(self, source, rgb_class_map=None):\n        super().__init__(source_type=rv.SEMANTIC_SEGMENTATION_RASTER)\n        self.source = source\n        self.rgb_class_map = rgb_class_map\n\n    def to_proto(self):\n        msg = super().to_proto()\n\n        rgb_class_items = None\n        if self.rgb_class_map is not None:\n            rgb_class_items = self.rgb_class_map.to_proto()\n        opts = LabelSourceConfigMsg.SemanticSegmentationRasterSource(\n            source=self.source.to_proto(), rgb_class_items=rgb_class_items)\n        msg.semantic_segmentation_raster_source.CopyFrom(opts)\n        return msg\n\n    def create_source(self, task_config, extent, crs_transformer, tmp_dir):\n        return SemanticSegmentationRasterSource(\n            self.source.create_source(tmp_dir, extent, crs_transformer),\n            self.rgb_class_map)\n\n    def update_for_command(self, command_type, experiment_config, context=[]):\n        if context is None:\n            context = []\n        context = context + [self]\n        io_def = rv.core.CommandIODefinition()\n\n        b = self.to_builder()\n\n        (new_raster_source, sub_io_def) = self.source.update_for_command(\n            command_type, experiment_config, context)\n\n        io_def.merge(sub_io_def)\n        b = b.with_raster_source(new_raster_source)\n\n        return (b.build(), io_def)\n\n\nclass SemanticSegmentationRasterSourceConfigBuilder(LabelSourceConfigBuilder):\n    def __init__(self, prev=None):\n        config = {}\n        if prev:\n            config = {\n                'source': prev.source,\n                'rgb_class_map': prev.rgb_class_map\n            }\n\n        super().__init__(SemanticSegmentationRasterSourceConfig, config)\n\n    def from_proto(self, msg):\n        b = SemanticSegmentationRasterSourceConfigBuilder()\n\n        raster_source_config = rv.RasterSourceConfig.from_proto(\n            msg.semantic_segmentation_raster_source.source)\n\n        b = b.with_raster_source(raster_source_config)\n        rgb_class_items = msg.semantic_segmentation_raster_source.rgb_class_items\n        if rgb_class_items:\n            b = b.with_rgb_class_map(\n                ClassMap.construct_from(list(rgb_class_items)))\n\n        return b\n\n    def with_raster_source(self, source, channel_order=None):\n        \"\"\"Set raster_source.\n\n        Args:\n            source: (RasterSourceConfig) A RasterSource assumed to have RGB values that\n                are mapped to class_ids using the rgb_class_map.\n\n        Returns:\n            SemanticSegmentationRasterSourceConfigBuilder\n        \"\"\"\n        b = deepcopy(self)\n        if isinstance(source, RasterSourceConfig):\n            b.config['source'] = source\n        elif isinstance(source, str):\n            provider = rv._registry.get_raster_source_default_provider(source)\n            source = provider.construct(source, channel_order=channel_order)\n            b.config['source'] = source\n        else:\n            raise rv.ConfigError(\n                'source must be either string or RasterSourceConfig, '\n                ' not {}'.format(str(type(source))))\n\n        return b\n\n    def with_rgb_class_map(self, rgb_class_map):\n        \"\"\"Set rgb_class_map.\n\n        Args:\n            rgb_class_map: (something accepted by ClassMap.construct_from) a class\n                map with color values used to map RGB values to class ids\n\n        Returns:\n            SemanticSegmentationRasterSourceConfigBuilder\n        \"\"\"\n        b = deepcopy(self)\n        b.config['rgb_class_map'] = ClassMap.construct_from(rgb_class_map)\n        return b\n\n    def validate(self):\n        source = self.config.get('source')\n\n        if source is None:\n            raise rv.ConfigError(\n                'You must set the source for SemanticSegmentationRasterSourceConfig'\n                ' Use \"with_raster_source\".')\n", "path": "rastervision/data/label_source/semantic_segmentation_raster_source_config.py"}]}