Skip to content

Commit

Permalink
Merge branch 'release_24.1' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
nsoranzo committed Jun 2, 2024
2 parents 9753a0b + 0a7de5c commit ef294f9
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 67 deletions.
6 changes: 5 additions & 1 deletion client/src/components/History/HistoryView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</div>

<b-alert :show="copySuccess">
History imported and is now your active history. <b-link to="/histories/list">View here</b-link>.
History imported and is now your active history. <b-link :to="importedHistoryLink">View here</b-link>.
</b-alert>

<CollectionPanel
Expand All @@ -40,6 +40,7 @@
<script>
import { mapActions, mapState } from "pinia";
import { isAnonymousUser } from "@/api";
import { useHistoryStore } from "@/stores/historyStore";
import { useUserStore } from "@/stores/userStore";
Expand Down Expand Up @@ -89,6 +90,9 @@ export default {
canImportHistory() {
return !this.userOwnsHistory && !this.history.purged;
},
importedHistoryLink() {
return isAnonymousUser(this.currentUser) ? "/" : "/histories/list";
},
},
created() {
this.loadHistoryById(this.id);
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/History/Modals/CopyModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ async function copy(close: () => void) {
<transition name="fade">
<BAlert v-localize :show="isAnonymous" variant="warning">
As an anonymous user, unless you log in or register, you will lose your current history after copying
this history. You can <a href="/user/login">log in here</a> or <a href="/user/create">register here</a>.
this history. You can <a href="/login/start">log in or register here</a>.
</BAlert>
</transition>

Expand Down
75 changes: 43 additions & 32 deletions lib/galaxy/visualization/data_providers/genome.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
GFFReaderWrapper,
parse_gff_attributes,
)
from galaxy.exceptions import MessageException
from galaxy.model import DatasetInstance
from galaxy.visualization.data_providers.basic import BaseDataProvider
from galaxy.visualization.data_providers.cigar import get_ref_based_read_seq_and_cigar
Expand Down Expand Up @@ -106,43 +107,53 @@ def __init__(self, converted_dataset):
self.converted_dataset = converted_dataset

def get_data(self, query):
if self.converted_dataset is None or not self.converted_dataset.is_ok:
raise MessageException("The dataset is not available or is in an error state.")
# Init.
textloc_file = open(self.converted_dataset.get_file_name())
line_len = int(textloc_file.readline())
file_len = os.path.getsize(self.converted_dataset.get_file_name())
query = query.lower()

# Find query in file using binary search.
low = 0
high = int(file_len / line_len)
while low < high:
mid: int = (low + high) // 2
position = mid * line_len
textloc_file.seek(position)

# Compare line with query and update low, high.
result = []
with open(self.converted_dataset.get_file_name()) as textloc_file:
line = textloc_file.readline()
if line < query:
low = mid + 1
else:
high = mid
if not line:
raise MessageException("The dataset is empty.")
try:
line_len = int(line)
except ValueError:
raise MessageException(f"Expected an integer at first line, but found: '{line}'")
if line_len < 1:
raise MessageException(f"The first line must be a positive integer, but found: {line_len}")

file_len = os.path.getsize(self.converted_dataset.get_file_name())
query = query.lower()

# Find query in file using binary search.
low = 0
high = int(file_len / line_len)
while low < high:
mid: int = (low + high) // 2
position = mid * line_len
textloc_file.seek(position)

# Compare line with query and update low, high.
line = textloc_file.readline()
if line < query:
low = mid + 1
else:
high = mid

# Need to move back one line because last line read may be included in
# results.
position = low * line_len
textloc_file.seek(position)
# Need to move back one line because last line read may be included in
# results.
position = low * line_len
textloc_file.seek(position)

# At right point in file, generate hits.
result = []
while True:
line = textloc_file.readline()
if not line.startswith(query):
break
if line[-1:] == "\n":
line = line[:-1]
result.append(line.split()[1:])
# At right point in file, generate hits.
while True:
line = textloc_file.readline()
if not line.startswith(query):
break
if line[-1:] == "\n":
line = line[:-1]
result.append(line.split()[1:])

textloc_file.close()
return result


Expand Down
41 changes: 10 additions & 31 deletions lib/galaxy_test/driver/driver_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@
DEFAULT_WEB_HOST,
target_url_parts,
)
from tool_shed.webapp.app import UniverseApplication as ToolshedUniverseApplication
from tool_shed.webapp.fast_app import initialize_fast_app as init_tool_shed_fast_app
from .test_logging import logging_config_file

galaxy_root = galaxy_directory()
Expand All @@ -71,9 +69,8 @@
log = logging.getLogger("test_driver")


# Global variables to pass database contexts around - only needed for older
# Global variable to pass database contexts around - only needed for older
# Tool Shed twill tests that didn't utilize the API for such interactions.
tool_shed_context = None
install_context = None


