Skip to content

Commit

Permalink
Try to fix CI (#162)
Browse files Browse the repository at this point in the history
* Removed 2.7 code
  • Loading branch information
Adrian committed Dec 21, 2022
1 parent 1a164c9 commit cedf448
Show file tree
Hide file tree
Showing 47 changed files with 109 additions and 448 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/cibuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: "3.10"
- name: Install tox
run: python -m pip install --upgrade tox
- name: egg-info caom2
Expand All @@ -41,8 +41,12 @@ jobs:
strategy:
fail-fast: true
matrix:
python-version: ["3.6","3.7","3.8","3.9","3.10"]
python-version: ["3.7","3.8","3.9","3.10", "3.11"]
package: [caom2, caom2utils, caom2repo]
exclude:
# temporary since hdf5 is not working yet
- python-version: "3.11"
package: caom2utils
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand All @@ -67,10 +71,10 @@ jobs:
needs: tests
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: "3.10"
- name: Setup Graphviz
uses: ts-graphviz/setup-graphviz@v1
- name: Install tox
Expand Down
3 changes: 0 additions & 3 deletions caom2/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ To create a minimal Simple Observation

.. code:: python
# make it compatible with Python 2 and 3
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import sys
from caom2 import SimpleObservation, TypedOrderedDict, Plane, Artifact,\
Part, Chunk, ObservationWriter, ProductType,\
Expand Down
9 changes: 2 additions & 7 deletions caom2/caom2/artifact.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# -*- coding: utf-8 -*-
# ***********************************************************************
# ****************** CANADIAN ASTRONOMY DATA CENTRE *******************
# ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES **************
#
# (c) 2016. (c) 2016.
# (c) 2022. (c) 2022.
# Government of Canada Gouvernement du Canada
# National Research Council Conseil national de recherches
# Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6
Expand Down Expand Up @@ -71,12 +70,8 @@
"""

from __future__ import (absolute_import, division, print_function,
unicode_literals)


from builtins import str, int
from six.moves.urllib.parse import urlparse
from urllib.parse import urlparse

from . import caom_util
from .chunk import ProductType
Expand Down
14 changes: 4 additions & 10 deletions caom2/caom2/caom_util.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# ***********************************************************************
# ****************** CANADIAN ASTRONOMY DATA CENTRE *******************
# ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES **************
Expand Down Expand Up @@ -76,16 +75,11 @@
engineer get the correct meta data more quickly.
"""

from __future__ import (absolute_import, division, print_function,
unicode_literals)

import sys
import collections
from datetime import datetime

import six
from six.moves import collections_abc
from six.moves.urllib.parse import urlsplit
from urllib.parse import urlsplit
from builtins import int, str as newstr


Expand Down Expand Up @@ -267,7 +261,7 @@ def key_type(self):
return self._oktypes


class TypedSet(collections_abc.MutableSet):
class TypedSet(collections.abc.MutableSet):
"""
Class that implements a typed set in Python. Supported types
are specified when instance is created. Example:
Expand Down Expand Up @@ -402,12 +396,12 @@ def __init__(self, key_type=None, *args):

def __str__(self):
return "\n".join(["{} => {}".format(k, v)
for k, v in six.iteritems(self)])
for k, v in self.items()])

def __repr__(self):
return "TypedOrderedDict((%r))," % self._oktypes + (
"(".join(
["(%r,%r)" % (k, v) for k, v in six.iteritems(self)]) + ")")
["(%r,%r)" % (k, v) for k, v in self.items()]) + ")")

def check(self, key, value):
"""
Expand Down
5 changes: 1 addition & 4 deletions caom2/caom2/checksum.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# -*- coding: utf-8 -*-
# ***********************************************************************
# ****************** CANADIAN ASTRONOMY DATA CENTRE *******************
# ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES **************
#
# (c) 2017. (c) 2017.
# (c) 2022. (c) 2022.
# Government of Canada Gouvernement du Canada
# National Research Council Conseil national de recherches
# Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6
Expand Down Expand Up @@ -66,8 +65,6 @@
#
# ***********************************************************************
#
from __future__ import (absolute_import, division, print_function,
unicode_literals)

import hashlib
import logging
Expand Down
8 changes: 1 addition & 7 deletions caom2/caom2/chunk.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# -*- coding: utf-8 -*-
# ***********************************************************************
# ****************** CANADIAN ASTRONOMY DATA CENTRE *******************
# ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES **************
#
# (c) 2019. (c) 2019.
# (c) 2022. (c) 2022.
# Government of Canada Gouvernement du Canada
# National Research Council Conseil national de recherches
# Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6
Expand Down Expand Up @@ -71,8 +70,6 @@
"""

from __future__ import (absolute_import, division, print_function,
unicode_literals)

from builtins import str

Expand All @@ -98,9 +95,6 @@ class ProductType(OrderedEnum):
FLAT: "flat"
WAVECAL: "wavecal"
"""
# __order__ required for Python2.7
__order__ = "SCIENCE CALIBRATION PREVIEW INFO NOISE WEIGHT AUXILIARY " \
"THUMBNAIL BIAS DARK FLAT WAVECAL"
SCIENCE = "science"
CALIBRATION = "calibration"
PREVIEW = "preview"
Expand Down
21 changes: 5 additions & 16 deletions caom2/caom2/common.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# -*- coding: utf-8 -*-
# ***********************************************************************
# ****************** CANADIAN ASTRONOMY DATA CENTRE *******************
# ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES **************
#
# (c) 2016. (c) 2016.
# (c) 2022. (c) 2022.
# Government of Canada Gouvernement du Canada
# National Research Council Conseil national de recherches
# Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6
Expand Down Expand Up @@ -67,17 +66,13 @@
# ***********************************************************************
#

from __future__ import (absolute_import, division, print_function,
unicode_literals)

import inspect
import uuid
from datetime import datetime

from builtins import int, str
from six.moves.urllib.parse import SplitResult, urlparse, urlsplit
from urllib.parse import SplitResult, urlparse, urlsplit
import logging
import six

from . import caom_util
import warnings
Expand Down Expand Up @@ -110,7 +105,7 @@ class OrderedEnum(Enum):
"""
Enums are in the order of their definition.
This is here just for Python2.7 and to work with aenum.
TODO: not sure this is required in Python 3
enum.Enum is supposed to support this.
"""

Expand Down Expand Up @@ -148,10 +143,7 @@ def __init__(self):
pass

def __str__(self):
if six.PY3:
args = inspect.getfullargspec(self.__init__).args[1:]
else:
args = inspect.getargspec(self.__init__).args[1:]
args = inspect.getfullargspec(self.__init__).args[1:]
class_name = self.__class__.__name__
return "\n".join(["{}.{} : {}".
format(class_name, arg, getattr(self, arg, None))
Expand All @@ -164,10 +156,7 @@ def __eq__(self, other):
return False

def __repr__(self):
if six.PY3:
args = inspect.getfullargspec(self.__init__).args[1:]
else:
args = inspect.getargspec(self.__init__).args[1:]
args = inspect.getfullargspec(self.__init__).args[1:]
class_name = ""
if self.__class__.__module__ != '__main__':
class_name += self.__class__.__module__ + "."
Expand Down
6 changes: 1 addition & 5 deletions caom2/caom2/diff.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# -*- coding: utf-8 -*-
# ***********************************************************************
# ****************** CANADIAN ASTRONOMY DATA CENTRE *******************
# ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES **************
#
# (c) 2018. (c) 2018.
# (c) 2022. (c) 2022.
# Government of Canada Gouvernement du Canada
# National Research Council Conseil national de recherches
# Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6
Expand Down Expand Up @@ -72,9 +71,6 @@
"""

from __future__ import (absolute_import, division, print_function,
unicode_literals)

import math

from caom2.common import CaomObject
Expand Down
16 changes: 5 additions & 11 deletions caom2/caom2/obs_reader_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# ****************** CANADIAN ASTRONOMY DATA CENTRE *******************
# ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES **************
#
# (c) 2016. (c) 2016.
# (c) 2022. (c) 2022.
# Government of Canada Gouvernement du Canada
# National Research Council Conseil national de recherches
# Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6
Expand Down Expand Up @@ -70,14 +70,10 @@

""" Defines ObservationReader class """

from __future__ import (absolute_import, division, print_function,
unicode_literals)

import os
import uuid
from builtins import str, int
import six
from six.moves.urllib.parse import urlparse
from urllib.parse import urlparse

from lxml import etree

Expand Down Expand Up @@ -2039,7 +2035,7 @@ def _add_planes_element(self, planes, parent):
return

element = self._get_caom_element("planes", parent)
for _plane in six.itervalues(planes):
for _plane in planes.values():
plane_element = self._get_caom_element("plane", element)
self._add_entity_attributes(_plane, plane_element)
self._add_element("productID", _plane.product_id, plane_element)
Expand Down Expand Up @@ -2297,7 +2293,7 @@ def _add_artifacts_element(self, artifacts, parent):
return

element = self._get_caom_element("artifacts", parent)
for _artifact in six.itervalues(artifacts):
for _artifact in artifacts.values():
artifact_element = self._get_caom_element("artifact", element)
self._add_entity_attributes(_artifact, artifact_element)
self._add_element("uri", _artifact.uri, artifact_element)
Expand Down Expand Up @@ -2335,7 +2331,7 @@ def _add_parts_element(self, parts, parent):
return

element = self._get_caom_element("parts", parent)
for _part in six.itervalues(parts):
for _part in parts.values():
part_element = self._get_caom_element("part", element)
self._add_entity_attributes(_part, part_element)
self._add_element("name", _part.name, part_element)
Expand Down Expand Up @@ -2680,8 +2676,6 @@ def _add_element(self, name, value, parent):
element.text = value
else:
if isinstance(value, float):
# in Python 2.7 str(float) might alter precision of float
# therefore call repr instead
element.text = repr(value)
else:
element.text = str(value)
Expand Down
13 changes: 3 additions & 10 deletions caom2/caom2/observation.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# -*- coding: utf-8 -*-
# ***********************************************************************
# ****************** CANADIAN ASTRONOMY DATA CENTRE *******************
# ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES **************
#
# (c) 2016. (c) 2016.
# (c) 2022. (c) 2022.
# Government of Canada Gouvernement du Canada
# National Research Council Conseil national de recherches
# Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6
Expand Down Expand Up @@ -69,12 +68,8 @@

"""definition of the caom2.Observation object."""

from __future__ import (absolute_import, division, print_function,
unicode_literals)

from datetime import datetime

import six
from builtins import str
import warnings
from deprecated import deprecated
Expand All @@ -86,7 +81,7 @@
from .common import _CAOM_VOCAB_NS
from .plane import Plane
from .shape import Point
from six.moves.urllib.parse import urlsplit
from urllib.parse import urlsplit
with warnings.catch_warnings():
warnings.simplefilter('ignore')
from aenum import Enum
Expand All @@ -103,8 +98,6 @@ class ObservationIntentType(OrderedEnum):
CALIBRATION: "calibration"
SCIENCE: "science"
"""
# __order__ required for Python2.7
__order__ = "SCIENCE CALIBRATION"
SCIENCE = "science"
CALIBRATION = "calibration"

Expand Down Expand Up @@ -506,7 +499,7 @@ def __init__(self, name):
simple observation, otherwise name of algorithm that selected
composite members or just 'composite' works too.
"""
caom_util.type_check(name, six.text_type, 'name', override=False)
caom_util.type_check(name, str, 'name', override=False)
self._name = str(name)

def _key(self):
Expand Down
6 changes: 1 addition & 5 deletions caom2/caom2/part.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# -*- coding: utf-8 -*-
# ***********************************************************************
# ****************** CANADIAN ASTRONOMY DATA CENTRE *******************
# ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES **************
#
# (c) 2016. (c) 2016.
# (c) 2022. (c) 2022.
# Government of Canada Gouvernement du Canada
# National Research Council Conseil national de recherches
# Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6
Expand Down Expand Up @@ -70,9 +69,6 @@
"""Defines the caom2.Part class which describes
the caom2_Observation_Plane_Artifact_Part object."""

from __future__ import (absolute_import, division, print_function,
unicode_literals)

from builtins import str

from . import caom_util
Expand Down
Loading

0 comments on commit cedf448

Please sign in to comment.