Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: clean up & refactor majorly #171

Merged
merged 37 commits into from
May 19, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
a56bb15
feat: remove scripts and add then in one place ie Makefile
JaeAeich May 11, 2024
b854244
chore: restructure deployement stuff
JaeAeich May 11, 2024
2dd67a7
chore: rename src to tesk
JaeAeich May 11, 2024
eaa230c
typo
JaeAeich May 11, 2024
aea50bd
restructure tests folder
JaeAeich May 11, 2024
301bb54
rename core to service
JaeAeich May 11, 2024
5ff8a07
refactor makefile command names
JaeAeich May 11, 2024
7ef9206
restructure docs and tests
JaeAeich May 11, 2024
38a0f2c
add poetry and checks
JaeAeich May 11, 2024
5c301d9
add ruff and fix format and lint issues
JaeAeich May 12, 2024
439e9cb
add lint and format in CI and fix some stuff
JaeAeich May 12, 2024
743f073
test command
JaeAeich May 12, 2024
988009b
tests fixed a lil bit
JaeAeich May 12, 2024
e16775a
fix: console script
JaeAeich May 13, 2024
6c9d1be
chore: change dockerfile due to moving to pyproject
JaeAeich May 13, 2024
afc0b94
fix tests a lil more
JaeAeich May 13, 2024
6cedfd5
test: fix S3 filer location constraint
uniqueg May 13, 2024
d4cd1a1
test: fix test file path
uniqueg May 13, 2024
2a0b025
fix tests a lil more, only 2 failing
JaeAeich May 13, 2024
a9cd65a
tests fixed :) locally :(
JaeAeich May 14, 2024
91a9dc0
CI test fix
JaeAeich May 14, 2024
5cd4940
github actions cache, and create dep groups in pyproject for CI
JaeAeich May 14, 2024
166012e
feat: add spell-checker, code-review, fix format of image to oci, and…
JaeAeich May 16, 2024
444d3b3
feat: some CI checks
JaeAeich May 16, 2024
939d48e
fix: sourcery errors
JaeAeich May 18, 2024
868291b
fix: safety errors
JaeAeich May 18, 2024
ce82dbc
fix: bandit errors
JaeAeich May 18, 2024
e5ad07a
fix: mypy errors
JaeAeich May 18, 2024
92fce10
fix: CI
JaeAeich May 18, 2024
2b477d1
fix: remove sourcery because eww
JaeAeich May 18, 2024
2da83fb
chore: minor renaming stuff
JaeAeich May 18, 2024
b6d3e27
chore: rename to
JaeAeich May 18, 2024
9345667
fix: test ci
JaeAeich May 18, 2024
6d73f00
chore: remove coverage report
JaeAeich May 19, 2024
863ec10
chore: remove empty file
JaeAeich May 19, 2024
2dd5fc7
chore: remove helm install from CI
JaeAeich May 19, 2024
46cba22
chore: add badge
JaeAeich May 19, 2024
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
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# TODO: Remove and add in `pyproject.toml`
uniqueg marked this conversation as resolved.
Show resolved Hide resolved
include README.md
75 changes: 75 additions & 0 deletions Makefile
uniqueg marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# TODO: Add commands to be compatible for windows
JaeAeich marked this conversation as resolved.
Show resolved Hide resolved
# TODO: Add commands for tesk_api

# Define variables
PYTHON_CMD := $(shell command -v python3 2> /dev/null)
BUILDAH_CMD := $(shell command -v buildah 2> /dev/null)
DOCKER_CMD := $(shell command -v docker 2> /dev/null)
ELIXIR_CLOUD_REGISTRY := docker.io/elixircloud
DOCKER_FILE_PATH := deployment/containers

# Define arguments
IMAGE ?= filer
TAG ?= testing

# Default target, build image if `make` is called without any arguments
default: build

# Create and activate virtual environment
.PHONY: venv
venv:
@if [ -x "$(PYTHON_CMD)" ]; then \
$(PYTHON_CMD) -m venv .venv; \
echo "Virtual environment created. To activate, run: source .venv/bin/activate"; \
else \
echo "Please install python3 to create virtual environment."; \
exit 1; \
fi

# Remove virtual environment
.PHONY: clean-venv
clean-venv:
rm -rf .venv

# TODO: Install package manages and change the below commands
# Install dependencies
.PHONY: install
install:
@if [ -f .venv/bin/activate ]; then \
pip install .; \
else \
echo "Virtual environment not found. Please create it first using 'make venv'."; \
fi

# Build image
.PHONY: build
build:
@if [ -x "$(BUILDAH_CMD)" ]; then \
$(BUILDAH_CMD) bud \
-t $(ELIXIR_CLOUD_REGISTRY)/tesk-core-$(IMAGE):$(TAG) \
--format=docker \
JaeAeich marked this conversation as resolved.
Show resolved Hide resolved
--no-cache \
-f $(DOCKER_FILE_PATH)/$(IMAGE).Dockerfile; \
elif [ -x "$(DOCKER_CMD)" ]; then \
$(DOCKER_CMD) build \
-t $(ELIXIR_CLOUD_REGISTRY)/tesk-core-$(IMAGE):$(TAG) \
-f $(DOCKER_FILE_PATH)/$(IMAGE).Dockerfile .; \
else \
echo "Please install buildah or docker to build images."; \
exit 1; \
fi

# Run image
.PHONY: run
run:
@if [ -x "$(DOCKER_CMD)" ]; then \
$(DOCKER_CMD) run \
-it --rm $(ELIXIR_CLOUD_REGISTRY)/tesk-core-$(IMAGE):$(TAG); \
else \
echo "Please install docker to run images."; \
exit 1; \
fi

# Clean up built images or other generated artifacts
clean:
docker rmi $(ELIXIR_CLOUD_REGISTRY)/tesk-core-$(IMAGE):$(TAG)
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<img src="documentation/img/TESKlogowfont.png" height="200">
<img src="deployment/documentation/img/TESKlogowfont.png" height="200">

JaeAeich marked this conversation as resolved.
Show resolved Hide resolved

An implementation of a task execution engine based on the [TES standard](https://github.com/ga4gh/task-execution-schemas) running on `Kubernetes`. For more details on `TES`, see the (very) brief [introduction to TES](documentation/tesintro.md).
An implementation of a task execution engine based on the [TES standard](https://github.com/ga4gh/task-execution-schemas) running on `Kubernetes`. For more details on `TES`, see the (very) brief [introduction to TES](deployment/documentation/tesintro.md).

JaeAeich marked this conversation as resolved.
Show resolved Hide resolved
For organisational reasons, this project is split into 3 repositories:
- This one, which contains documentation and deployment files
Expand All @@ -10,15 +10,16 @@ For organisational reasons, this project is split into 3 repositories:

If the API is running on your cluster it will pull the images from our `docker.io` repository automatically.

`TESK` is designed with the goal to support any `Kubernetes` cluster, for its deployment please refer to the [deployment](documentation/deployment.md) page.
`TESK` is designed with the goal to support any `Kubernetes` cluster, for its deployment please refer to the [deployment](deployment/documentation/deployment.md) page.

The technical documentation is available in the [documentation](documentation) folder.
The technical documentation is available in the [documentation](deployment/documentation) folder.


## Architecture
As a diagram:

![TESK architecture](documentation/img/architecture.png)
<!-- TODO: Change the image remove tomcat, change naming etc -->
![TESK architecture](deployment/documentation/img/architecture.png)

**Description**: The first pod in the task lifecycle is the API pod, a pod which runs a web server (`Tomcat`) and exposes the `TES` specified endpoints. It consumes `TES` requests, validates them and translates them to `Kubernetes` jobs. The API pod then creates a `task controller` pod, or `taskmaster`.

Expand All @@ -30,4 +31,4 @@ After the last executor, the `filer` is called once more to process the outputs
- A working [Kubernetes](https://kubernetes.io/) cluster version 1.9 and later.
- If you want TESK to handle tasks with I/O (and you probably want), you additionally need:
- A default storage class, which TESK will use to create temporary PVCs. It is enough that the storage class supports the RWO mode.
- And, if you want TESK to integrate with workflow managers, you additionally need either an FTP account or a PVC that can be accessed from within or from outside of the cluster by the workflow manager (more in the [deployment](documentation/deployment.md) page).
- And, if you want TESK to integrate with workflow managers, you additionally need either an FTP account or a PVC that can be accessed from within or from outside of the cluster by the workflow manager (more in the [deployment](deployment/documentation/deployment.md) page).
6 changes: 0 additions & 6 deletions cloudbuild.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions cloudbuild_testing.yaml

This file was deleted.

JaeAeich marked this conversation as resolved.
Show resolved Hide resolved
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
JaeAeich marked this conversation as resolved.
Show resolved Hide resolved
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
JaeAeich marked this conversation as resolved.
Show resolved Hide resolved
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion dockerBuild

This file was deleted.

1 change: 0 additions & 1 deletion dockerRun

This file was deleted.

8 changes: 0 additions & 8 deletions init

This file was deleted.

4 changes: 0 additions & 4 deletions install

This file was deleted.

1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# TODO: Remove and add in `pyproject.toml`
[pytest]
env =
FTP_USER=user
Expand Down
31 changes: 0 additions & 31 deletions scripts/dockerBuild

This file was deleted.

12 changes: 0 additions & 12 deletions scripts/dockerRun

This file was deleted.

2 changes: 2 additions & 0 deletions scripts/run
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# TODO: Remove once API is stable and tested on cluster.
# This script can also be added to Makefile

#
# Usage:
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# TODO: Remove and add in `pyproject.toml`
[metadata]
description-file=README.md
[aliases]
Expand Down
9 changes: 5 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# TODO: Remove and add in `pyproject.toml`
import codecs
from os import path
from setuptools import setup, find_packages
Expand Down Expand Up @@ -59,13 +60,13 @@
# What does your project relate to?
keywords='tes kubernetes ebi',

packages = find_packages('src'),
package_dir = {'': 'src'},
packages = find_packages('tesk'),
package_dir = {'': 'tesk'},

entry_points={
'console_scripts' : [
'filer = tesk_core.filer:main',
'taskmaster = tesk_core.taskmaster:main'
'filer = service.filer:main',
'taskmaster = service.taskmaster:main'
]
},
test_suite='tests',
Expand Down
4 changes: 2 additions & 2 deletions taskmaster
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# TODO: Add to makefile after undertanding what its doing 😕


PYTHONPATH="src" python src/tesk_core/taskmaster.py "$@"
PYTHONPATH="tesk" python tesk/service/taskmaster.py "$@"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions src/tesk_core/filer.py → tesk/service/filer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
import netrc
import requests
import gzip
from tesk_core.exception import UnknownProtocol, FileProtocolDisabled
from service.exception import UnknownProtocol, FileProtocolDisabled
import shutil
from glob import glob
from tesk_core.path import containerPath, getPath, fileEnabled
from tesk_core.transput import Type, Transput, urlparse
from tesk_core.filer_s3 import S3Transput
from service.path import containerPath, getPath, fileEnabled
from service.transput import Type, Transput, urlparse
from service.filer_s3 import S3Transput



Expand Down
4 changes: 2 additions & 2 deletions src/tesk_core/filer_class.py → tesk/service/filer_class.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
from tesk_core import path
from tesk_core.path import fileEnabled
from service import path
from service.path import fileEnabled


class Filer:
Expand Down
2 changes: 1 addition & 1 deletion src/tesk_core/filer_s3.py → tesk/service/filer_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import re
import botocore
import boto3
from tesk_core.transput import Transput, Type
from service.transput import Transput, Type

class S3Transput(Transput):
def __init__(self, path, url, ftype):
Expand Down
2 changes: 1 addition & 1 deletion src/tesk_core/job.py → tesk/service/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from datetime import datetime, timezone
from kubernetes import client, config
from kubernetes.client.rest import ApiException
from tesk_core.Util import pprint
from service.Util import pprint


logging.basicConfig(format='%(message)s', level=logging.INFO)
Expand Down
2 changes: 1 addition & 1 deletion src/tesk_core/path.py → tesk/service/path.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
from os.path import relpath
from tesk_core.exception import InvalidHostPath
from service.exception import InvalidHostPath
try:
from urllib.parse import urlparse
except ImportError:
Expand Down
2 changes: 1 addition & 1 deletion src/tesk_core/pvc.py → tesk/service/pvc.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from kubernetes import client, config
from kubernetes.client.rest import ApiException
from tesk_core.Util import pprint
from service.Util import pprint
import os
import logging

Expand Down
6 changes: 3 additions & 3 deletions src/tesk_core/taskmaster.py → tesk/service/taskmaster.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import logging
import gzip
from kubernetes import client, config
from tesk_core.job import Job
from tesk_core.pvc import PVC
from tesk_core.filer_class import Filer
from service.job import Job
from service.pvc import PVC
from service.filer_class import Filer

created_jobs = []
poll_interval = 5
Expand Down
File renamed without changes.
JaeAeich marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import unittest
import os
from tesk_core.filer_class import Filer
from tesk_core import path
from tesk_core.Util import pprint
from service.filer_class import Filer
from service import path
from service.Util import pprint

try:
from unittest.mock import patch # Python 3 @UnresolvedImport
Expand All @@ -14,9 +14,9 @@



@patch('tesk_core.path.HOST_BASE_PATH' , '/home/tfga/workspace/cwl-tes')
@patch('tesk_core.path.CONTAINER_BASE_PATH' , '/transfer')
@patch('tesk_core.path.TRANSFER_PVC_NAME' , 'transfer-pvc')
@patch('service.path.HOST_BASE_PATH' , '/home/tfga/workspace/cwl-tes')
@patch('service.path.CONTAINER_BASE_PATH' , '/transfer')
@patch('service.path.TRANSFER_PVC_NAME' , 'transfer-pvc')
@patch.dict(os.environ,
{
"AWS_SHARED_CREDENTIALS_FILE": "/aws/credentials",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import unittest
from tesk_core.taskmaster import newParser, run_task, newLogger
from service.taskmaster import newParser, run_task, newLogger
from argparse import Namespace
import json
import logging
Expand Down Expand Up @@ -64,11 +64,11 @@ def test_pullPolicyAlways(self):



@patch('tesk_core.taskmaster.args' , Namespace(debug=True, namespace='default', pull_policy_always=True))
@patch('tesk_core.taskmaster.logger' , newLogger(logging.DEBUG))
@patch('tesk_core.taskmaster.PVC.create' , pvcCreateMock)
@patch('tesk_core.taskmaster.PVC.delete' , pvcDeleteMock)
@patch('tesk_core.taskmaster.Job.run_to_completion' , jobRunToCompletionMock)
@patch('service.taskmaster.args' , Namespace(debug=True, namespace='default', pull_policy_always=True))
@patch('service.taskmaster.logger' , newLogger(logging.DEBUG))
@patch('service.taskmaster.PVC.create' , pvcCreateMock)
@patch('service.taskmaster.PVC.delete' , pvcDeleteMock)
@patch('service.taskmaster.Job.run_to_completion' , jobRunToCompletionMock)
def test_run_task(self):

with open('tests/resources/inputFile.json') as fh:
Expand Down
File renamed without changes.
Loading
Loading