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

Mccalluc/consistent arrays #66

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

Conversation

mccalluc
Copy link
Contributor

@mccalluc mccalluc commented Oct 13, 2022

I've made lots of comments below. There are breaking changes here which will require work in portal-ui, but it's in the direction of greater consistency:

  • We always return an array now, instead of an array of viewconfs for some assays and plain viewconf for others. (This includes the Null case: portal should check len instead of is None.)
  • The array is an array of ViteesceConfig objects: portal-ui will need to call .to_dict(): The idea is just to stay with a higher level object as long as possible, and leave it to the downstream code to pull out what it needs.

@mccalluc mccalluc mentioned this pull request Oct 13, 2022
@@ -1 +1 @@
0.0.6
0.1.0
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change to the interface, so incrementing the minor version number seems appropriate.

def __init__(self, entity, groups_token, assets_endpoint, **kwargs):
super().__init__(entity, groups_token, assets_endpoint, **kwargs)
def __init__(self, entity, groups_token, assets_endpoint):
super().__init__(entity, groups_token, assets_endpoint)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The **kwargs has masked bugs: We thought we were using the right kwarg, but there was a typo, so the code assumed no value was supplied and it continued on without complaint.

# Spatially resolved RNA-seq assays require some special handling,
# and others do not.
self._is_spatial = False
self._scatterplot_w = 9

def get_conf_cells(self, marker=None):
def get_configs(self, marker=None):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Builder subclasses now define get_configs instead of get_conf_cells, which is now defined only on the base class. The idea is to factor up behavior which is shared between subclasses.

@@ -77,7 +76,7 @@ def get_conf_cells(self, marker=None):
))

vc = self._setup_anndata_view_config(vc, dataset, marker)
return get_conf_cells(vc)
return [vc]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • See above: This method is now only responsible for returning confs
  • Big change: Every class now returns a list of viewconfs. For most, it's only one element, but consistency in return types is a good thing.

return [
nbformat.v4.new_code_cell(f'from vitessce import {", ".join(imports)}'),
nbformat.v4.new_code_cell(f'conf = {conf_expression}\nconf.widget()'),
]
Copy link
Contributor Author

@mccalluc mccalluc Oct 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both of these are moved from utils, since this is the only code that needs them.

def get_conf_cells(self, **kwargs):
return ConfCells(None, None)
def get_configs_cells(self, marker=None):
return ConfigsCells([], [])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency, even for the Null case we return lists. (One possibility for the cells would be to generate a message that there is no visualization... Sort of depends on the direction taken by workspaces.)

kwargs = {'marker': marker} if marker is not None else {}
configs = self.get_configs(**kwargs)
cells = _get_cells_from_conf_list(configs)
return ConfigsCells(configs, cells)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the new base class method that constructs the list of cells and returns a tuple.

def get_conf_cells(self, **kwargs):
pass
def get_configs(self):
raise NotImplementedError()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't be called... if it were, we want an error.

@@ -93,7 +93,7 @@ def get_conf_cells(self, **kwargs):
conf = vc.to_dict()
# Don't want to render all layers
del conf["datasets"][0]["files"][0]["options"]["renderLayers"]
return get_conf_cells(conf)
return [VitessceConfig.from_dict(conf)]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another change for the sake of consistency: get_configs will now always return a list of configuration objects, instead of returning dicts for some classes, objects for others, and lists in a couple cases.

@@ -159,13 +159,11 @@ def get_conf_cells(self, **kwargs):
conf = vc.to_dict()
# Don't want to render all layers
del conf["datasets"][0]["files"][0]["options"]["renderLayers"]
confs.append(conf)
return get_conf_cells(confs)
confs.append(VitessceConfig.from_dict(conf))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto: We're always objects now.

self._imaging_path_regex = kwargs["imaging_path"]
self._base_name = base_name
self._image_name = base_name
self._imaging_path_regex = imaging_path
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mentioned above: Make kwargs explicit to avoid typo bugs.

"coordinationSpace": {
"dataset": {
"A": "A"
[
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We consistently return a list now. (Hide whitespace on the diff to make review easier.)

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

Successfully merging this pull request may close these issues.

1 participant