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

Show the user the available projects in the catmaid instance and their associated id #157

Open
histonemark opened this issue Jun 4, 2020 · 3 comments

Comments

@histonemark
Copy link

Hi,

If I've read the code correctly, every time you use functions building on catmaid_fetch, the project id has to be provided (or defaults to 1). I think it would be nice to allow the user to see the available projects in the Catmaid insance they are connecting to (during catmaid_login for example), and ask him to select one. Catmaid exposes the info via the api so getting the projects is a catmaid_fetch('projects', conn = conn) away. If asking the user interactively is not an option, I would suggest to warn the user and default to the first pid available to the user in the server (not always 1 apparently). Apologies if I missed something, and if you want me to submit it as a push request, I am happy to give it a try.

Cheers.

Marc

@jefferis
Copy link
Collaborator

jefferis commented Jun 4, 2020

Dear Marc,

Thanks for your message and interest in the catmaid R package. I'm not sure that "rcatmaid assumes one project per instance" is a very good summary precisely because you have the option to submit a specific project id (pid) in any call to the catmaid server. What I have considered would be the option to associate a default pid with a connection object. If you would like to submit a pull request generating a catmaid_projects function something like this

catmaid_projects<-function(conn, ...) {
catmaid_fetch('projects', conn = conn, ...)
# [process results? into a data.frame?]
}

then I would be very happy to review.

I don't think asking the user to choose a pid interactively is a good idea, but for connections to neuprint I have recently implemented the pattern of associating the dataset (similar to project) with the connection object and warning when more than one is available.

Best,

Greg.

@histonemark
Copy link
Author

Hi Greg,

Sorry if my title was misleading, i will give it a go, and thanks or the fantastic package!

Marc

@histonemark histonemark changed the title rcatmaid assumes one project per instance Show the user the available projects in the catmaid instance and thieir associated id Jun 4, 2020
@histonemark histonemark changed the title Show the user the available projects in the catmaid instance and thieir associated id Show the user the available projects in the catmaid instance and their associated id Jun 4, 2020
@histonemark
Copy link
Author

histonemark commented Jun 10, 2020

Hi Greg,

In my opinion, it would be valuable to add 2 slots to conn:

  • pid: defaulting to the first of the available projects in the catmaid instance. (making it consistent with the parameter of the functions that I would modify to set the default pid by reading the conn object.
  • proj_name_id: the list of the names and pids available in the catmaid instance (to be able to switch project without login twice).

The parsing is easy, we could call:

# Every CATMAID server can have more than one project. We can store the project
# names and ids on the first connection and default to one. 
catmaid_projects<-function(conn, ...) {
  avail_proj = catmaid_fetch('projects', conn = conn)
  proj_name_id = lapply(avail_proj, function(x){unlist(x)[c("id","title")]})
  return(invisible(proj_name_id))
 }

When wold you call it? I see that you try to build the conn object with cache, environment set variables or user passed arguments.
Do you want to allow setting and reading the variable from the environment with something like catmaid.pid/ catmaid_id? I think its a bit tedious to call the functions passing the pid each time, but that might be because I think in my user case scenario where I connect and work mostly with one of the available projects.

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