Expand Down Expand Up @@ -583,26 +580,6 @@ def build_galaxy_app(simple_kwargs) -> GalaxyUniverseApplication:
return app


def build_shed_app(simple_kwargs):
"""Build a Galaxy app object from a simple keyword arguments.
Construct paste style complex dictionary. Also setup "global" reference
to sqlalchemy database context for tool shed database.
"""
log.info("Tool shed database connection: %s", simple_kwargs["database_connection"])
# TODO: Simplify global_conf to match Galaxy above...
simple_kwargs["__file__"] = "tool_shed_wsgi.yml.sample"
simple_kwargs["global_conf"] = get_webapp_global_conf()

app = ToolshedUniverseApplication(**simple_kwargs)
log.info("Embedded Toolshed application started")

global tool_shed_context
tool_shed_context = app.model.context

return app


def explicitly_configured_host_and_port(prefix, config_object):
host_env_key = f"{prefix}_TEST_HOST"
port_env_key = f"{prefix}_TEST_PORT"
Expand Down Expand Up @@ -758,7 +735,14 @@ def launch_gravity(port, gxit_port=None, galaxy_config=None):
)


def launch_server(app_factory, webapp_factory, prefix=DEFAULT_CONFIG_PREFIX, galaxy_config=None, config_object=None):
def launch_server(
app_factory,
webapp_factory,
prefix=DEFAULT_CONFIG_PREFIX,
galaxy_config=None,
config_object=None,
init_fast_app=init_galaxy_fast_app,
):
name = prefix.lower()
host, port = explicitly_configured_host_and_port(prefix, config_object)
port = attempt_ports(port)
Expand Down Expand Up @@ -792,12 +776,7 @@ def launch_server(app_factory, webapp_factory, prefix=DEFAULT_CONFIG_PREFIX, gal
static_enabled=True,
register_shutdown_at_exit=False,
)
if name == "galaxy":
asgi_app = init_galaxy_fast_app(wsgi_webapp, app)
elif name == "tool_shed":
asgi_app = init_tool_shed_fast_app(wsgi_webapp, app)
else:
raise NotImplementedError(f"Launching {name} not implemented")
asgi_app = init_fast_app(wsgi_webapp, app)

server, port, thread = uvicorn_serve(asgi_app, host=host, port=port)
set_and_wait_for_http_target(prefix, host, port, url_prefix=url_prefix)
Expand Down
28 changes: 27 additions & 1 deletion lib/tool_shed/test/base/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
from galaxy_test.driver import driver_util
from tool_shed.test.base.api_util import get_admin_api_key
from tool_shed.webapp import buildapp as toolshedbuildapp
from tool_shed.webapp.app import UniverseApplication as ToolshedUniverseApplication
from tool_shed.webapp.fast_app import initialize_fast_app as init_tool_shed_fast_app

log = driver_util.build_logger()

Expand All @@ -36,6 +38,29 @@
<data_managers>
</data_managers>
"""
# Global variable to pass database contexts around - only needed for older
# Tool Shed twill tests that didn't utilize the API for such interactions.
tool_shed_context = None


def build_shed_app(simple_kwargs):
"""Build a Galaxy app object from a simple keyword arguments.
Construct paste style complex dictionary. Also setup "global" reference
to sqlalchemy database context for tool shed database.
"""
log.info("Tool shed database connection: %s", simple_kwargs["database_connection"])
# TODO: Simplify global_conf to match Galaxy above...
simple_kwargs["__file__"] = "tool_shed_wsgi.yml.sample"
simple_kwargs["global_conf"] = driver_util.get_webapp_global_conf()

app = ToolshedUniverseApplication(**simple_kwargs)
log.info("Embedded Toolshed application started")

global tool_shed_context
tool_shed_context = app.model.context

return app


class ToolShedTestDriver(driver_util.TestDriver):
Expand Down Expand Up @@ -117,10 +142,11 @@ def _setup_local(self):
# ---- Run tool shed webserver ------------------------------------------------------
# TODO: Needed for hg middleware ('lib/galaxy/webapps/tool_shed/framework/middleware/hg.py')
tool_shed_server_wrapper = driver_util.launch_server(
app_factory=lambda: driver_util.build_shed_app(kwargs),
app_factory=lambda: build_shed_app(kwargs),
webapp_factory=toolshedbuildapp.app_factory,
galaxy_config=kwargs,
prefix="TOOL_SHED",
init_fast_app=init_tool_shed_fast_app,
)
self.server_wrappers.append(tool_shed_server_wrapper)
tool_shed_test_host = tool_shed_server_wrapper.host
Expand Down
2 changes: 1 addition & 1 deletion lib/tool_shed/test/base/test_db_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


def sa_session():
from galaxy_test.driver.driver_util import tool_shed_context as sa_session
from .driver import tool_shed_context as sa_session

return sa_session

Expand Down

0 comments on commit ef294f9

Please sign in to comment.