question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature][runtime env] refactor URI Protocol in runtime env.

See original GitHub issue

Search before asking

  • I had searched in the issues and found no similar feature requirement.

Description

Make different protocols become different plugins. In simple terms, I want to implement a SmartURIHandle, somewhat similar to io_path:


class BaseURIHandler:
    def __init__(self, uri):
        ...
    async def async_download(self, file_name):
        ...
    
    async def get_hash_from_uri(self):
        ...
    
    async def get_hash_from_file(self, local_path):    
        ...

class SmartURIHandler:

    @classmethod
    def register_handler(cls, handler: BaseURIHandler):
        ....
    
    async def async_download(self, urI):
        ...
    
    async def get_hash_from_uri(self):
        ...
    
    async def get_hash_from_file(self, local_path):    
        ...

# download file
async def download_package(uri, file_name):
    return await SmartURIHandler(uri).download(file_name)

This simplifies the implementation of runtime_env.packing.py, and in the future, we have the opportunity to let users define their own protocols outside of ray.

Use case

No response

Related issues

No response

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Catch-Bullcommented, Mar 1, 2022

@Catch-Bull the idea looks good, but I’m not sure about the specifics of this proposal. I think we could do something simpler like define an abstract URIHandler and then register the supported ones like this:

uri_handlers: Dict[str, URIHandler] = {"http": HTTPHandler}

ray.runtime_env.register_uri_handler("custom-uri", CustomURIHandler)

no problem and I will open a PR, we can discuss details in PR’s comment

1reaction
Catch-Bullcommented, Feb 25, 2022

This looks like a good idea to me. What does register_handler do?

make SmartURIHandler have the ability to handle a specific URI, for example:

class MyURIHandler:
    PROTOCOL = "my_uri"

# this will raise exception with message "unregister protocol: my_uri "
SmartURIHandler("my_uri://test.zip")

SmartURIHandler.register_handler(MyURIHandler)

# It will be OK
SmartURIHandler("my_uri://test.zip")

Read more comments on GitHub >

github_iconTop Results From Across the Web

Refactoring Activities into a Sub-Process
You can create a new call sub-process activity and sub-process by extracting existing objects. Procedure. Select the objects that you want to put...
Read more >
Allow vscode.env.asExternalUri to return valid results ... - GitHub
Here's how that could look like: On the desktop, the API would return a URI with the ${appScheme} protocol which would open the...
Read more >
Unit Testing | Nuxeo Documentation
The Nuxeo Test Framework is based on JUnit4 and provides features such as: Test configuration through annotations,. Embedded Nuxeo Runtime,.
Read more >
PyInstaller Documentation - Read the Docs
PyInstaller is distributed under a dual-licensing scheme using both the GPL 2.0 License, ... environment, --runtime-tmpdir might be a workaround.).
Read more >
Bundle names used in repository - Eclipse Downloads
Service Location Protocol (RFC 2608) Implementation Source ... SourceForge LPG Java Runtime Source Bundle; net.i2p.crypto.eddsa 0.3.0.v20220506-1020
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found