Skip to content

Commit 8abf168

Browse files
committed
fixed missing .csvpaths prop
1 parent 74ce7a8 commit 8abf168

4 files changed

Lines changed: 28 additions & 1 deletion

File tree

‎csvpath/managers/integrations/ol/v2/sender.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ def client(self):
3333
return self._client
3434

3535
def metadata_update(self, mdata: Metadata) -> None:
36+
if not hasattr(self, "csvpaths"):
37+
self.config.logger.warning(
38+
"No CsvPaths available. OpenLineage only works with CsvPaths instances."
39+
)
40+
return
3641
es = EventBuilder(listener=self).build(mdata)
3742
for e in es:
3843
self.client.emit(e)

‎csvpath/managers/paths/paths_registrar.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,19 @@ def update_manifest_if(self, *, group_file_path, name, paths):
6767
mdata.manifest_path = mpath
6868
mdata.fingerprint = f
6969
self.distribute_update(mdata)
70-
else:
70+
elif self.csvpaths:
7171
#
7272
# leave as info so nobody has to dig to see why no update
7373
#
7474
self.csvpaths.logger.info(
7575
"Fingerprints of named-paths %s match, as expected; no need to fire update event",
7676
name,
7777
)
78+
else:
79+
#
80+
# no logger is not helpful or expected
81+
#
82+
print("WARNING: PathsRegistrar has no CsvPaths instance")
7883

7984
def metadata_update(self, mdata: Metadata) -> None:
8085
jdata = self.get_manifest(mdata.manifest_path)

‎csvpath/managers/registrar.py‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,19 @@ def distribute_update(self, mdata: Metadata) -> None:
6666
self.csvpaths.logger.debug(
6767
"Updating listener %s with metadata %s", lst, mdata
6868
)
69+
#
70+
# this is important. is this the best place to do it?
71+
#
72+
lst.csvpaths = self.csvpaths
73+
else:
74+
if self.result and self.result.csvpath:
75+
self.result.csvpath.logger.warn("No csvpaths on Registrar")
76+
else:
77+
#
78+
# no result and no csvpath likely just means we are in a
79+
# CsvPath only context.
80+
#
81+
...
6982
try:
7083
lst.metadata_update(mdata)
7184
except Exception as ex:

‎tests/csvpaths/examples/csvpaths_examples_openlineage/test_csvpaths_examples_openlineage.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,10 @@ def test_csvpaths_openlineage_results_1(self) -> None:
190190

191191
def test_csvpaths_openlineage_result_1(self) -> None:
192192
paths = CsvPaths()
193+
194+
paths.config.set(section="listeners", name="groups", value="openlineage")
195+
paths.config.set(section="listeners", name="openlineage.version", value="2")
196+
193197
ref, mdata = paths.file_manager.add_named_file(
194198
name="orders", path=FILE, return_metadata=True
195199
)

0 commit comments

Comments
 (0)