-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Localhost] Create localhost config file
- Loading branch information
1 parent
5636f53
commit d89a82a
Showing
6 changed files
with
78 additions
and
43 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
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,52 @@ | ||
# | ||
# 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. | ||
# | ||
|
||
import os | ||
import re | ||
import sys | ||
|
||
|
||
DEFAULT_CONFIG_KEYS = { | ||
'runtime': os.path.basename(sys.executable), | ||
'worker_processes': os.cpu_count(), | ||
} | ||
|
||
LOCALHOST_EXECUTION_TIMEOUT = 3600 | ||
|
||
|
||
def load_config(config_data): | ||
|
||
if 'localhost' not in config_data or not config_data['localhost']: | ||
config_data['localhost'] = {} | ||
|
||
for key in DEFAULT_CONFIG_KEYS: | ||
if key not in config_data['localhost']: | ||
config_data['localhost'][key] = DEFAULT_CONFIG_KEYS[key] | ||
|
||
config_data['localhost']['max_workers'] = 1 | ||
|
||
if 'execution_timeout' not in config_data['lithops']: | ||
config_data['lithops']['execution_timeout'] = LOCALHOST_EXECUTION_TIMEOUT | ||
|
||
if 'storage' not in config_data['lithops']: | ||
config_data['lithops']['storage'] = 'localhost' | ||
|
||
windows_path_pattern = re.compile(r'^[A-Za-z]:\\.*$') | ||
runtime_name = config_data['localhost']['runtime'] | ||
|
||
if runtime_name.startswith(('python', '/')) \ | ||
or windows_path_pattern.match(runtime_name) is not None: | ||
config_data['localhost']['environment'] = 'default' | ||
else: | ||
config_data['localhost']['environment'] = 'container' |
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