Skip to content

Commit

Permalink
chore: rename to
Browse files Browse the repository at this point in the history
  • Loading branch information
JaeAeich committed May 18, 2024
1 parent 2da83fb commit b6d3e27
Show file tree
Hide file tree
Showing 35 changed files with 92 additions and 92 deletions.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ classifiers = [
]

[tool.poetry.scripts]
filer = 'tesk.service.filer:main'
taskmaster = 'tesk.service.taskmaster:main'
filer = 'tesk.services.filer:main'
taskmaster = 'tesk.services.taskmaster:main'

[tool.poetry.dependencies]
python = "^3.11"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions tesk/service/filer.py → tesk/services/filer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@

import requests

from tesk.service.constants import TIMEOUT
from tesk.service.exceptions import (
from tesk.services.constants import TIMEOUT
from tesk.services.exceptions import (
FileProtocolDisabled,
ServiceStatusCodes,
UnknownProtocol,
)
from tesk.service.filer_s3 import S3Transput
from tesk.service.path import containerPath, fileEnabled, getPath
from tesk.service.transput import Transput, Type, urlparse
from tesk.services.filer_s3 import S3Transput
from tesk.services.path import containerPath, fileEnabled, getPath
from tesk.services.transput import Transput, Type, urlparse


class HTTPTransput(Transput):
Expand Down
4 changes: 2 additions & 2 deletions tesk/service/filer_class.py → tesk/services/filer_class.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json

from tesk.service import path
from tesk.service.path import fileEnabled
from tesk.services import path
from tesk.services.path import fileEnabled


class Filer:
Expand Down
2 changes: 1 addition & 1 deletion tesk/service/filer_s3.py → tesk/services/filer_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import boto3
import botocore

from tesk.service.transput import Transput, Type
from tesk.services.transput import Transput, Type


class S3Transput(Transput):
Expand Down
4 changes: 2 additions & 2 deletions tesk/service/job.py → tesk/services/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from kubernetes import client
from kubernetes.client.exceptions import ApiException

from tesk.service.exceptions import ServiceStatusCodes
from tesk.service.utils import pprint
from tesk.services.exceptions import ServiceStatusCodes
from tesk.services.utils import pprint

logging.basicConfig(format='%(message)s', level=logging.INFO)

Expand Down
2 changes: 1 addition & 1 deletion tesk/service/path.py → tesk/services/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from os.path import relpath
from urllib.parse import urlparse

from tesk.service.exceptions import InvalidHostPath
from tesk.services.exceptions import InvalidHostPath


def getEnv(varName):
Expand Down
4 changes: 2 additions & 2 deletions tesk/service/pvc.py → tesk/services/pvc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from kubernetes import client
from kubernetes.client.exceptions import ApiException

from tesk.service.exceptions import ServiceStatusCodes
from tesk.service.utils import pprint
from tesk.services.exceptions import ServiceStatusCodes
from tesk.services.utils import pprint


class PVC:
Expand Down
6 changes: 3 additions & 3 deletions tesk/service/taskmaster.py → tesk/services/taskmaster.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

from kubernetes import config

from tesk.service.filer_class import Filer
from tesk.service.job import Job
from tesk.service.pvc import PVC
from tesk.services.filer_class import Filer
from tesk.services.job import Job
from tesk.services.pvc import PVC

created_jobs = []
poll_interval = 5
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import os
import unittest

from tesk.service import path
from tesk.service.filer_class import Filer
from tesk.service.utils import pprint
from tesk.services import path
from tesk.services.filer_class import Filer
from tesk.services.utils import pprint

try:
from unittest.mock import patch # Python 3 @UnresolvedImport
except ImportError:
from unittest.mock import patch


@patch('tesk.service.path.HOST_BASE_PATH', '/home/tfga/workspace/cwl-tes')
@patch('tesk.service.path.CONTAINER_BASE_PATH', '/transfer')
@patch('tesk.service.path.TRANSFER_PVC_NAME', 'transfer-pvc')
@patch('tesk.services.path.HOST_BASE_PATH', '/home/tfga/workspace/cwl-tes')
@patch('tesk.services.path.CONTAINER_BASE_PATH', '/transfer')
@patch('tesk.services.path.TRANSFER_PVC_NAME', 'transfer-pvc')
@patch.dict(
os.environ,
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from argparse import Namespace
from unittest.mock import patch

from tesk.service.taskmaster import newLogger, newParser, run_task
from tesk.services.taskmaster import newLogger, newParser, run_task


def pvcCreateMock(self):
Expand Down Expand Up @@ -74,13 +74,13 @@ def test_pullPolicyAlways(self):
)

@patch(
'tesk.service.taskmaster.args',
'tesk.services.taskmaster.args',
Namespace(debug=True, namespace='default', pull_policy_always=True),
)
@patch('tesk.service.taskmaster.logger', newLogger(logging.DEBUG))
@patch('tesk.service.taskmaster.PVC.create', pvcCreateMock)
@patch('tesk.service.taskmaster.PVC.delete', pvcDeleteMock)
@patch('tesk.service.taskmaster.Job.run_to_completion', jobRunToCompletionMock)
@patch('tesk.services.taskmaster.logger', newLogger(logging.DEBUG))
@patch('tesk.services.taskmaster.PVC.create', pvcCreateMock)
@patch('tesk.services.taskmaster.PVC.delete', pvcDeleteMock)
@patch('tesk.services.taskmaster.Job.run_to_completion', jobRunToCompletionMock)
def test_run_task(self):
with open('tests/resources/inputFile.json') as fh:
data = json.load(fh)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

from fs.opener import open_fs

from tesk.service.exceptions import (
from tesk.services.exceptions import (
FileProtocolDisabled,
InvalidHostPath,
UnknownProtocol,
)
from tesk.service.filer import (
from tesk.services.filer import (
FileTransput,
FTPTransput,
HTTPTransput,
Expand All @@ -23,9 +23,9 @@
process_file,
subfolders_in,
)
from tesk.service.filer_s3 import S3Transput
from tesk.service.path import containerPath
from tests.test_unit.test_service.assertThrows import AssertThrowsMixin
from tesk.services.filer_s3 import S3Transput
from tesk.services.path import containerPath
from tests.test_unit.test_services.assertThrows import AssertThrowsMixin


def getTree(rootDir):
Expand All @@ -41,15 +41,15 @@ def stripLines(txt):
return '\n'.join([line.strip() for line in txt.splitlines()[1:]])


@patch('tesk.service.path.HOST_BASE_PATH', '/home/tfga/workspace/cwl-tes')
@patch('tesk.service.path.CONTAINER_BASE_PATH', '/transfer')
@patch('tesk.services.path.HOST_BASE_PATH', '/home/tfga/workspace/cwl-tes')
@patch('tesk.services.path.CONTAINER_BASE_PATH', '/transfer')
class FilerTest(unittest.TestCase, AssertThrowsMixin):
@classmethod
def setUpClass(cls):
logConfig(logging.DEBUG) # Doesn't work...

@patch('tesk.service.filer.copyDir')
@patch('tesk.service.filer.shutil.copy')
@patch('tesk.services.filer.copyDir')
@patch('tesk.services.filer.shutil.copy')
def test_download_file(self, copyMock, copyDirMock):
filedata = {
'url': 'file:///home/tfga/workspace/cwl-tes/tmphrtip1o8/md5',
Expand All @@ -69,8 +69,8 @@ def test_download_file(self, copyMock, copyDirMock):
'/var/lib/cwl/stgda974802-fa81-4f0b-' '8fe4-341d5655af4b/md5',
)

@patch('tesk.service.filer.copyDir')
@patch('tesk.service.filer.shutil.copy')
@patch('tesk.services.filer.copyDir')
@patch('tesk.services.filer.shutil.copy')
def test_download_dir(self, copyMock, copyDirMock):
filedata = {
'url': 'file:///home/tfga/workspace/cwl-tes/tmphrtip1o8/',
Expand All @@ -85,8 +85,8 @@ def test_download_dir(self, copyMock, copyDirMock):

copyDirMock.assert_called_once_with('/transfer/tmphrtip1o8', '/TclSZU')

@patch('tesk.service.filer.copyDir')
@patch('tesk.service.filer.shutil.copy')
@patch('tesk.services.filer.copyDir')
@patch('tesk.services.filer.shutil.copy')
def test_upload_dir(self, copyMock, copyDirMock):
filedata = {
'url': 'file:///home/tfga/workspace/cwl-tes/tmphrtip1o8/',
Expand All @@ -101,8 +101,8 @@ def test_upload_dir(self, copyMock, copyDirMock):

copyDirMock.assert_called_once_with('/TclSZU', '/transfer/tmphrtip1o8')

@patch('tesk.service.filer.copyDir')
@patch('tesk.service.filer.copyFile')
@patch('tesk.services.filer.copyDir')
@patch('tesk.services.filer.copyFile')
def test_upload_file(self, copyFileMock, copyDirMock):
filedata = {
'url': 'file:///home/tfga/workspace/cwl-tes/tmphrtip1o8/md5',
Expand All @@ -117,8 +117,8 @@ def test_upload_file(self, copyFileMock, copyDirMock):

copyFileMock.assert_called_once_with('/TclSZU/md5', '/transfer/tmphrtip1o8/md5')

@patch('tesk.service.filer.copyDir')
@patch('tesk.service.filer.copyFile')
@patch('tesk.services.filer.copyDir')
@patch('tesk.services.filer.copyFile')
def test_upload_file_glob(self, copyFileMock, copyDirMock):
filedata = {
'url': 'file:///home/tfga/workspace/cwl-tes/tmphrtip1o8/md5*',
Expand All @@ -139,7 +139,7 @@ def test_copyDir(self):
def rmDir(d):
os.system(f'rm -r {d}')

baseDir = 'tests/test_unit/test_service/resources/copyDirTest/'
baseDir = 'tests/test_unit/test_services/resources/copyDirTest/'
src = os.path.join(baseDir, 'src')
dst1 = os.path.join(baseDir, 'dst1')
dst2 = os.path.join(baseDir, 'dst2')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import os
from unittest import mock

from tesk.service.filer import (
from tesk.services.filer import (
FTPTransput,
Type,
ftp_check_directory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import pytest

from tesk.service.filer import FileProtocolDisabled, copyContent, process_file
from tesk.services.filer import FileProtocolDisabled, copyContent, process_file


def test_process_file_no_scheme(caplog):
Expand All @@ -31,7 +31,7 @@ def test_process_file_with_scheme(mocker):
'path': '.',
'type': 'FILE',
}
mock_new_Trans = mocker.patch('tesk.service.filer.newTransput')
mock_new_Trans = mocker.patch('tesk.services.filer.newTransput')
process_file('inputs', filedata)

mock_new_Trans.assert_called_once_with('http', 'www.foo.bar')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

from requests import Response

from tesk.service.filer import HTTPTransput, Type
from tesk.services.filer import HTTPTransput, Type

PATH_DOWN = 'test_download_file.txt'
PATH_UP = 'tests/test_unit/test_service/test_filer_http_pytest.py'
PATH_UP = 'tests/test_unit/test_services/test_filer_http_pytest.py'
SUCCESS = 200
FAIL = 300
URL = 'http://www.foo.bar'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from dateutil.tz import tzutc
from kubernetes.client.rest import ApiException

from tesk.service import taskmaster
from tesk.service.job import Job
from tesk.services import taskmaster
from tesk.services.job import Job

START_TIME = datetime.datetime.now(timezone.utc)

Expand Down Expand Up @@ -210,7 +210,7 @@ def test_job(self):

@patch('kubernetes.client.BatchV1Api.create_namespaced_job')
@patch(
'tesk.service.job.Job.get_status',
'tesk.services.job.Job.get_status',
side_effect=[
('Running', True),
('Running', True),
Expand All @@ -234,10 +234,10 @@ def test_run_to_completion_success(
)
self.assertEqual(status, 'Complete')

@patch('tesk.service.job.Job.delete')
@patch('tesk.service.taskmaster.check_cancelled', return_value=True)
@patch('tesk.services.job.Job.delete')
@patch('tesk.services.taskmaster.check_cancelled', return_value=True)
@patch('kubernetes.client.BatchV1Api.create_namespaced_job')
@patch('tesk.service.job.Job.get_status', side_effect=[('Running', True)])
@patch('tesk.services.job.Job.get_status', side_effect=[('Running', True)])
def test_run_to_completion_cancelled(
self,
mock_get_status,
Expand All @@ -258,12 +258,12 @@ def test_run_to_completion_cancelled(
)
self.assertEqual(status, 'Cancelled')

@patch('tesk.service.taskmaster.check_cancelled', return_value=False)
@patch('tesk.services.taskmaster.check_cancelled', return_value=False)
@patch(
'kubernetes.client.BatchV1Api.create_namespaced_job',
side_effect=ApiException(status=409, reason='conflict'),
)
@patch('tesk.service.job.Job.get_status', side_effect=[('Complete', True)])
@patch('tesk.services.job.Job.get_status', side_effect=[('Complete', True)])
@patch(
'kubernetes.client.BatchV1Api.read_namespaced_job',
side_effect=read_namespaced_job_running,
Expand Down Expand Up @@ -314,8 +314,8 @@ def test_run_to_completion_check_other_K8_exception(
'kubernetes.client.BatchV1Api.read_namespaced_job',
side_effect=read_namespaced_job_error,
)
@patch('tesk.service.job.Job.delete')
@patch('tesk.service.taskmaster.check_cancelled', return_value=False)
@patch('tesk.services.job.Job.delete')
@patch('tesk.services.taskmaster.check_cancelled', return_value=False)
@patch('kubernetes.client.BatchV1Api.create_namespaced_job')
def test_run_to_completion_error( # noqa: PLR0913
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import boto3
import pytest

# from tesk.service.extract_endpoint import extract_endpoint
# from tesk.services.extract_endpoint import extract_endpoint
from moto import mock_aws

from tesk.service.filer_s3 import S3Transput
from tesk.services.filer_s3 import S3Transput


@pytest.fixture()
Expand Down Expand Up @@ -71,7 +71,7 @@ def test_check_if_bucket_exists(moto_boto, path, url, ftype, expected):
assert trans.check_if_bucket_exists(client) == expected


# @patch('tesk.service.filer.os.makedirs')
# @patch('tesk.services.filer.os.makedirs')
# @patch('builtins.open')
# @patch('s3transfer.utils.OSUtils.rename_file')
@pytest.mark.parametrize(
Expand All @@ -93,10 +93,10 @@ def test_s3_download_file(moto_boto, path, url, ftype, expected, fs, caplog): #
assert os.path.exists(path) is True


@patch('tesk.service.filer.os.makedirs')
@patch('tesk.services.filer.os.makedirs')
@patch('builtins.open')
@patch('s3transfer.utils.OSUtils.rename_file')
# @patch("tesk.service.filer_s3.extract_endpoint", return_value="http://s3.amazonaws.com")
# @patch("tesk.services.filer_s3.extract_endpoint", return_value="http://s3.amazonaws.com")
@pytest.mark.parametrize(
'path, url, ftype,expected',
[
Expand Down Expand Up @@ -196,7 +196,7 @@ def test_upload_directory_for_unknown_file_type(moto_boto, fs, monkeypatch, capl
assert 'Object is neither file or directory' in caplog.text


@patch('tesk.service.filer.os.path.exists', return_value=1)
@patch('tesk.services.filer.os.path.exists', return_value=1)
def test_extract_url_from_config_file(mock_path_exists):
"""
Testing extraction of endpoint url from default file location
Expand Down
Loading

0 comments on commit b6d3e27

Please sign in to comment.