Skip to content
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

[batch] use volcano TOS as batch storage #344

Merged
merged 9 commits into from
Nov 5, 2024
Merged

[batch] use volcano TOS as batch storage #344

merged 9 commits into from
Nov 5, 2024

Conversation

xinchen384
Copy link
Contributor

Pull Request Description

This PR uses remote TOS to save all Batch requests, including input and output.
Now this PR uses volcano TOS.

Related Issues

Resolves: part of #182

  1. Before use volcano TOS, we need to create bucket on TOS first. When initializing TOS config, it needs to pass access_key and secret_key.
  2. This PR completes the read and write operation for both input and output.
  3. The above R/W operations are consistent with the online object results by checking TOS browser.
  4. The prefix API works fine on Volcano's TOS. All tests work as expected.
image
Contribution Guidelines (Expand for Details)

We appreciate your contribution to aibrix! To ensure a smooth review process and maintain high code quality, please adhere to the following guidelines:

Pull Request Title Format

Your PR title should start with one of these prefixes to indicate the nature of the change:

  • [Bug]: Corrections to existing functionality
  • [CI]: Changes to build process or CI pipeline
  • [Docs]: Updates or additions to documentation
  • [API]: Modifications to aibrix's API or interface
  • [CLI]: Changes or additions to the Command Line Interface
  • [Misc]: For changes not covered above (use sparingly)

Note: For changes spanning multiple categories, use multiple prefixes in order of importance.

Submission Checklist

  • PR title includes appropriate prefix(es)
  • Changes are clearly explained in the PR description
  • New and existing tests pass successfully
  • Code adheres to project style and best practices
  • Documentation updated to reflect changes (if applicable)
  • Thorough testing completed, no regressions introduced

By submitting this PR, you confirm that you've read these guidelines and your changes align with the project's contribution standards.



if __name__ == "__main__":
test_submit_job_input()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not to use pytest here? and seems you only invoke one test method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remove the main. pytest is enabled here by default.
image

Copy link
Collaborator

@Jeffwan Jeffwan Nov 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, please move it under batch folder etc if this is specific to batch feature. it can be done in future PRs

)


def initialize_storage(storage_type=StorageType.LocalDiskFile, params={}):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: what's the different between initialize_storage and initialize_batch_storage? why do we need two levels?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is to be consistent with other interfaces.

@@ -14,14 +14,30 @@

import uuid

from aibrix.batch.storage.tos_storage import TOSStorage
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please also add S3 later. You can use minio for testing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack


self._client = None
self._bucket_name = bucket_name
endpoint = "tos-cn-beijing.volces.com"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we ask user to pass in the endpoint and region. they should be same as credentials. We can not fix it here. We already have cluster setup for other regions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Complete it.

)

print("Finished creating TOS client!!!")
# HTTP状态码
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you remove chinese characters?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

self._bucket_name, object_key, content=string_io_obj
)

print("Finished creating TOS client!!!")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you use logging instead of print?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you need to create object as part of client initialization

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove is done.

try:
self._client = tos.TosClientV2(ak, sk, endpoint, region)
object_key = "test_key"
string_io_obj = StringIO("hello world")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are you doing here..?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

)
except tos.exceptions.TosServerError as e:
# 操作失败,捕获服务端异常,可从返回信息中获取详细错误信息
print("fail with server error, code: {}".format(e.code))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not create a single message and custom the error string?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update is done

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems this is not done yet. this is minor issue. please help refactor it in later PRs.

 except tos.exceptions.TosServerError as e:
            logging.error(f"fail with server error, code: {e.code}")
            logging.error(f"error with request id: {e.request_id}")
            logging.error(f"error with message: {e.message}")
            logging.error(f"error with http code: {e.status_code}")
            logging.error(f"error with ec: {e.ec}".format())
            logging.error(f"error with request url: {e.request_url}")

@xinchen384
Copy link
Contributor Author

All comments have been addressed. This PR I only change the print to logging in TOS file. Next PR I will change all print to logging. @Jeffwan

@Jeffwan
Copy link
Collaborator

Jeffwan commented Nov 5, 2024

It looks good to me. please address unfinished items in future PR. I highly suggest to concentrate on e2e testing in future PRs and list down the blocker items so we can better build the plans

@Jeffwan Jeffwan merged commit 33e21d0 into main Nov 5, 2024
9 checks passed
@Jeffwan Jeffwan deleted the xin/tos branch November 5, 2024 00:36
gangmuk pushed a commit that referenced this pull request Jan 25, 2025
* use TOS as batch request storage

* update format check

* file with test

* update tos with volcano TOS and add an initialization for storage

* update format

* address comments

* remove main

* update log format

* update log format

---------

Co-authored-by: xin.chen <xin.chen@bytedance.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants