Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 76 additions & 10 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,49 @@ name: Pre-commit actions for Delphix Virtualization SDK
on: [pull_request]

jobs:
pytest:
name: Test ${{ matrix.package }} on ${{ matrix.os }} using pytest
pytest27:
name: Test ${{ matrix.package }} on ${{ matrix.os }} using pytest (Python 2.7)
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 4
matrix:
python-version: [2.7]
os: [ubuntu-latest, macos-latest, windows-latest]
package: [common, libs, platform]

steps:
- name: Checkout ${{ matrix.package }} project
uses: actions/checkout@v1

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}

- name: Install ${{ matrix.package }} dependencies
working-directory: ${{ matrix.package }}
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt --find-links https://test.pypi.org/simple/dvp-api/

- name: Install ${{ matrix.package }} project
working-directory: ${{ matrix.package }}
run: |
pip install . --find-links https://test.pypi.org/simple/dvp-api/

- name: Test ${{ matrix.package }} project with pytest
working-directory: ${{ matrix.package }}
run: |
python -m pytest src/test/python

pytest38:
name: Test ${{ matrix.package }} on ${{ matrix.os }} using pytest (Python 3.8)
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 4
matrix:
python-version: [3.8]
os: [ubuntu-latest, macos-latest, windows-latest]
package: [common, libs, platform, tools]

steps:
Expand Down Expand Up @@ -38,33 +73,64 @@ jobs:
run: |
python -m pytest src/test/python

lint:
name: Lint ${{ matrix.package }}
lintpython27:
name: Lint ${{ matrix.package }} - Python27

runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
package: [tools]
package: [common, libs, platform]

steps:
- name: Checkout ${{ matrix.package }}
uses: actions/checkout@v1

- name: Set up Python 2.7
uses: actions/setup-python@v1
with:
python-version: 2.7

- name: Install flake8
run: |
python -m pip install --upgrade pip
pip install flake8

- name: Run flake8 on src directory
working-directory: ${{ matrix.package }}
run: python -m flake8 src/main/python --max-line-length 88


- name: Run flake8 on test directory
working-directory: ${{ matrix.package }}
run: python -m flake8 src/test/python --max-line-length 88

lintpython38:
name: Lint ${{ matrix.package }} - Python38

runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
package: [common, libs, platform, tools]

steps:
- name: Checkout ${{ matrix.package }}
uses: actions/checkout@v1

- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8

- name: Install flake8
run: |
python -m pip install --upgrade pip
pip install flake8

- name: Run flake8 on src directory
working-directory: ${{ matrix.package }}
run: python -m flake8 src/main/python --max-line-length 88

- name: Run flake8 on test directory
working-directory: ${{ matrix.package }}
run: python -m flake8 src/test/python --max-line-length 88
Expand Down
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2019 by Delphix. All rights reserved.
# Copyright (c) 2019, 2021 by Delphix. All rights reserved.
#

# IntelliJ config files
Expand Down Expand Up @@ -35,3 +35,8 @@ venv/
# Python cache
__pycache__

# .python-version files
*.python-version

# OSX DS Store files
*.DS_Store
1 change: 0 additions & 1 deletion common/.python-version

This file was deleted.

19 changes: 10 additions & 9 deletions common/setup.cfg
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
#
# Copyright (c) 2019 by Delphix. All rights reserved.
# Copyright (c) 2019, 2021 by Delphix. All rights reserved.
#

[metadata]
Metadata-Version: 1.2
Author: Delphix
Author-email: [email protected]
Home-page: https://developer.delphix.com
Long-description: file: README.md
Long-description-content-type: text/markdown
Classifiers:
metadata_version: 1.2
author: Delphix
author_email: [email protected]
home_page: https://developer.delphix.com
long_description: file: README.md
long_description_content_type: text/markdown
classifiers:
Development Status :: 5 - Production/Stable
Programming Language :: Python
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3.8
License :: OSI Approved :: Apache Software License
Operating System :: OS Independent

[options]
Requires-Python: 2.7
requires_python: >=2.7, <=3.8, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, !=3.6.*, !=3.7.*
1 change: 1 addition & 0 deletions common/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
install_requires=install_requires,
package_dir={'': PYTHON_SRC},
packages=setuptools.find_packages(PYTHON_SRC),
python_requires='>=2.7, <3.9, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, !=3.6.*, !=3.7.*',
)
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# Copyright (c) 2019 by Delphix. All rights reserved.
# Copyright (c) 2019, 2021 by Delphix. All rights reserved.
#

