-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update local cli executor to use same filename strategy as docker (#1981
) * consistent file saving across cli executors * test fixes * feedback * make path * formatting * run timeout test on windows --------- Co-authored-by: Chi Wang <wang.chi@microsoft.com>
- Loading branch information
1 parent
a814ba5
commit d583c80
Showing
5 changed files
with
114 additions
and
87 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,22 @@ | ||
# Will return the filename relative to the workspace path | ||
from pathlib import Path | ||
from typing import Optional | ||
|
||
|
||
# Raises ValueError if the file is not in the workspace | ||
def _get_file_name_from_content(code: str, workspace_path: Path) -> Optional[str]: | ||
first_line = code.split("\n")[0] | ||
# TODO - support other languages | ||
if first_line.startswith("# filename:"): | ||
filename = first_line.split(":")[1].strip() | ||
|
||
# Handle relative paths in the filename | ||
path = Path(filename) | ||
if not path.is_absolute(): | ||
path = workspace_path / path | ||
path = path.resolve() | ||
# Throws an error if the file is not in the workspace | ||
relative = path.relative_to(workspace_path.resolve()) | ||
return str(relative) | ||
|
||
return None |
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