forked from dptech-corp/dpgen2
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support specifying URI of init_data, multi_init_data, valid_data, ini…
…t_model (#227) …t_models <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced new arguments for handling model and data URIs to enhance data management capabilities. - Added functions for fetching and uploading artifacts, improving workflow efficiency. - **Refactor** - Refactored data handling logic to support concurrent learning workflows and better manage input data structures. - **Documentation** - Updated documentation for new arguments and functions to guide users on their usage. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: zjgemi <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
d3f52d8
commit ff2aed7
Showing
5 changed files
with
120 additions
and
52 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
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,23 @@ | ||
from dflow import ( | ||
S3Artifact, | ||
s3_config, | ||
upload_artifact, | ||
) | ||
|
||
|
||
def get_artifact_from_uri(uri): | ||
if uri.startswith("s3://"): | ||
return S3Artifact(uri[5:]) | ||
elif uri.startswith("oss://"): | ||
return S3Artifact(uri[6:]) | ||
else: | ||
raise ValueError("Unrecognized scheme of URI: %s" % uri) | ||
|
||
|
||
def upload_artifact_and_print_uri(files, name): | ||
art = upload_artifact(files) | ||
if s3_config["repo_type"] == "s3" and hasattr(art, "key"): | ||
print("%s has been uploaded to s3://%s" % (name, art.key)) | ||
elif s3_config["repo_type"] == "oss" and hasattr(art, "key"): | ||
print("%s has been uploaded to oss://%s" % (name, art.key)) | ||
return art |