Skip to content

Commit

Permalink
Get the objectstore connected to the datasets used in the job using g…
Browse files Browse the repository at this point in the history
…et_dataset_attributes. And uses the requests library rather than httpx.
  • Loading branch information
pauldg committed Feb 5, 2024
1 parent 99a3be7 commit ad7c61e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
11 changes: 8 additions & 3 deletions tests/fixtures/scenario-locations-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@ tools:
offline
rules: []
rank: |
import httpx
import requests
import json
import pathlib
from ruamel.yaml import YAML
from tpv.commands.test import mock_galaxy
from tpv.core.helpers import get_dataset_attributes
# NOTE: currently object store info is stored in a yaml
objectstore_loc_path = "tests/fixtures/object_store_locations.yml"
print(dir(job))
dataset_attributes = helpers.get_dataset_attributes(job.input_datasets)
selected_object_store = "object_store_australia"
yaml=YAML(typ='safe')
Expand All @@ -36,11 +40,12 @@ tools:
input_data = {
"destinations": candidate_destinations_list,
"objectstores": objectstore_dict,
"selected_objectstore": selected_object_store
# "selected_objectstore": selected_object_store
"dataset_attributes": dataset_attributes
}
# Send a POST request to the API endpoint
response = httpx.post(api_url, json=input_data)
response = requests.post(api_url, json=input_data)
# Check if the request was successful (status code 200)
if response.status_code == 200:
Expand Down
7 changes: 5 additions & 2 deletions tests/test_scenarios_locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from galaxy.jobs.mapper import JobMappingException
from tpv.rules import gateway
from tpv.commands.test import mock_galaxy
from tpv.core.helpers import get_dataset_attributes

class TestScenarios(unittest.TestCase):

Expand Down Expand Up @@ -35,7 +36,8 @@ def test_scenario_esg_group_user(self):
tool = mock_galaxy.Tool('trinity')
user = mock_galaxy.User('pulsar-hm2-user', 'pulsar-hm2-user@unimelb.edu.au', roles=["ga_admins"])
datasets = [mock_galaxy.DatasetAssociation("input", mock_galaxy.Dataset("input.fastq",
file_size=1000*1024**3))]
file_size=1000*1024**3,
object_store_id="files1"))]
rules_file = os.path.join(os.path.dirname(__file__), 'fixtures/scenario-locations.yml')
destination = self._map_to_destination(tool, user, datasets=datasets, tpv_config_path=rules_file,
job_conf='fixtures/job_conf_scenario_locations.yml')
Expand All @@ -50,7 +52,8 @@ def test_scenario_esg_group_user_api(self):
tool = mock_galaxy.Tool('trinity')
user = mock_galaxy.User('pulsar-hm2-user', 'pulsar-hm2-user@unimelb.edu.au', roles=["ga_admins"])
datasets = [mock_galaxy.DatasetAssociation("input", mock_galaxy.Dataset("input.fastq",
file_size=1000*1024**3))]
file_size=1000*1024**3,
object_store_id="object_store_australia"))]
rules_file = os.path.join(os.path.dirname(__file__), 'fixtures/scenario-locations-api.yml')
destination = self._map_to_destination(tool, user, datasets=datasets, tpv_config_path=rules_file,
job_conf='fixtures/job_conf_scenario_locations.yml')
Expand Down

0 comments on commit ad7c61e

Please sign in to comment.