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

Dynamic options: add data table filter #12941

Open
wants to merge 20 commits into
base: dev
Choose a base branch
from

Conversation

bernt-matthias
Copy link
Contributor

@bernt-matthias bernt-matthias commented Nov 17, 2021

In a recent gitter discussion (https://gitter.im/galaxy-iuc/iuc?at=6190aeff8c019f0d0b93414b) it was asked for a way to have a select list containing only elements that are not yet in a data table.. Et voila .. there is a data table filter.

The test tool shows how it might be used:

  1. the options are dynamically create from a file (from_file also had no test so far)
  2. the filter removes all options that are already in the data table

For the first part I needed to apply a little hack: from_file seems to assume that the file is in tool-data in the Galaxy root. It would be much nicer if the file would be loaded from the dir (or a tool-data dir in this dir) containing the tool. Otherwise we would not meet the use case of the gitter discussion.

I did not think about other possible use cases (e.g. intersections of data tables) and possibly needed attributes...

Ping @mvdbeek @pvanheus

The PR also adds more linting to filters.

How to test the changes?

(Select all options that apply)

  • I've included appropriate automated tests.
  • This is a refactoring of components with existing test coverage.
  • Instructions for manual testing are as follows:
    1. [add testing steps and prerequisites here if you didn't write automated tests covering all your changes]

License

  • I agree to license these contributions under Galaxy's current license.
  • I agree to allow the Galaxy committers to license these and all my past contributions to the core galaxy codebase under the MIT license. If this condition is an issue, uncheck and just let us know why with an e-mail to [email protected].

@github-actions github-actions bot added this to the 22.01 milestone Nov 17, 2021
@bernt-matthias bernt-matthias changed the title add data table filter dynamic options: add data table filter Nov 17, 2021
Copy link
Member

@mvdbeek mvdbeek left a comment

Choose a reason for hiding this comment

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

This is really cool, but from_file should not be able to reference files outside of the tool dir.

lib/galaxy/tools/parameters/dynamic_options.py Outdated Show resolved Hide resolved
lib/galaxy/tools/parameters/dynamic_options.py Outdated Show resolved Hide resolved
<inputs>
<param name="dynamic_select" type="select">
<!-- initialize options from file (contains all entries that could be added to the data table) -->
<options from_file="../test/functional/tool-data/test_file.tsv">
Copy link
Member

Choose a reason for hiding this comment

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

That's a security issue and should not work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you have an idea how to specify another dir during tests, eg test/functional/tool-data/?

I guess we can check if os.path.abspath(path) startswith the tool-data dir... could do this in another PR.

Copy link
Member

Choose a reason for hiding this comment

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

It's fine to do this in another PR, but we shouldn't merge this before we sorted that out.

Copy link
Member

Choose a reason for hiding this comment

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

Also there is a safe_contains function in galaxy.util you can use

Copy link
Contributor Author

@bernt-matthias bernt-matthias Nov 18, 2021

Choose a reason for hiding this comment

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

ae4c401 contains a possible solution for:

Do you have an idea how to specify another dir during tests, eg test/functional/tool-data/?

Any comments?

if not os.path.isabs(data_file):
full_path = os.path.join(self.tool_param.tool.app.config.tool_data_path, data_file)
full_path = os.path.join(self.tool_param.tool.app.config.tool_data_path, data_file)
full_path = os.path.normpath(full_path)
Copy link
Member

Choose a reason for hiding this comment

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

Is the normpath call necessary here ? safe_contains should be smart enough to figure this out, and joining with cwd for non-absolute paths does not seem right (that seems to be what normpath does internally).

@@ -60,7 +60,7 @@ def setUp(self):
self.galaxy_url = f"http://{self.galaxy_host}:{self.galaxy_port}"
self.shed_tool_data_table_conf = os.environ.get('TOOL_SHED_TEST_TOOL_DATA_TABLE_CONF')
self.file_dir = os.environ.get('TOOL_SHED_TEST_FILE_DIR', None)
self.tool_data_path = os.environ.get('GALAXY_TEST_TOOL_DATA_PATH')
self.tool_data_path = os.environ.get('GALAXY_TEST_TOOL_DATA_PATH', 'test/functional/tool-data/')
Copy link
Member

Choose a reason for hiding this comment

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

If that's necessary for tests to pass I think it likely alerts to the fact that this would break under other circumstances as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Found no other way to get the functional test working. But you are right, since there are probably other tests using data tables it makes one wonder why they are working.

I remember that the problem was that GALAXY_ROOT/tool-data was used if I did not change this.

Maybe this is related to the other comment?

Any suggestions how to continue. I'm happy to try anything :)

@mvdbeek mvdbeek modified the milestones: 22.01, 22.05 Jan 26, 2022
@mvdbeek
Copy link
Member

mvdbeek commented Jan 26, 2022

I'm bumping this to 22.05, we still need to figure out what's up with #12941 (comment)

@mvdbeek mvdbeek modified the milestones: 22.05, 22.09 May 25, 2022
@dannon dannon modified the milestones: 23.0, 23.1 Dec 8, 2022
@mvdbeek mvdbeek removed this from the 23.1 milestone Jun 21, 2023
@mvdbeek mvdbeek marked this pull request as draft June 21, 2023 18:30
@mvdbeek
Copy link
Member

mvdbeek commented Jun 21, 2023

There's a conflict here and I think the framework test failure is legitimate ?

@bernt-matthias bernt-matthias force-pushed the topic/data-table-filter branch 2 times, most recently from b973bd5 to 50ed0fe Compare February 17, 2024 15:11
@bernt-matthias bernt-matthias marked this pull request as ready for review February 17, 2024 15:32
@bernt-matthias bernt-matthias added this to the 24.0 milestone Feb 17, 2024
@mvdbeek mvdbeek modified the milestones: 24.0, 24.1 Mar 5, 2024
@mvdbeek mvdbeek modified the milestones: 24.1, 24.2 May 14, 2024
@jdavcs jdavcs changed the title dynamic options: add data table filter Dynamic options: add data table filter Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants