Skip to content

Commit

Permalink
Changed the default resource ID (#102)
Browse files Browse the repository at this point in the history
* Changed default service for caom2repo to ivo://cadc.nrc.ca/ams
  • Loading branch information
andamian authored Jan 18, 2019
1 parent 4826b7d commit 2e1fca7
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 42 deletions.
29 changes: 18 additions & 11 deletions caom2pipe/caom2pipe/execute_composable.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,9 @@ def _fits2caom2_cmd_client(self):
mc.exec_cmd(cmd)

def _fits2caom2_cmd_client_local(self):
"""Execute fits2caom with a --cert parameter and a --local parameter."""
"""
Execute fits2caom with a --cert parameter and a --local parameter.
"""
plugin = self._find_fits2caom2_plugin()
# so far, the plugin is also the module :)
local_fqn = os.path.join(self.working_dir, self.fname)
Expand Down Expand Up @@ -417,9 +419,9 @@ def _fits2caom2_cmd_in_out_local_client(self):
local_fqn = os.path.join(self.working_dir, self.fname)
cmd = '{} {} {} --in {} --out {} --local {} ' \
'--plugin {} --module {} --lineage {}/{}'.format(
self.command_name, self.logging_level_param, self.cred_param,
self.model_fqn, self.model_fqn, local_fqn, plugin, plugin,
self.product_id, self.uri)
self.command_name, self.logging_level_param, self.cred_param,
self.model_fqn, self.model_fqn, local_fqn, plugin, plugin,
self.product_id, self.uri)
mc.exec_cmd(cmd)

