Skip to content

Commit

Permalink
Fix issue with initialization of mock_galaxy object
Browse files Browse the repository at this point in the history
  • Loading branch information
nuwang committed Feb 18, 2023
1 parent 19113a9 commit 62063de
Show file tree
Hide file tree
Showing 24 changed files with 68 additions and 21 deletions.
4 changes: 2 additions & 2 deletions docs/topics/shell_commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ example:
rules: []
EOF
$ tpv lint good.yml
INFO : tpv.core.shell: lint successful.
INFO : tpv.commands.shell: lint successful.
$ echo $?
0
Expand All @@ -40,7 +40,7 @@ example:
cores: 1
EOF
$ tpv lint bad.yml
INFO : tpv.core.shell: lint failed.
INFO : tpv.commands.shell: lint failed.
$ echo $?
1
Expand Down
1 change: 1 addition & 0 deletions requirements_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ galaxy-files@git+https://github.com/galaxyproject/galaxy.git@release_22.05#subdi
galaxy-data@git+https://github.com/galaxyproject/galaxy.git@release_22.05#subdirectory=packages/data
galaxy-auth@git+https://github.com/galaxyproject/galaxy.git@release_22.05#subdirectory=packages/auth
galaxy-selenium@git+https://github.com/galaxyproject/galaxy.git@release_22.05#subdirectory=packages/selenium
galaxy-data@git+https://github.com/galaxyproject/galaxy.git@release_22.05#subdirectory=packages/data
galaxy-job-execution@git+https://github.com/galaxyproject/galaxy.git@release_22.05#subdirectory=packages/job_execution
galaxy-job-metrics@git+https://github.com/galaxyproject/galaxy.git@release_22.05#subdirectory=packages/job_metrics
galaxy-tool-util@git+https://github.com/galaxyproject/galaxy.git@release_22.05#subdirectory=packages/tool_util
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
},
entry_points={
'console_scripts': [
'tpv = tpv.core.shell:main'
'tpv = tpv.commands.shell:main'
]
},
classifiers=[
Expand Down
2 changes: 1 addition & 1 deletion tests/test_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from tpv.rules import gateway
from tpv.core.entities import Tag
from tpv.core.entities import TagType
from tpv.core.test import mock_galaxy
from tpv.commands.test import mock_galaxy


class TestEntity(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_mapper_basic.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import unittest
from tpv.rules import gateway
from tpv.core.test import mock_galaxy
from tpv.commands.test import mock_galaxy
from galaxy.jobs.mapper import JobMappingException


Expand Down
2 changes: 1 addition & 1 deletion tests/test_mapper_context.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import unittest
from tpv.rules import gateway
from tpv.core.test import mock_galaxy
from tpv.commands.test import mock_galaxy


class TestMapperContext(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_mapper_destinations.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import unittest
from tpv.rules import gateway
from tpv.core.test import mock_galaxy
from tpv.commands.test import mock_galaxy
from galaxy.jobs.mapper import JobMappingException


Expand Down
2 changes: 1 addition & 1 deletion tests/test_mapper_inheritance.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import unittest
from tpv.rules import gateway
from tpv.core.test import mock_galaxy
from tpv.commands.test import mock_galaxy
from tpv.core.loader import InvalidParentException


Expand Down
2 changes: 1 addition & 1 deletion tests/test_mapper_merge_multiple.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import unittest
from tpv.rules import gateway
from tpv.core.test import mock_galaxy
from tpv.commands.test import mock_galaxy
from galaxy.jobs.mapper import JobMappingException


Expand Down
2 changes: 1 addition & 1 deletion tests/test_mapper_params_specific.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import unittest
from tpv.rules import gateway
from tpv.core.test import mock_galaxy
from tpv.commands.test import mock_galaxy


class TestParamsSpecific(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_mapper_rank.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import unittest
from tpv.rules import gateway
from tpv.core.test import mock_galaxy
from tpv.commands.test import mock_galaxy


class TestMapperRank(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_mapper_role.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import unittest
from tpv.rules import gateway
from tpv.core.test import mock_galaxy
from tpv.commands.test import mock_galaxy
from galaxy.jobs.mapper import JobMappingException


Expand Down
2 changes: 1 addition & 1 deletion tests/test_mapper_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import shutil
import unittest
from tpv.rules import gateway
from tpv.core.test import mock_galaxy
from tpv.commands.test import mock_galaxy
from galaxy.jobs.mapper import JobMappingException
from galaxy.jobs.mapper import JobNotReadyException

Expand Down
2 changes: 1 addition & 1 deletion tests/test_mapper_sample.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import unittest
from tpv.rules import gateway
from tpv.core.test import mock_galaxy
from tpv.commands.test import mock_galaxy


class TestMapperSample(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_mapper_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import unittest
from tpv.rules import gateway
from tpv.core.entities import IncompatibleTagsException
from tpv.core.test import mock_galaxy
from tpv.commands.test import mock_galaxy


class TestMapperUser(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_scenarios.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import unittest
from galaxy.jobs.mapper import JobMappingException
from tpv.rules import gateway
from tpv.core.test import mock_galaxy
from tpv.commands.test import mock_galaxy


class TestScenarios(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import yaml
from galaxy.jobs.mapper import JobMappingException

from tpv.core.shell import main
from tpv.commands.shell import main


@pytest.fixture
Expand Down
File renamed without changes.
46 changes: 46 additions & 0 deletions tpv/commands/dryrunner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from .test import mock_galaxy
from tpv.rules import gateway


class TPVDryRunner():

def __init__(self, job_conf, tpv_confs=None, user=None, tool=None, job=None):
self.galaxy_app = mock_galaxy.App(job_conf=job_conf, create_model=True)
self.user = user
self.tool = tool
self.job = job
if tpv_confs:
self.tpv_config_files = tpv_confs
else:
self.tpv_config_files = self.galaxy_app.job_config.get_destination(
'tpv_dispatcher').params['tpv_config_files']

def run(self):
gateway.ACTIVE_DESTINATION_MAPPER = None
return gateway.map_tool_to_destination(self.galaxy_app, self.job, self.tool, self.user,
tpv_config_files=self.tpv_config_files)

@staticmethod
def from_params(job_conf, user=None, tool=None, tpv_confs=None, input_size=None):
if user is not None:
if '@' in user:
username, email = user.split('@', 1)
else:
username, email = (user, 'example.org')
user = mock_galaxy.User(username, email)
else:
user = None

if tool:
tool = mock_galaxy.Tool(tool)
else:
tool = None

job = mock_galaxy.Job()
if input_size:
dataset = mock_galaxy.DatasetAssociation(
"test",
mock_galaxy.Dataset("test.txt", file_size=input_size*1024**3))
job.add_input_dataset(dataset)

return TPVDryRunner(job_conf=job_conf, tpv_confs=tpv_confs, user=user, tool=tool, job=job)
2 changes: 1 addition & 1 deletion tpv/core/formatter.py → tpv/commands/formatter.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations
import logging

from . import util
from tpv.core import util

log = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion tpv/core/linter.py → tpv/commands/linter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging

from .loader import TPVConfigLoader
from tpv.core.loader import TPVConfigLoader

log = logging.getLogger(__name__)

Expand Down
File renamed without changes.
Empty file added tpv/commands/test/__init__.py
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ def __init__(self, job_conf=None, create_model=False):
server_name="main",
is_set=lambda x: True,
)
self.application_stack = ApplicationStack()
self.job_metrics = JobMetrics()
self.job_config = JobConfiguration(self)
if create_model:
self.model = mapping.init(
"/tmp",
"sqlite:///:memory:",
create_tables=True
)
self.application_stack = ApplicationStack(app=self)
self.job_config = JobConfiguration(self)


class User:
Expand Down

0 comments on commit 62063de

Please sign in to comment.