-
Notifications
You must be signed in to change notification settings - Fork 473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add windows machine for CI #1112
Changes from 72 commits
0543f0f
cdd6a30
d9ad62a
727ead0
5606ff0
d244536
bfbdf2d
8cac046
280dbc0
95addd7
4d4cf6c
e72d553
7bbed11
836e14f
66d908d
3c13351
51d5827
70e1f33
3b8358b
447e347
6a3d4ca
2c9b7a4
c746d0c
676f45c
ab9e05a
e1df826
57ea6e0
374aa18
ca38d78
fe32b10
2c6c5f2
8b8961d
90dee33
03a47e0
043c46e
15f8be3
34970c0
8a32735
8fbb352
990ec80
6f806e6
f0fce96
faadefe
6fd84c4
efff0a3
578b496
a9a2930
380520b
a449b87
5ee4126
6280b05
38b6985
7c055e7
6a8f200
3e0bb56
b645430
744d837
aaaafec
8a98205
0d2b82f
7100f65
3140ae0
65885ee
3ad5ce9
ba03a44
558ebbf
9f99606
7665b8b
722c50d
fa85197
06592ca
e342c79
309b559
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,8 @@ | |
) | ||
|
||
# exact same regex as in the Hub server. Please keep in sync. | ||
REGEX_YAML_BLOCK = re.compile(r"^(\s*---[\n\r]+)([\S\s]*?)([\n\r]+---([\n\r]|$))") | ||
# See https://github.com/huggingface/moon-landing/blob/main/server/lib/ViewMarkdown.ts#L18 | ||
REGEX_YAML_BLOCK = re.compile(r"^(\s*---[\r\n]+)([\S\s]*?)([\r\n]+---(\r\n|\n|$))") | ||
|
||
logger = get_logger(__name__) | ||
|
||
|
@@ -127,7 +128,9 @@ def save(self, filepath: Union[Path, str]): | |
""" | ||
filepath = Path(filepath) | ||
filepath.parent.mkdir(parents=True, exist_ok=True) | ||
filepath.write_text(str(self), encoding="utf-8") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting, this didn't work as expected on Windows? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was "working" but encoding a newline was different on Windows ( (And yes, I discovered/learnt about all this while working on this PR :D) |
||
# Preserve newlines as in the existing file. | ||
with open(filepath, mode="w", newline="", encoding="utf-8") as f: | ||
f.write(str(self)) | ||
|
||
@classmethod | ||
def load( | ||
|
@@ -516,11 +519,11 @@ def metadata_save(local_path: Union[str, Path], data: Dict) -> None: | |
# try to detect existing newline character | ||
if os.path.exists(local_path): | ||
with open(local_path, "r", newline="") as readme: | ||
if type(readme.newlines) is tuple: | ||
content = readme.read() | ||
if isinstance(readme.newlines, tuple): | ||
line_break = readme.newlines[0] | ||
if type(readme.newlines) is str: | ||
elif isinstance(readme.newlines, str): | ||
line_break = readme.newlines | ||
content = readme.read() | ||
|
||
# creates a new file if it not | ||
with open(local_path, "w", newline="") as readme: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe mention here that if this isn't activated, it will still work, just in a non-optimized manner
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea !