Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
feat: use iso 8601 for timestamp
Browse files- tests/test_utils.py +9 -2
- utils.py +18 -7
tests/test_utils.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import pandas as pd
|
2 |
import pytest
|
3 |
|
4 |
-
from utils import filter_models, search_table, filter_queries, select_columns, update_table_long_doc
|
5 |
|
6 |
|
7 |
@pytest.fixture
|
@@ -78,4 +78,11 @@ def test_select_columns(toy_df):
|
|
78 |
|
79 |
def test_update_table_long_doc(toy_df_long_doc):
|
80 |
df_result = update_table_long_doc(toy_df_long_doc, ['law',], ['en',], ["bge-reranker-v2-m3", ], "jina")
|
81 |
-
print(df_result)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import pandas as pd
|
2 |
import pytest
|
3 |
|
4 |
+
from utils import filter_models, search_table, filter_queries, select_columns, update_table_long_doc, get_iso_format_timestamp
|
5 |
|
6 |
|
7 |
@pytest.fixture
|
|
|
78 |
|
79 |
def test_update_table_long_doc(toy_df_long_doc):
|
80 |
df_result = update_table_long_doc(toy_df_long_doc, ['law',], ['en',], ["bge-reranker-v2-m3", ], "jina")
|
81 |
+
print(df_result)
|
82 |
+
|
83 |
+
|
84 |
+
def test_get_iso_format_timestamp():
|
85 |
+
timestamp_config, timestamp_fn = get_iso_format_timestamp()
|
86 |
+
assert len(timestamp_fn) == 14
|
87 |
+
assert len(timestamp_config) == 20
|
88 |
+
assert timestamp_config[-1] == "Z"
|
utils.py
CHANGED
@@ -1,11 +1,9 @@
|
|
1 |
import json
|
2 |
from typing import List
|
3 |
import os
|
4 |
-
from datetime import datetime
|
5 |
from pathlib import Path
|
6 |
|
7 |
-
import pytz
|
8 |
-
|
9 |
import pandas as pd
|
10 |
|
11 |
from src.benchmarks import BENCHMARK_COLS_QA, BENCHMARK_COLS_LONG_DOC, BenchmarksQA, BenchmarksLongDoc
|
@@ -150,6 +148,20 @@ def upload_file(filepath: str):
|
|
150 |
from huggingface_hub import ModelCard
|
151 |
from huggingface_hub.utils import EntryNotFoundError
|
152 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
153 |
def submit_results(filepath: str, model: str, model_url: str, version: str="AIR-Bench_24.04", anonymous=False):
|
154 |
if not filepath.endswith(".zip"):
|
155 |
return styled_error(f"file uploading aborted. wrong file type: {filepath}")
|
@@ -173,9 +185,8 @@ def submit_results(filepath: str, model: str, model_url: str, version: str="AIR-
|
|
173 |
# rename the uploaded file
|
174 |
input_fp = Path(filepath)
|
175 |
revision = input_fp.name.removesuffix(".zip")
|
176 |
-
|
177 |
-
|
178 |
-
output_fn = f"{timestamp}-{input_fp.name}"
|
179 |
input_folder_path = input_fp.parent
|
180 |
API.upload_file(
|
181 |
path_or_fileobj=filepath,
|
@@ -191,7 +202,7 @@ def submit_results(filepath: str, model: str, model_url: str, version: str="AIR-
|
|
191 |
"version": f"{version}",
|
192 |
"anonymous": f"{anonymous}",
|
193 |
"revision": f"{revision}",
|
194 |
-
"timestamp": f"{
|
195 |
}
|
196 |
with open(input_folder_path / output_config_fn, "w") as f:
|
197 |
json.dump(output_config, f, ensure_ascii=False)
|
|
|
1 |
import json
|
2 |
from typing import List
|
3 |
import os
|
4 |
+
from datetime import datetime, timezone
|
5 |
from pathlib import Path
|
6 |
|
|
|
|
|
7 |
import pandas as pd
|
8 |
|
9 |
from src.benchmarks import BENCHMARK_COLS_QA, BENCHMARK_COLS_LONG_DOC, BenchmarksQA, BenchmarksLongDoc
|
|
|
148 |
from huggingface_hub import ModelCard
|
149 |
from huggingface_hub.utils import EntryNotFoundError
|
150 |
|
151 |
+
|
152 |
+
def get_iso_format_timestamp():
|
153 |
+
# Get the current timestamp with UTC as the timezone
|
154 |
+
current_timestamp = datetime.now(timezone.utc)
|
155 |
+
|
156 |
+
# Remove milliseconds by setting microseconds to zero
|
157 |
+
current_timestamp = current_timestamp.replace(microsecond=0)
|
158 |
+
|
159 |
+
# Convert to ISO 8601 format and replace the offset with 'Z'
|
160 |
+
iso_format_timestamp = current_timestamp.isoformat().replace('+00:00', 'Z')
|
161 |
+
filename_friendly_timestamp = current_timestamp.strftime('%Y%m%d%H%M%S')
|
162 |
+
return iso_format_timestamp, filename_friendly_timestamp
|
163 |
+
|
164 |
+
|
165 |
def submit_results(filepath: str, model: str, model_url: str, version: str="AIR-Bench_24.04", anonymous=False):
|
166 |
if not filepath.endswith(".zip"):
|
167 |
return styled_error(f"file uploading aborted. wrong file type: {filepath}")
|
|
|
185 |
# rename the uploaded file
|
186 |
input_fp = Path(filepath)
|
187 |
revision = input_fp.name.removesuffix(".zip")
|
188 |
+
timestamp_config, timestamp_fn = get_iso_format_timestamp()
|
189 |
+
output_fn = f"{timestamp_fn}-{input_fp.name}"
|
|
|
190 |
input_folder_path = input_fp.parent
|
191 |
API.upload_file(
|
192 |
path_or_fileobj=filepath,
|
|
|
202 |
"version": f"{version}",
|
203 |
"anonymous": f"{anonymous}",
|
204 |
"revision": f"{revision}",
|
205 |
+
"timestamp": f"{timestamp_config}"
|
206 |
}
|
207 |
with open(input_folder_path / output_config_fn, "w") as f:
|
208 |
json.dump(output_config, f, ensure_ascii=False)
|