Skip to content

Commit

Permalink
Added check if CI env vars are set.
Browse files Browse the repository at this point in the history
  • Loading branch information
popovaan committed Oct 17, 2023
1 parent 286176a commit 0d5b5df
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/utils/opt_in_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,28 @@ def _check_run_in_notebook():
pass
return False

@staticmethod
def _run_in_ci():
"""
Checks that script is executed in CI job.
:return: True script is executed in CI job, otherwise False
"""
ci_env_vars = ["CI", "TF_BUILD"]

for env_name in ci_env_vars:
if env_name in os.environ:
return True
return False

def check(self, enable_opt_in_dialog):
"""
Checks if user has accepted the collection of the information by checking the consent file.
:return: opt-in dialog result
For CI jobs always returns ConsentCheckResult.DECLINED
:return: consent check result
"""
if self._run_in_ci():
return ConsentCheckResult.DECLINED

if not os.path.exists(self.consent_file()):
if enable_opt_in_dialog:
if not self._check_main_process():
Expand Down

0 comments on commit 0d5b5df

Please sign in to comment.