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

Adding docs #21

Open
marimeireles opened this issue Jul 25, 2024 · 1 comment
Open

Adding docs #21

marimeireles opened this issue Jul 25, 2024 · 1 comment

Comments

@marimeireles
Copy link

Hi Josh,

I've been reading omero-rdf code because I'm looking into building a similar tool to scrape data from the electronic notebook system (and possibly build a more generic tool for extracting data).

I thought I might write some small "how to use" docs for omero-rdf.

from omero.plugins.rdf import RdfControl
from omero.cli import CLI

def main():
    # OMERO server connection details
    host = 'localhost'
    port = 4064
    username = 'your_username'
    password = 'your_password'

    # Image ID to export as RDF
    image_id = 123

    # Create an instance of the CLI class
    cli = CLI()

    # Login to the OMERO server
    cli.invoke(["login", host, "-u", username, "-w", password, "-p", str(port)])

    # Create an instance of the RdfControl class
    rdf_control = RdfControl(cli)

    # Set up the arguments for exporting the RDF
    args = Namespace(
        target=[f"Image:{image_id}"],
        pretty=True,
        ellide=False,
        trim_whitespace=False
    )

    # Run the action to export RDF
    rdf_control.action(args)

    # Logout from the OMERO server
    cli.invoke(["logout"])

if __name__ == "__main__":
    main()

This is an improved (by chatgpt) version of the script I first wrote to use omero-rdf, though, I'm not entirely sure if that's how it's supposed to be used?

I also could try to add some little introduction on how to build a plugin, which might be helpful for #11.

Please let me know whether I'm on the right path and if docs would be helpful here. :)

@joshmoore
Copy link
Member

This is really interesting, @marimeireles! It's like ChatGPT read the implementation and did something that would be technically correct, but not optimal (and not something that I think any human has ever done).

With OMERO plugins, there are usually two styles of access:

  • CLI based, i.e. from Bash
  • Library based

For the second, we really should do some refactoring so that you don't need any of the boilerplate above. i.e., our goal would be something like:

from omero.gateway import BlitzGateway
from omero_rdf import RdfLibrary

with BlitzGateway("root","omero","xx.xxx.xxx.xx") as conn:
    lib = RdfLibrary(connection)
    # Load whatever you want here.

For #11, I think you are most interested in something like https://github.com/German-BioImaging/omero-rdf/blob/main/src/omero_rdf/idr_annotations.py

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

No branches or pull requests

2 participants