__path__ = __import__('pkgutil').extend_path(__path__, __name__)

from dlpx.virtualization.common._common_classes import *
from dlpx.virtualization.common._common_classes import * # noqa
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2019 by Delphix. All rights reserved.
# Copyright (c) 2019, 2021 by Delphix. All rights reserved.
#

from abc import ABCMeta
Expand Down Expand Up @@ -134,7 +134,9 @@ def reference(self):
return self.__reference

def to_proto(self):
"""Converts plugin class RemoteEnvironment to protobuf class common_pb2.RemoteEnvironment
"""
Converts plugin class RemoteEnvironment to protobuf
class common_pb2.RemoteEnvironment
"""
remote_environment = common_pb2.RemoteEnvironment()
remote_environment.name = self.name
Expand All @@ -144,7 +146,9 @@ def to_proto(self):

@staticmethod
def from_proto(environment):
"""Converts protobuf class common_pb2.RemoteEnvironment to plugin class RemoteEnvironment
"""
Converts protobuf class common_pb2.RemoteEnvironment to plugin
class RemoteEnvironment
"""
if not isinstance(environment, common_pb2.RemoteEnvironment):
raise IncorrectTypeError(
Expand Down Expand Up @@ -353,7 +357,9 @@ def password(self):

@staticmethod
def from_proto(credentials_result):
"""Converts protobuf class libs_pb2.CredentialsResult to plugin class PasswordCredentials
"""
Converts protobuf class libs_pb2.CredentialsResult to plugin
class PasswordCredentials
"""
if not isinstance(credentials_result, libs_pb2.CredentialsResult):
raise IncorrectTypeError(
Expand All @@ -375,7 +381,8 @@ class KeyPairCredentials(Credentials):
Args:
username (str): User name.
private_key (str): Private key.
public_key (str): Public key corresponding to private key. Empty string if not present.
public_key (str): Public key corresponding to private key. Empty string if
not present.
"""
def __init__(self, username, private_key, public_key):
super(KeyPairCredentials, self).__init__(username)
Expand Down
19 changes: 8 additions & 11 deletions common/src/main/python/dlpx/virtualization/common/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2019 by Delphix. All rights reserved.
# Copyright (c) 2019, 2021 by Delphix. All rights reserved.
#


Expand Down Expand Up @@ -104,7 +104,8 @@ def _get_type_name(type_object):
if len(expected_type) > 1:
for index in range(0, len(expected_type)):
expected_type[index] = _get_type_name(expected_type[index])
expected_type[index] = _remove_angle_brackets(str(expected_type[index]))
expected_type[index] = _remove_angle_brackets(
str(expected_type[index]))

expected = "any one of the following types: '{}'".format(expected_type)
elif len(expected_type) == 0:
Expand All @@ -120,8 +121,8 @@ def _get_type_name(type_object):
raise PlatformError('The thrown TypeError should have had a'
' dict of size 1 as the expected_type')

key_type = expected_type.keys()[0]
value_type = expected_type.values()[0]
key_type = list(expected_type.keys())[0]
value_type = list(expected_type.values())[0]

key_type_name = _get_type_name(key_type)
value_type_name = _get_type_name(value_type)
Expand All @@ -147,7 +148,7 @@ def _get_type_name(type_object):
raise PlatformError('The thrown TypeError should have had a'
' set of tuples to represent a dict')
actual = 'a dict of {{{}}}'.format(', '.join(['{0}:{1}'.format(
_remove_angle_brackets(str(k)),
_remove_angle_brackets(str(k)),
_remove_angle_brackets(str(v))) for k, v in actual_type]))
else:
actual = _remove_angle_brackets(str(actual_type))
Expand All @@ -172,12 +173,8 @@ class IncorrectTypeError(PluginRuntimeError):
"""

def __init__(
self,
object_type,
parameter_name,
actual_type,
expected_type,
required=True):
self, object_type, parameter_name, actual_type, expected_type,
required=True):
actual, expected = self.get_actual_and_expected_type(
actual_type, expected_type)

Expand Down
Loading