Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""Install the data_managers on galaxy"""
container = start_container
data_managers = [
dict(name="data_manager_fetch_genome_dbkeys_all_fasta",
owner="devteam"),
dict(name="data_manager_sam_fasta_index_builder",
owner="devteam"),
dict(name="data_manager_bwa_mem_index_builder",
owner="devteam")
]
irm = InstallRepositoryManager(container.gi)
irm.install_repositories(data_managers)
# Galaxy is restarted because otherwise data tables are not watched.
container.container.exec_run("supervisorctl restart galaxy:")
time.sleep(10) # give time for the services to go down
galaxy_wait(container.url)
# But alas, the trappings of a proprietary BSD kernel compel us to do ugly workarounds.
container = client.containers.run(GALAXY_IMAGE, detach=True, ports={'80/tcp': None}, **kwargs)
container_id = container.attrs.get('Id')
print(container_id)
# This seems weird as we also can just get container.attrs but for some reason
# the network settings are not loaded in container.attrs. With the get request
# these attributes are loaded
container_attributes = client.containers.get(container_id).attrs
# Venturing into deep nested dictionaries.
exposed_port = container_attributes.get('NetworkSettings').get('Ports').get('80/tcp')[0].get('HostPort')
container_url = "http://localhost:{0}".format(exposed_port)
galaxy_wait(container_url,
timeout=60) # We are only going to wait 60 seconds. These are tests, and we are impatient!
yield GalaxyContainer(url=container_url,
container=container,
attributes=container_attributes,
gi=GalaxyInstance(container_url, key="admin"))
container.remove(force=True)