-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrun.py
More file actions
executable file
·69 lines (63 loc) · 2.47 KB
/
Copy pathrun.py
File metadata and controls
executable file
·69 lines (63 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# OmniEvaluator
# Copyright (c) 2026-present NAVER Cloud Corp.
#
# 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 argparse
import ast
import dotenv
import os
import sys
from omni_evaluator.args import get_parser, CustomArgumentParser
from omni_evaluator.evaluate import main as main__evaluate
from omni_evaluator.utils.io import read_file
import logging
logger = logging.getLogger(__name__)
# Load .env, skipping empty values so we never override library defaults
# (e.g. HF_ENDPOINT, TRANSFORMERS_CACHE) with "". Respects override=False semantics.
for _k, _v in dotenv.dotenv_values().items():
if (
not _v
or _k in os.environ
):
continue
os.environ[_k] = _v
# Mirror proxy env var case — some libs (requests/curl idiom) read lowercase, others uppercase.
for _upper, _lower in (("HTTP_PROXY", "http_proxy"), ("HTTPS_PROXY", "https_proxy")):
if os.environ.get(_upper) and not os.environ.get(_lower):
os.environ[_lower] = os.environ[_upper]
elif os.environ.get(_lower) and not os.environ.get(_upper):
os.environ[_upper] = os.environ[_lower]
if __name__ == "__main__":
artifact_filepath = None
for _idx, _arg in enumerate(sys.argv):
if "artifact_filepath" not in _arg:
continue
if (
_idx >= len(sys.argv) - 1
or sys.argv[_idx+1].startswith("--")
): # arg value is included in current arg
artifact_filepath = _arg.split("=")[-1].strip()
else:
# arg value is included in next arg
artifact_filepath = sys.argv[_idx+1].strip()
if artifact_filepath:
CustomArgumentParser.restore_arguments(
artifact_filepath=artifact_filepath,
)
logger.info(f'restored artifact: {artifact_filepath}')
parser = CustomArgumentParser()
parser, validations = get_parser(parser=parser)
args = parser.parse_args()
for _validation_func in validations:
args = _validation_func(args=args)
main__evaluate(args)