Skip to content

Commit bec13f2

Browse files
committed
sync action for the run method
1 parent bffbed8 commit bec13f2

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/component.py

+14-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from os import mkdir, path
99

1010
from keboola.component.base import ComponentBase, sync_action
11-
from keboola.component.dao import SupportedDataTypes, BaseType, ColumnDefinition
11+
from keboola.component.dao import BaseType, ColumnDefinition, SupportedDataTypes
1212
from keboola.component.exceptions import UserException
1313
from keboola.component.sync_actions import MessageType, SelectElement, ValidationResult
1414
from keboola.utils.header_normalizer import NormalizerStrategy, get_normalizer
@@ -86,7 +86,7 @@ class Component(ComponentBase):
8686
def __init__(self):
8787
super().__init__()
8888

89-
def run(self):
89+
def run(self, return_data=False):
9090
self.validate_configuration_parameters(REQUIRED_PARAMETERS)
9191
self.validate_image_parameters(REQUIRED_IMAGE_PARS)
9292

@@ -130,6 +130,9 @@ def run(self):
130130
logging.debug([result for result in results])
131131
logging.info(f"Downloaded {total_records} records in total")
132132

133+
if return_data:
134+
return results
135+
133136
# remove headers and get columns
134137
output_columns = self._fix_header_from_csv(results)
135138
output_columns = self.normalize_column_names(output_columns)
@@ -419,9 +422,9 @@ def _get_login_method(self) -> LoginType:
419422
@staticmethod
420423
def process_salesforce_domain(url):
421424
if url.startswith("http://"):
422-
url = url[len("http://"):]
425+
url = url[len("http://") :]
423426
if url.startswith("https://"):
424-
url = url[len("https://"):]
427+
url = url[len("https://") :]
425428
if url.endswith(".salesforce.com"):
426429
url = url[: -len(".salesforce.com")]
427430

@@ -619,6 +622,13 @@ def load_possible_primary_keys(self) -> list[SelectElement]:
619622
else:
620623
raise UserException(f"Invalid {KEY_QUERY_TYPE}")
621624

625+
# @sync_action("runComponent")
626+
# def sync_run_component(self):
627+
# """
628+
# Run the component as a sync action
629+
# """
630+
# return self.run(return_data=True)
631+
622632
def _get_object_name_from_custom_query(self) -> str:
623633
params = self.configuration.parameters
624634
salesforce_client = self.get_salesforce_client(params)

0 commit comments

Comments
 (0)