Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
text-generation-inference
Commits
3c02262f
Commit
3c02262f
authored
Nov 23, 2023
by
Nicolas Patry
Browse files
Reduce race condition on file system for test
parent
c6bb7670
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
2 deletions
+9
-2
router/src/lib.rs
router/src/lib.rs
+9
-2
No files found.
router/src/lib.rs
View file @
3c02262f
...
@@ -300,15 +300,22 @@ mod tests {
...
@@ -300,15 +300,22 @@ mod tests {
use
tokenizers
::
Tokenizer
;
use
tokenizers
::
Tokenizer
;
pub
(
crate
)
async
fn
get_tokenizer
()
->
Tokenizer
{
pub
(
crate
)
async
fn
get_tokenizer
()
->
Tokenizer
{
if
!
std
::
path
::
Path
::
new
(
"tokenizer.json"
)
.exists
()
{
let
filename
=
std
::
path
::
Path
::
new
(
"tokenizer.json"
);
if
!
filename
.exists
()
{
let
content
=
reqwest
::
get
(
"https://huggingface.co/gpt2/raw/main/tokenizer.json"
)
let
content
=
reqwest
::
get
(
"https://huggingface.co/gpt2/raw/main/tokenizer.json"
)
.await
.await
.unwrap
()
.unwrap
()
.bytes
()
.bytes
()
.await
.await
.unwrap
();
.unwrap
();
let
mut
file
=
std
::
fs
::
File
::
create
(
"tokenizer.json"
)
.unwrap
();
let
tmp_filename
=
"tokenizer.json.temp"
;
let
mut
file
=
std
::
fs
::
File
::
create
(
tmp_filename
)
.unwrap
();
file
.write_all
(
&
content
)
.unwrap
();
file
.write_all
(
&
content
)
.unwrap
();
// Re-check if another process has written this file maybe.
if
!
filename
.exists
()
{
std
::
fs
::
rename
(
tmp_filename
,
filename
)
.unwrap
()
}
}
}
Tokenizer
::
from_file
(
"tokenizer.json"
)
.unwrap
()
Tokenizer
::
from_file
(
"tokenizer.json"
)
.unwrap
()
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment