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] [Xlang] Auto method name translation

See original GitHub issue

Search before asking

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

Description

A common issue when communicating between Java and Python using the cross language API is the method name convention is not consistent for the language.

For example when calling java from Python

counter_class = ray.java_actor_class(
      "io.ray.demo.Counter")
counter = counter_class.remote()
# Note the camelCase
counter.incrementValue.remote()

calling Python from Java is less worried because you have to create PyActorMethod by string. But the snake_case still stand out.

    PyActorClass actorClass = PyActorClass.of(
        "ray_demo", "Counter");
    PyActorHandle actor = Ray.actor(actorClass).remote();
    ObjectRef objRef1 = actor.task(
        PyActorMethod.of("increment_value", int.class)).remote();

The mix of camelCase and snake_case is harms readability and compatibility. For example, in Ray Serve, our Python actor needs to manage both Java and Python actors, we have to sprinkle these cases everywhere:

if lang = "JAVA":
    ref = actor.performTask.remote(...)
else:
    ref = actor.perform_task.remote(...)

Proposal

Ideally, I can just call a snake_case method on Java actor handle and have it automatically translated to camelCase method name. so that

    ref = java_actor.perform_task.remote(...)

automatically resolves to the actor’s performTask method.

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
jon-chuangcommented, Jan 13, 2022

I feel that this should be opt-in. So

counter_class = ray.java_actor_class(..).set_snake_case_methods()
0reactions
jovany-wangcommented, Jan 17, 2022

It’s natural for Java and Py. But I’m not sure if it’s a good idea for other languages. For example, C++ has no strong recommend on the function name style. @qicosmos CC

I think it won’t be a problem if we let users specify the desired naming conversion explicitly, like what @jon-chuang recommended above.

Yes. Proposal from @jon-chuang looks good.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Image-to-Image Translation: Methods and Applications - arXiv
Abstract—Image-to-image translation (I2I) aims to transfer images from a source domain to a target domain while preserving.
Read more >
Linguistic Features · spaCy Usage Documentation
spaCy is a free open-source library for Natural Language Processing in Python. It features NER, POS tagging, dependency parsing, word vectors and more....
Read more >
Translation AI - Google Cloud
Cloud Translation lets you dynamically translate between languages using pre-trained or custom ML models based on your content needs.
Read more >
An Analysis of Arabic-English Translation: Problems ... - ERIC
This research paper is designed with a view to looking into various problems of translating. Arabic texts into English and fixing them with...
Read more >
GNU gettext utilities
The two strings, untranslated and translated, are quoted in various ways in the PO file, using " delimiters and \ escapes, but the...
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