-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix infinite recursion on lazy_api_imports
PiperOrigin-RevId: 697989132
- Loading branch information
1 parent
c65a09d
commit 8a5685a
Showing
5 changed files
with
91 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Copyright 2024 The etils Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
"""XManager utils.""" | ||
|
||
# pylint: disable=g-importing-member | ||
|
||
from etils.exm.dummy import current_experiment | ||
from etils.exm.dummy import current_work_unit | ||
from etils.exm.dummy import is_running_under_xmanager | ||
from etils.exm.dummy import add_experiment_artifact | ||
from etils.exm.dummy import add_work_unit_artifact | ||
from etils.exm.dummy import curr_job_name | ||
from etils.exm.dummy import url_to_python_only_logs | ||
from etils.exm.dummy import set_citc_source |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Copyright 2024 The etils Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
"""Dummy implementation of the `exm` API to simplify open-sourcing.""" | ||
|
||
import functools | ||
from typing import TypeVar | ||
|
||
_T = TypeVar('_T') | ||
|
||
|
||
def _noop(*args, return_value: _T, **kwargs) -> _T: | ||
del args, kwargs | ||
return return_value | ||
|
||
|
||
def _error(*args, **kwargs): | ||
del args, kwargs | ||
raise NotImplementedError('This `exm` function does not work in open-source.') | ||
|
||
|
||
current_experiment = _error | ||
current_work_unit = _error | ||
is_running_under_xmanager = functools.partial(_noop, return_value=False) | ||
add_experiment_artifact = functools.partial(_noop, return_value=None) | ||
add_work_unit_artifact = functools.partial(_noop, return_value=None) | ||
curr_job_name = functools.partial(_noop, return_value='<unknown job name>') | ||
url_to_python_only_logs = functools.partial( | ||
_noop, return_value='<unknown log url>' | ||
) | ||
set_citc_source = functools.partial(_noop, return_value=None) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters