Skip to content

Commit

Permalink
fix license_check transform
Browse files Browse the repository at this point in the history
Signed-off-by: Shivdeep Singh <[email protected]>
  • Loading branch information
shivdeep-singh-ibm committed Jun 20, 2024
1 parent 03301d1 commit 2758803
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 20 deletions.
16 changes: 8 additions & 8 deletions transforms/code/license_check/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ image::
@# Help: Recursively make $@ in all subdirs
@$(MAKE) RULE=$@ .recurse

set-versions:
@# Help: Recursively $@ in all subdirs
@$(MAKE) RULE=$@ .recurse

publish::
@# Help: Recursively make $@ in all subdirs
@$(MAKE) RULE=$@ .recurse
Expand All @@ -43,21 +47,17 @@ load-image::

.PHONY: workflow-venv
workflow-venv:
$(MAKE) -C kfp_ray/v1 workflow-venv
$(MAKE) -C kfp_ray workflow-venv

.PHONY: workflow-build
workflow-build:
$(MAKE) -C kfp_ray/v1 workflow-build
$(MAKE) -C kfp_ray workflow-build

.PHONY: workflow-test
workflow-test:
$(MAKE) -C kfp_ray/v1 workflow-test
$(MAKE) -C kfp_ray workflow-test

.PHONY: workflow-upload
workflow-upload:
$(MAKE) -C kfp_ray/v1 workflow-upload

.PHONY: workflow-reconcile-requirements
workflow-reconcile-requirements:
$(MAKE) -C kfp_ray/v1 workflow-reconcile-requirements
$(MAKE) -C kfp_ray workflow-upload

Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
transform = LicenseCheckTransform(license_check_params)

data_access = DataAccessLocal()
table = data_access.get_table(os.path.join(input_folder, "sample_1.parquet"))
table, _ = data_access.get_table(os.path.join(input_folder, "sample_1.parquet"))
print(f"input table: {table}")
# Transform the table
table_list, metadata = transform.transform(table)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ def _get_supported_licenses(license_file: str, data_access: DataAccess) -> list[
licenses_list = json.loads(licenses_list_json.decode("utf-8"))
logger.info(f"Read a list of {len(licenses_list)} licenses.")
except Exception as e:
logger.error(f"got and exception {e}")
logger.error(f"Failed to read file: {license_file} due to {e}")
return licenses_list


class LicenseCheckTransform(AbstractTableTransform):
""" """
"""It can be used to select the rows/records of data with licenses
matching those in the approved/deny list.
"""

def __init__(self, config: dict):
super().__init__(config)
Expand All @@ -66,13 +68,10 @@ def __init__(self, config: dict):
)

def transform(self, table: pa.Table, file_name: str = None) -> tuple[list[pa.Table], dict]:
""" """
if type(table) is tuple:
logger.info(f"We got a tuple. Extract table from tuple, if possible.")
extracted_table, _ = table
if type(extracted_table) is pa.Table:
table = extracted_table

"""
Transforms input tables by adding a boolean `license_status` column
indicating whether the license is approved/denied.
"""
if not TransformUtils.validate_columns(table, [self.license_check["license_column_name"]]):
return [], {}
new_table = self.transformer.transform(table)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,11 @@
"result_doc_count": 4
},
"source": {
"name": "/Users/shivdeep/workspace/projects/current/oss-data-prep/data-prep-lab/transforms/code/license_check/python/test-data/input",
"name": "data-prep-kit/transforms/code/license_check/python/test-data/input",
"type": "path"
},
"target": {
"name": "/Users/shivdeep/workspace/projects/current/oss-data-prep/data-prep-lab/transforms/code/license_check/python/test-data/output",
"name": "data-prep-kit/transforms/code/license_check/python/test-data/output",
"type": "path"
}
}

0 comments on commit 2758803

Please sign in to comment.