33
44from yarl import URL
55
6- from cratedb_toolkit .io .ingestr .boot import import_ingestr
6+ from cratedb_toolkit .io .omniload .boot import import_omniload
77from cratedb_toolkit .model import DatabaseAddress
88
99logger = logging .getLogger (__name__ )
1010
1111
1212@lru_cache (maxsize = 1 )
13- def _get_ingestr ():
13+ def _get_omniload ():
1414 """
15- Get an ingestr API handle, cached.
15+ Get an omniload API handle, cached.
1616 """
17- return import_ingestr ()
17+ return import_omniload ()
1818
1919
20- def ingestr_select (source_url : str ) -> bool :
20+ def omniload_select (source_url : str ) -> bool :
2121 """
22- Whether to select `ingestr ` for this data source.
22+ Whether to select `omniload ` for this data source.
2323 """
24- ingestr_available , ingestr , ConfigFieldMissingException = _get_ingestr ()
24+ omniload_available , omniload , ConfigFieldMissingException = _get_omniload ()
2525
26- if not ingestr_available :
27- logger .debug ("ingestr is not installed" )
26+ if not omniload_available :
27+ logger .debug ("omniload is not installed" )
2828 return False
2929 try :
30- factory = ingestr .src .factory .SourceDestinationFactory (source_url , "csv:////tmp/foobar.csv" )
30+ factory = omniload .src .factory .SourceDestinationFactory (source_url , "csv:////tmp/foobar.csv" )
3131 factory .get_source ()
32- scheme = ingestr .src .factory .parse_scheme_from_uri (source_url )
33- logger .info (f"Selecting ingestr for source scheme: { scheme } " )
32+ scheme = omniload .src .factory .parse_scheme_from_uri (source_url )
33+ logger .info (f"Selecting omniload for source scheme: { scheme } " )
3434 return True
3535 except (ImportError , ValueError , AttributeError ) as ex :
3636 if "Unsupported source scheme" in str (ex ):
37- logger .debug (f"Failed to select ingestr for source url '{ source_url } ': { ex } " )
37+ logger .debug (f"Failed to select omniload for source url '{ source_url } ': { ex } " )
3838 else :
39- logger .exception (f"Unexpected error with ingestr for source url: { source_url } " )
39+ logger .exception (f"Unexpected error with omniload for source url: { source_url } " )
4040 return False
4141 except Exception :
42- logger .exception (f"Unexpected error with ingestr for source url: { source_url } " )
42+ logger .exception (f"Unexpected error with omniload for source url: { source_url } " )
4343 return False
4444
4545
46- def ingestr_copy (source_url : str , target_address : DatabaseAddress , progress : bool = False ) -> bool :
46+ def omniload_copy (source_url : str , target_address : DatabaseAddress , progress : bool = False ) -> bool :
4747 """
48- Invoke data transfer to CrateDB from any source provided by `ingestr `.
48+ Invoke data transfer to CrateDB from any source provided by `omniload `.
4949
50- https://cratedb-toolkit.readthedocs.io/io/ingestr /
50+ https://cratedb-toolkit.readthedocs.io/io/omniload /
5151
5252 Synopsis:
5353
@@ -63,11 +63,11 @@ def ingestr_copy(source_url: str, target_address: DatabaseAddress, progress: boo
6363 "postgresql://pguser:secret11@postgresql.example.org:5432/postgres?table=public.diamonds" \
6464 "crate://crate:na@localhost:4200/testdrive/ibis_diamonds"
6565 """
66- ingestr_available , ingestr , ConfigFieldMissingException = _get_ingestr ()
66+ omniload_available , omniload , ConfigFieldMissingException = _get_omniload ()
6767
6868 # Sanity checks.
69- if not ingestr_available :
70- raise ModuleNotFoundError ("ingestr subsystem not installed" )
69+ if not omniload_available :
70+ raise ModuleNotFoundError ("omniload subsystem not installed" )
7171
7272 # Compute source and target URLs and table names.
7373 # Table names use dotted notation `<schema>.<table>`.
@@ -91,7 +91,7 @@ def ingestr_copy(source_url: str, target_address: DatabaseAddress, progress: boo
9191
9292 target_uri , target_table_address = target_address .decode ()
9393 target_table = target_table_address .fullname
94- target_url = target_address .to_ingestr_url ()
94+ target_url = target_address .to_omniload_url ()
9595
9696 if not source_table :
9797 raise ValueError ("Source table is required" )
@@ -101,7 +101,7 @@ def ingestr_copy(source_url: str, target_address: DatabaseAddress, progress: boo
101101 if source_fragment :
102102 source_table += f"#{ source_fragment } "
103103
104- logger .info ("Invoking ingestr " )
104+ logger .info ("Invoking omniload " )
105105 logger .info (f"Source URL: { source_url_obj } " )
106106 logger .info (f"Target URL: { target_url } " )
107107 logger .info (f"Source Table: { source_table } " )
@@ -114,15 +114,14 @@ def ingestr_copy(source_url: str, target_address: DatabaseAddress, progress: boo
114114 dest_uri = str (target_url ),
115115 source_table = source_table ,
116116 dest_table = target_table ,
117- yes = True ,
118117 )
119118 if start_date is not None :
120119 ingest_kwargs ["interval_start" ] = start_date
121120 if batch_size is not None :
122121 ingest_kwargs ["page_size" ] = batch_size
123122
124123 try :
125- ingestr .main .ingest (** ingest_kwargs )
124+ omniload .main .ingest (** ingest_kwargs )
126125 return True
127126 except ConfigFieldMissingException :
128127 logger .error (
0 commit comments