Skip to content

Commit

Permalink
feat(svc): workflow ui support (#3135)
Browse files Browse the repository at this point in the history
  • Loading branch information
Panaetius committed Nov 2, 2022
1 parent f7cefda commit 3cf7c5d
Show file tree
Hide file tree
Showing 42 changed files with 1,929 additions and 1,225 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Expand Up @@ -23,4 +23,7 @@
"\\.eggs | \\.git | \\.hg | \\.mypy_cache | \\.tox | \\.venv | _build | buck-out | build | dist | docs/conf.py",
],
"esbonio.sphinx.confDir": "",
"python.analysis.include": [
"renku/**"
],
}
2 changes: 1 addition & 1 deletion docker-compose.yml
Expand Up @@ -117,7 +117,7 @@ services:
image: traefik:v2.4
command: --api.insecure=true --providers.docker
ports:
- "80:80"
- "81:81"
# set the UI port to something other than 8080 since that's our service already
- "8088:8080"
volumes:
Expand Down
839 changes: 461 additions & 378 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions pyproject.toml
Expand Up @@ -84,6 +84,7 @@ inject = "<4.4.0,>=4.3.0"
isort = { version = "<5.10.2,>=5.3.2", optional = true }
jinja2 = { version = ">=2.11.3,<3.1.3" }
marshmallow = { version = ">=3.14.0,<3.18.0", optional = true }
marshmallow-oneofschema = { version=">=3.0.1,<4.0.0", optional = true }
mypy = {version = ">=0.942,<1.0", optional = true}
networkx = "<2.7,>=2.6.0"
numpy = ">=1.20.0,<1.22.0"
Expand Down Expand Up @@ -161,6 +162,7 @@ service = [
"flask",
"gunicorn",
"marshmallow",
"marshmallow-oneofschema",
"pillow",
"ptvsd",
"python-dotenv",
Expand Down Expand Up @@ -218,6 +220,7 @@ all = [
"gunicorn",
"isort",
"marshmallow",
"marshmallow-oneofschema",
"mypy",
"pexpect",
"pillow",
Expand Down Expand Up @@ -361,6 +364,7 @@ module = [
"humanize",
"lazy_object_proxy",
"lockfile",
"marshmallow_oneofschema",
"networkx.*",
"pathspec",
"patoolib.*",
Expand Down
9 changes: 8 additions & 1 deletion renku/command/run.py
Expand Up @@ -20,6 +20,7 @@
import os
import sys
from subprocess import call
from typing import cast

import click

Expand All @@ -32,10 +33,12 @@
from renku.core.interface.plan_gateway import IPlanGateway
from renku.core.storage import check_external_storage, pull_paths_from_storage
from renku.core.util.datetime8601 import local_now
from renku.core.util.git import get_git_user
from renku.core.util.urls import get_slug
from renku.core.workflow.plan_factory import PlanFactory
from renku.domain_model.project_context import project_context
from renku.domain_model.provenance.activity import Activity
from renku.domain_model.provenance.agent import Person


def run_command():
Expand All @@ -56,6 +59,7 @@ def _run_command(
no_output_detection,
success_codes,
command_line,
creators,
activity_gateway: IActivityGateway,
plan_gateway: IPlanGateway,
) -> PlanViewModel:
Expand Down Expand Up @@ -197,7 +201,10 @@ def parse_explicit_definition(entries, type):
if return_code not in (success_codes or {0}):
raise errors.InvalidSuccessCode(return_code, success_codes=success_codes)

plan = tool.to_plan(name=name, description=description, keywords=keyword)
if not creators:
creators = [cast(Person, get_git_user(project_context.repository))]

plan = tool.to_plan(name=name, description=description, keywords=keyword, creators=creators)
activity = Activity.from_plan(
plan=plan,
repository=project_context.repository,
Expand Down
2 changes: 2 additions & 0 deletions renku/command/schema/composite_plan.py
Expand Up @@ -19,6 +19,7 @@

from marshmallow import EXCLUDE

from renku.command.schema.agent import PersonSchema
from renku.command.schema.calamus import JsonLDSchema, Nested, fields, prov, renku, schema
from renku.command.schema.parameter import ParameterLinkSchema, ParameterMappingSchema
from renku.command.schema.plan import PlanSchema
Expand All @@ -37,6 +38,7 @@ class Meta:

description = fields.String(schema.description, load_default=None)
id = fields.Id()
creators = Nested(schema.creator, PersonSchema, many=True)
mappings = Nested(renku.hasMappings, [ParameterMappingSchema], many=True, load_default=None)
date_created = fields.DateTime(schema.dateCreated, format="iso")
invalidated_at = fields.DateTime(prov.invalidatedAtTime, format="iso")
Expand Down
2 changes: 2 additions & 0 deletions renku/command/schema/plan.py
Expand Up @@ -21,6 +21,7 @@

import marshmallow

from renku.command.schema.agent import PersonSchema
from renku.command.schema.annotation import AnnotationSchema
from renku.command.schema.calamus import JsonLDSchema, Nested, fields, oa, prov, renku, schema
from renku.command.schema.parameter import CommandInputSchema, CommandOutputSchema, CommandParameterSchema
Expand All @@ -41,6 +42,7 @@ class Meta:

command = fields.String(renku.command, load_default=None)
description = fields.String(schema.description, load_default=None)
creators = Nested(schema.creator, PersonSchema, many=True)
id = fields.Id()
inputs = Nested(renku.hasInputs, CommandInputSchema, many=True, load_default=None)
date_created = fields.DateTime(schema.dateCreated, format="iso")
Expand Down
54 changes: 54 additions & 0 deletions renku/command/view_model/agent.py
@@ -0,0 +1,54 @@
# -*- coding: utf-8 -*-
#
# Copyright 2017-2022 - Swiss Data Science Center (SDSC)
# A partnership between École Polytechnique Fédérale de Lausanne (EPFL) and
# Eidgenössische Technische Hochschule Zürich (ETHZ).
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Agent view model."""


from typing import Optional

from renku.domain_model.provenance.agent import Person


class PersonViewModel:
"""View model for ``Person``."""

def __init__(self, name: str, email: str, affiliation: Optional[str]) -> None:
self.name = name
self.email = email
self.affiliation = affiliation

@classmethod
def from_person(cls, person: Person):
"""Create view model from ``Person``.
Args:
person(Person): The person to convert.
Returns:
View model for person
"""
return cls(name=person.name, email=person.email, affiliation=person.affiliation)

def __str__(self) -> str:
email = affiliation = ""

if self.email:
email = f" <{self.email}>"

if self.affiliation:
affiliation = f" [{self.affiliation}]"

return f"{self.name}{email}{affiliation}"

0 comments on commit 3cf7c5d

Please sign in to comment.