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

from_anndata, from_path, ... only needs to be added to the Artifact Registry #87

Open
rcannood opened this issue Nov 19, 2024 · 1 comment
Labels
enhancement New feature or request
Milestone

Comments

@rcannood
Copy link
Collaborator

rcannood commented Nov 19, 2024

Functions like from_path and from_anndata should only be added if the class is an Artifact Registry.

We probably need a

create_registry <- function(instance, module, api, registry_name, registry_schema) {
  public <- list(
    initialize = function(instance, module, api, registry_name, registry_schema) {
      super$new(
        instance = instance,
        module = module,
        api = api,
        registry_name = registry_name,
        registry_schema = registry_schema
      )
    },
    # ...
  )

  if (registry_name == "Artifact") {
    public$from_path <- ...
    public$from_anndata <- ..
    public$from_dir <- ...
    public$from_mudata <- ...
  }
  if (registry_names == "FeatureSet") {
    public$from_values <- ...
  }
  # ...

  RichRegistryClass <- R6::R6Class(
    paste0(registry_name, "Registry"),
    cloneable = FALSE,
    inherit = Registry,
    public = public
  )

  RichRegistryClass
}

Or the other way around

create_registry <- function(instance, module, api, registry_name, registry_schema) {
  public <- list(
    initialize = function(instance, module, api, registry_name, registry_schema) {
      super$new(
        instance = instance,
        module = module,
        api = api,
        registry_name = registry_name,
        registry_schema = registry_schema
      )
    },
    from_path = function(...) {
      ...
    },
    from_anndata = function(...) {
      ...
    },
    from_dir = function(...) {
      ...
    },
    # ...
  )

  if (registry_name != "Artifact") {
    public$from_path <- NULL
    public$from_anndata <- NULL
    public$from_dir <- NULL
    public$from_mudata <- NULL
  }
  if (registry_names != "FeatureSet") {
    public$from_values <- NULL
  }
  # ...

  RichRegistryClass <- R6::R6Class(
    paste0(registry_name, "Registry"),
    cloneable = FALSE,
    inherit = Registry,
    public = public
  )

  RichRegistryClass
}

Originally posted by @rcannood in #85 (comment)

@rcannood
Copy link
Collaborator Author

Somewhat related to #63

@rcannood rcannood added this to the 0.2.1 milestone Nov 25, 2024
@rcannood rcannood added the enhancement New feature or request label Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant