Skip to content

Commit 3cf7c5d

Browse files
authored
feat(svc): workflow ui support (#3135)
1 parent f7cefda commit 3cf7c5d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1929
-1225
lines changed

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,7 @@
2323
"\\.eggs | \\.git | \\.hg | \\.mypy_cache | \\.tox | \\.venv | _build | buck-out | build | dist | docs/conf.py",
2424
],
2525
"esbonio.sphinx.confDir": "",
26+
"python.analysis.include": [
27+
"renku/**"
28+
],
2629
}

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ services:
117117
image: traefik:v2.4
118118
command: --api.insecure=true --providers.docker
119119
ports:
120-
- "80:80"
120+
- "81:81"
121121
# set the UI port to something other than 8080 since that's our service already
122122
- "8088:8080"
123123
volumes:

poetry.lock

Lines changed: 461 additions & 378 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ inject = "<4.4.0,>=4.3.0"
8484
isort = { version = "<5.10.2,>=5.3.2", optional = true }
8585
jinja2 = { version = ">=2.11.3,<3.1.3" }
8686
marshmallow = { version = ">=3.14.0,<3.18.0", optional = true }
87+
marshmallow-oneofschema = { version=">=3.0.1,<4.0.0", optional = true }
8788
mypy = {version = ">=0.942,<1.0", optional = true}
8889
networkx = "<2.7,>=2.6.0"
8990
numpy = ">=1.20.0,<1.22.0"
@@ -161,6 +162,7 @@ service = [
161162
"flask",
162163
"gunicorn",
163164
"marshmallow",
165+
"marshmallow-oneofschema",
164166
"pillow",
165167
"ptvsd",
166168
"python-dotenv",
@@ -218,6 +220,7 @@ all = [
218220
"gunicorn",
219221
"isort",
220222
"marshmallow",
223+
"marshmallow-oneofschema",
221224
"mypy",
222225
"pexpect",
223226
"pillow",
@@ -361,6 +364,7 @@ module = [
361364
"humanize",
362365
"lazy_object_proxy",
363366
"lockfile",
367+
"marshmallow_oneofschema",
364368
"networkx.*",
365369
"pathspec",
366370
"patoolib.*",

renku/command/run.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import os
2121
import sys
2222
from subprocess import call
23+
from typing import cast
2324

2425
import click
2526

@@ -32,10 +33,12 @@
3233
from renku.core.interface.plan_gateway import IPlanGateway
3334
from renku.core.storage import check_external_storage, pull_paths_from_storage
3435
from renku.core.util.datetime8601 import local_now
36+
from renku.core.util.git import get_git_user
3537
from renku.core.util.urls import get_slug
3638
from renku.core.workflow.plan_factory import PlanFactory
3739
from renku.domain_model.project_context import project_context
3840
from renku.domain_model.provenance.activity import Activity
41+
from renku.domain_model.provenance.agent import Person
3942

4043

4144
def run_command():
@@ -56,6 +59,7 @@ def _run_command(
5659
no_output_detection,
5760
success_codes,
5861
command_line,
62+
creators,
5963
activity_gateway: IActivityGateway,
6064
plan_gateway: IPlanGateway,
6165
) -> PlanViewModel:
@@ -197,7 +201,10 @@ def parse_explicit_definition(entries, type):
197201
if return_code not in (success_codes or {0}):
198202
raise errors.InvalidSuccessCode(return_code, success_codes=success_codes)
199203

200-
plan = tool.to_plan(name=name, description=description, keywords=keyword)
204+
if not creators:
205+
creators = [cast(Person, get_git_user(project_context.repository))]
206+
207+
plan = tool.to_plan(name=name, description=description, keywords=keyword, creators=creators)
201208
activity = Activity.from_plan(
202209
plan=plan,
203210
repository=project_context.repository,

renku/command/schema/composite_plan.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
from marshmallow import EXCLUDE
2121

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

3839
description = fields.String(schema.description, load_default=None)
3940
id = fields.Id()
41+
creators = Nested(schema.creator, PersonSchema, many=True)
4042
mappings = Nested(renku.hasMappings, [ParameterMappingSchema], many=True, load_default=None)
4143
date_created = fields.DateTime(schema.dateCreated, format="iso")
4244
invalidated_at = fields.DateTime(prov.invalidatedAtTime, format="iso")

renku/command/schema/plan.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import marshmallow
2323

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

4243
command = fields.String(renku.command, load_default=None)
4344
description = fields.String(schema.description, load_default=None)
45+
creators = Nested(schema.creator, PersonSchema, many=True)
4446
id = fields.Id()
4547
inputs = Nested(renku.hasInputs, CommandInputSchema, many=True, load_default=None)
4648
date_created = fields.DateTime(schema.dateCreated, format="iso")

renku/command/view_model/agent.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# Copyright 2017-2022 - Swiss Data Science Center (SDSC)
4+
# A partnership between École Polytechnique Fédérale de Lausanne (EPFL) and
5+
# Eidgenössische Technische Hochschule Zürich (ETHZ).
6+
#
7+
# Licensed under the Apache License, Version 2.0 (the "License");
8+
# you may not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
"""Agent view model."""
19+
20+
21+
from typing import Optional
22+
23+
from renku.domain_model.provenance.agent import Person
24+
25+
26+
class PersonViewModel:
27+
"""View model for ``Person``."""
28+
29+
def __init__(self, name: str, email: str, affiliation: Optional[str]) -> None:
30+
self.name = name
31+
self.email = email
32+
self.affiliation = affiliation
33+
34+
@classmethod
35+
def from_person(cls, person: Person):
36+
"""Create view model from ``Person``.
37+
38+
Args:
39+
person(Person): The person to convert.
40+
Returns:
41+
View model for person
42+
"""
43+
return cls(name=person.name, email=person.email, affiliation=person.affiliation)
44+
45+
def __str__(self) -> str:
46+
email = affiliation = ""
47+
48+
if self.email:
49+
email = f" <{self.email}>"
50+
51+
if self.affiliation:
52+
affiliation = f" [{self.affiliation}]"
53+
54+
return f"{self.name}{email}{affiliation}"

0 commit comments

Comments
 (0)