Dispatch resolver based on type of source. Args: source: Different data sources Raises: RuntimeError: If the source is a not supported type.
(self, source)
| 165 | return self.__str__() |
| 166 | |
| 167 | def resolve(self, source): |
| 168 | """Dispatch resolver based on type of source. |
| 169 | |
| 170 | Args: |
| 171 | source: Different data sources |
| 172 | |
| 173 | Raises: |
| 174 | RuntimeError: If the source is a not supported type. |
| 175 | """ |
| 176 | if isinstance(source, str): |
| 177 | self.process_location(source) |
| 178 | elif isinstance(source, pathlib.Path): |
| 179 | self.process_location(str(source)) |
| 180 | elif isinstance(source, pd.DataFrame): |
| 181 | self.process_pandas(source) |
| 182 | elif vineyard is not None and isinstance( |
| 183 | source, (vineyard.Object, vineyard.ObjectID, vineyard.ObjectName) |
| 184 | ): |
| 185 | self.process_vy_object(source) |
| 186 | elif isinstance(source, Sequence): |
| 187 | # Assume a list of numpy array are passed as COO matrix, with length >= 2. |
| 188 | # Formats: [src_id, dst_id, prop_1, ..., prop_n] |
| 189 | check_argument(all([isinstance(item, np.ndarray) for item in source])) |
| 190 | self.process_numpy(source) |
| 191 | else: |
| 192 | raise RuntimeError("Not support source", source) |
| 193 | |
| 194 | def process_location(self, source): |
| 195 | self.protocol = urlparse(source).scheme |
no test coverage detected