Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions docs/interface.html
Original file line number Diff line number Diff line change
Expand Up @@ -905,9 +905,12 @@ <h1 class="title">Module <code>keboola.component.interface</code></h1>
Returns:

&#34;&#34;&#34;
features = os.environ.get(&#39;KBC_PROJECT_FEATURE_GATES&#39;)
features = os.environ.get(&#39;KBC_PROJECT_FEATURE_GATES&#39;, &#39;&#39;)
is_legacy_queue = True
if not features or &#39;queuev2&#39; in features:
# checking for runId which should always be present when run in the platform to determine
# if the project is running locally
# so the user does not have to set the feature gate
if &#39;queuev2&#39; in features or (not features and not os.environ.get(&#39;KBC_RUNID&#39;)):
is_legacy_queue = False
return is_legacy_queue

Expand Down Expand Up @@ -2113,9 +2116,12 @@ <h2 id="args">Args</h2>
Returns:

&#34;&#34;&#34;
features = os.environ.get(&#39;KBC_PROJECT_FEATURE_GATES&#39;)
features = os.environ.get(&#39;KBC_PROJECT_FEATURE_GATES&#39;, &#39;&#39;)
is_legacy_queue = True
if not features or &#39;queuev2&#39; in features:
# checking for runId which should always be present when run in the platform to determine
# if the project is running locally
# so the user does not have to set the feature gate
if &#39;queuev2&#39; in features or (not features and not os.environ.get(&#39;KBC_RUNID&#39;)):
is_legacy_queue = False
return is_legacy_queue

Expand Down Expand Up @@ -2445,9 +2451,12 @@ <h3>Instance variables</h3>
Returns:

&#34;&#34;&#34;
features = os.environ.get(&#39;KBC_PROJECT_FEATURE_GATES&#39;)
features = os.environ.get(&#39;KBC_PROJECT_FEATURE_GATES&#39;, &#39;&#39;)
is_legacy_queue = True
if not features or &#39;queuev2&#39; in features:
# checking for runId which should always be present when run in the platform to determine
# if the project is running locally
# so the user does not have to set the feature gate
if &#39;queuev2&#39; in features or (not features and not os.environ.get(&#39;KBC_RUNID&#39;)):
is_legacy_queue = False
return is_legacy_queue</code></pre>
</details>
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

setuptools.setup(
name="keboola.component",
version="1.4.4",
version="1.5.0",
author="Keboola KDS Team",
project_urls=project_urls,
setup_requires=['pytest-runner', 'flake8'],
Expand Down
7 changes: 5 additions & 2 deletions src/keboola/component/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -877,9 +877,12 @@ def is_legacy_queue(self) -> bool:
Returns:

"""
features = os.environ.get('KBC_PROJECT_FEATURE_GATES')
features = os.environ.get('KBC_PROJECT_FEATURE_GATES', '')
is_legacy_queue = True
if not features or 'queuev2' in features:
# checking for runId which should always be present when run in the platform to determine
# if the project is running locally
# so the user does not have to set the feature gate
if 'queuev2' in features or (not features and not os.environ.get('KBC_RUNID')):
is_legacy_queue = False
return is_legacy_queue

Expand Down
19 changes: 18 additions & 1 deletion tests/test_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ def setUp(self):
'data_examples', 'data1')
os.environ["KBC_DATADIR"] = path

# default to queue2
os.environ['KBC_PROJECT_FEATURE_GATES'] = 'queuev2'

def test_all_env_variables_initialized(self):
env_copy = os.environ.copy()
# set all variables
os.environ['KBC_RUNID'] = 'KBC_RUNID'
os.environ['KBC_PROJECTID'] = 'KBC_PROJECTID'
Expand Down Expand Up @@ -42,6 +46,9 @@ def test_all_env_variables_initialized(self):
self.assertEqual(ci.environment_variables.logger_addr, 'KBC_LOGGER_ADDR')
self.assertEqual(ci.environment_variables.logger_port, 'KBC_LOGGER_PORT')

# return back environ
os.environ = env_copy

def test_empty_required_params_pass(self):
c = CommonInterface
return True
Expand Down Expand Up @@ -110,10 +117,12 @@ def test_get_files_in_dir(self):
self.assertEqual(tables_out, ci.tables_in_path)

def test_legacy_queue(self):
env_copy = os.environ.copy()
os.environ['KBC_PROJECT_FEATURE_GATES'] = ''
os.environ['KBC_RUNID'] = '3333'
ci = CommonInterface()
# with no env default to v2
self.assertEqual(False, ci.is_legacy_queue)
self.assertEqual(True, ci.is_legacy_queue)

# otherwise check for queuev2
os.environ['KBC_PROJECT_FEATURE_GATES'] = 'queuev2;someoterfeature'
Expand All @@ -123,6 +132,14 @@ def test_legacy_queue(self):
os.environ['KBC_PROJECT_FEATURE_GATES'] = 'feature1;someoterfeature'
self.assertEqual(True, ci.is_legacy_queue)

# If run locally the env variables do not need to be set
run_id = os.environ.pop('KBC_RUNID', '')
os.environ['KBC_PROJECT_FEATURE_GATES'] = ''
self.assertEqual(False, ci.is_legacy_queue)

# reset back
os.environ = env_copy

def test_create_and_write_table_manifest_deprecated(self):
ci = CommonInterface()
# create table def
Expand Down