def _compare_checksums_client(self, fname):
Expand Down Expand Up @@ -1275,14 +1277,16 @@ def choose(self, storage_name, command_name, meta_visitors, data_visitors):
self.chooser.needs_delete(observation)):
executors.append(
Collection2CaomLocalMetaDeleteCreateClient(
self.config, storage_name, command_name,
self.config, storage_name,
command_name,
cred_param, cadc_data_client,
caom_repo_client, observation,
meta_visitors))
else:
executors.append(
Collection2CaomLocalMetaUpdateClient(
self.config, storage_name, command_name,
self.config, storage_name,
command_name,
cred_param, cadc_data_client,
caom_repo_client, observation,
meta_visitors))
Expand All @@ -1291,15 +1295,18 @@ def choose(self, storage_name, command_name, meta_visitors, data_visitors):
self.chooser.needs_delete(observation)):
executors.append(
Collection2CaomMetaDeleteCreateClient(
self.config, storage_name, command_name,
self.config, storage_name,
command_name,
cred_param, cadc_data_client,
caom_repo_client, observation,
meta_visitors))
else:
executors.append(Collection2CaomMetaUpdateClient(
self.config, storage_name, command_name,
cred_param, cadc_data_client, caom_repo_client,
observation, meta_visitors))
executors.append(
Collection2CaomMetaUpdateClient(
self.config, storage_name,
command_name, cred_param,
cadc_data_client, caom_repo_client,
observation, meta_visitors))
elif task_type == mc.TaskType.MODIFY:
if self.config.use_local_files:
if (executors is not None and len(executors) > 0 and
Expand Down
5 changes: 2 additions & 3 deletions caom2pipe/caom2pipe/manage_composable.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@

from cadcutils import net
from cadcdata import CadcDataClient
from caom2 import ObservationWriter, ObservationReader, Artifact, ReleaseType
from caom2 import ObservationWriter, ObservationReader, Artifact
from caom2 import ChecksumURI


Expand Down Expand Up @@ -583,7 +583,6 @@ def update_for_retry(self, count):

logging.info('Retry work file is {}'.format(self.work_fqn))


@staticmethod
def load_config(config_fqn):
"""Read a configuration as a YAML file.
Expand Down Expand Up @@ -892,7 +891,7 @@ def write_to_file(fqn, content):
try:
with open(fqn, 'w') as f:
f.write(content)
except Exception as e:
except Exception:
logging.error('Could not write file {}'.format(fqn))
raise CadcException('Could not write file {}'.format(fqn))

Expand Down
3 changes: 1 addition & 2 deletions caom2pipe/caom2pipe/tests/test_execute_composable.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
class MyExitError(Exception):
pass


if six.PY3:
class TestVisit:
@staticmethod
Expand All @@ -105,7 +106,6 @@ def visit(observation, **kwargs):
assert z is not None, 'log file directory'
assert observation is not None, 'undefined observation'


class TestStorageName(ec.StorageName):
def __init__(self, obs_id=None, file_name=None):
super(TestStorageName, self).__init__(
Expand All @@ -114,7 +114,6 @@ def __init__(self, obs_id=None, file_name=None):
def is_valid(self):
return True


class TestChooser(ec.OrganizeChooser):
def __init(self):
super(TestChooser, self).__init__()
Expand Down
9 changes: 5 additions & 4 deletions caom2pipe/caom2pipe/tests/test_manage_composable.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,13 @@ def test_get_artifact_metadata():

# create action
result = mc.get_artifact_metadata(test_fqn, ProductType.WEIGHT,
ReleaseType.META, uri=test_uri)
ReleaseType.META, uri=test_uri)
assert result is not None, 'expect a result'
assert isinstance(result, Artifact), 'expect an artifact'
assert result.product_type == ProductType.WEIGHT, 'wrong product type'
assert result.content_length == 255, 'wrong length'
assert result.content_checksum.uri == \
'md5:c649725745805d41fc1b601e85400e60', 'wrong checksum'
'md5:c649725745805d41fc1b601e85400e60', 'wrong checksum'

# update action
result.content_checksum = ChecksumURI('md5:abc')
Expand All @@ -250,7 +250,7 @@ def test_get_artifact_metadata():
assert result is not None, 'expect a result'
assert isinstance(result, Artifact), 'expect an artifact'
assert result.content_checksum.uri == \
'md5:c649725745805d41fc1b601e85400e60', 'wrong checksum'
'md5:c649725745805d41fc1b601e85400e60', 'wrong checksum'


# TODO understand python mocking .... :(
Expand All @@ -274,7 +274,8 @@ def test_get_artifact_metadata():
# # file_chunks = [file_content[i:i + 5].encode()
# # for i in range(0, len(file_content), 5)]
# # response = Mock()
# # response.headers.get.return_value = 'filename={}.gz'.format('TEST.fits')
# # response.headers.get.return_value =
# 'filename={}.gz'.format('TEST.fits')
# # response.raw.read.side_effect = file_chunks
# # response.history = []
# # response.status_code = 200
Expand Down
2 changes: 1 addition & 1 deletion caom2repo/caom2repo/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
'vos://cadc.nrc.ca~vospace/CADC/std/CAOM2Repository#obs-1.1'

# resource ID for info
DEFAULT_RESOURCE_ID = 'ivo://cadc.nrc.ca/caom2repo'
DEFAULT_RESOURCE_ID = 'ivo://cadc.nrc.ca/ams'
APP_NAME = 'caom2repo'


Expand Down
3 changes: 1 addition & 2 deletions caom2repo/caom2repo/tests/data/create_help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ optional arguments:
netrc file to use for authentication
-q, --quiet run quietly
--resource-id RESOURCE_ID
resource identifier (default
ivo://cadc.nrc.ca/caom2repo)
resource identifier (default ivo://cadc.nrc.ca/ams)
-u, --user USER name of user to authenticate. Note: application
prompts for the corresponding password!
-v, --verbose verbose messages
3 changes: 1 addition & 2 deletions caom2repo/caom2repo/tests/data/delete_help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ optional arguments:
netrc file to use for authentication
-q, --quiet run quietly
--resource-id RESOURCE_ID
resource identifier (default
ivo://cadc.nrc.ca/caom2repo)
resource identifier (default ivo://cadc.nrc.ca/ams)
-u, --user USER name of user to authenticate. Note: application
prompts for the corresponding password!
-v, --verbose verbose messages
3 changes: 1 addition & 2 deletions caom2repo/caom2repo/tests/data/read_help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ optional arguments:
--output, -o OUTPUT destination file
-q, --quiet run quietly
--resource-id RESOURCE_ID
resource identifier (default
ivo://cadc.nrc.ca/caom2repo)
resource identifier (default ivo://cadc.nrc.ca/ams)
-u, --user USER name of user to authenticate. Note: application
prompts for the corresponding password!
-v, --verbose verbose messages
3 changes: 1 addition & 2 deletions caom2repo/caom2repo/tests/data/update_help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ optional arguments:
netrc file to use for authentication
-q, --quiet run quietly
--resource-id RESOURCE_ID
resource identifier (default
ivo://cadc.nrc.ca/caom2repo)
resource identifier (default ivo://cadc.nrc.ca/ams)
-u, --user USER name of user to authenticate. Note: application
prompts for the corresponding password!
-v, --verbose verbose messages
3 changes: 1 addition & 2 deletions caom2repo/caom2repo/tests/data/visit_help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ optional arguments:
--plugin PLUGIN plugin class to update each observation
-q, --quiet run quietly
--resource-id RESOURCE_ID
resource identifier (default
ivo://cadc.nrc.ca/caom2repo)
resource identifier (default ivo://cadc.nrc.ca/ams)
--start START earliest observation to visit (UTC IVOA format: YYYY-
mm-ddTH:M:S)
--threads {2,3,4,5,6,7,8,9}
Expand Down
4 changes: 2 additions & 2 deletions caom2repo/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ license = AGPLv3
url = http://www.cadc-ccda.hia-iha.nrc-cnrc.gc.ca/caom2
edit_on_github = False
github_project = opencadc/caom2tools
install_requires = cadcutils>=1.1.9 caom2>=2.3.6
install_requires = cadcutils>=1.1.11 caom2>=2.3.6
# version should be PEP386 compatible (http://www.python.org/dev/peps/pep-0386)
version = 1.4.2
version = 1.4.3



Expand Down
10 changes: 4 additions & 6 deletions caom2utils/caom2utils/fits2caom2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1558,9 +1558,6 @@ def _to_enum_type(self, value, to_enum_type):

def _apply_blueprint_to_generic(self):

# pointers that are short to type
exts = self.blueprint._extensions
wcs_std = self.blueprint._wcs_std
plan = self.blueprint._plan

# first apply the functions
Expand Down Expand Up @@ -2431,7 +2428,8 @@ def _get_proposal(self, current):
if current is None:
prop_id = self._get_from_list('Observation.proposal.id', index=0)
pi = self._get_from_list('Observation.proposal.pi', index=0)
project = self._get_from_list('Observation.proposal.project', index=0)
project = self._get_from_list('Observation.proposal.project',
index=0)
title = self._get_from_list('Observation.proposal.title', index=0)
else:
prop_id = self._get_from_list('Observation.proposal.id', index=0,
Expand Down Expand Up @@ -2526,8 +2524,8 @@ def _get_telescope(self, current):
geo_z = _to_float(
self._get_from_list('Observation.telescope.geoLocationZ',
index=0, current=current.geo_location_z))
keywords = self._get_set_from_list('Observation.telescope.keywords',
index=0) # TODO
keywords = self._get_set_from_list(
'Observation.telescope.keywords', index=0) # TODO
if keywords is None:
keywords = current.keywords
self.logger.debug('End Telescope augmentation.')
Expand Down
2 changes: 2 additions & 0 deletions caom2utils/caom2utils/tests/data/text.override
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
artifact.productType = thumbnail
plane.dataProductType = image
plane.calibrationLevel = 3
8 changes: 5 additions & 3 deletions caom2utils/caom2utils/tests/test_fits2caom2.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
from caom2 import get_differences, obs_reader_writer, ObservationReader, Chunk
from caom2 import SpectralWCS, TemporalWCS, PolarizationWCS, SpatialWCS
from caom2 import Axis, CoordAxis1D, CoordAxis2D
import logging

import caom2utils

Expand Down Expand Up @@ -946,6 +947,8 @@ def _get_obs(from_xml_string):
<caom2:planes>
<caom2:plane caom2:id="00000000-0000-0000-8ffa-fc0a5a8759df">
<caom2:productID>test_product_id</caom2:productID>
<caom2:dataProductType>image</caom2:dataProductType>
<caom2:calibrationLevel>3</caom2:calibrationLevel>
<caom2:artifacts>
<caom2:artifact caom2:id="00000000-0000-0000-8ffa-fc0a5a8759df">
<caom2:productType>thumbnail</caom2:productType>
Expand Down Expand Up @@ -1248,16 +1251,15 @@ def test_get_vos_meta():


@pytest.mark.skipif(single_test, reason='Single test mode')
def test_generic_parser():
def test_generic_parser1():
test_key = 'Plane.metaRelease'
test_value = '2013-10-10'
test_blueprint = ObsBlueprint()
test_blueprint.set(test_key, '2013-10-10')
import logging
logging.error(test_blueprint)
test_parser = GenericParser()
assert test_parser._blueprint._plan[test_key] == \
(['RELEASE', 'REL_DATE'], None), 'default value changed'
(['RELEASE', 'REL_DATE'], None), 'default value changed'
test_parser.blueprint = test_blueprint
assert test_parser._blueprint._plan[test_key] == test_value, \
'original value over-ridden'
Expand Down

0 comments on commit 2e1fca7

Please sign in to comment.