Skip to content
Open
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
4 changes: 3 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@
// Allow the container to access the host X11 display and EPICS CA
// "--net=host",
// Make sure SELinux does not disable with access to host filesystems like tmp
"--security-opt=label=disable"
"--security-opt=label=disable",
"--env-file",
"src/.env"
],
"portsAttributes": {
"5173": {
Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff",
},
"python.envFile": "${workspaceFolder}/workspaces/python-interface-to-workflows/src/.env"
}
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ dependencies = [
"hera",
"requests",
"PyYAML",
"python-keycloak",
"pillow",
"numpy",
"h5py",
"dotenv",
"python-keycloak",
] # Add project dependencies here, e.g. ["click", "numpy"]
dynamic = ["version"]
license.file = "LICENSE"
Expand All @@ -45,6 +45,7 @@ dev = [
"numpy",
"h5py",
"dotenv",
"python-keycloak",
]

[project.scripts]
Expand Down
4 changes: 2 additions & 2 deletions scripts/makecopiercorrect.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash
cd "src/python_interface_to_workflows/workflow_definitions"

cp *.py "../../copier_template/src/{{ project_name }}/workflow_definitions"
cp ../templates/*.yaml "../../copier_template/src/{{ project_name }}/templates"
cp *example*.py "../../copier_template/src/{{ project_name }}/workflow_definitions"
cp ../templates/*example*.yaml "../../copier_template/src/{{ project_name }}/templates"

for file in "../../copier_template/src/{{ project_name }}/workflow_definitions"/*
do
Expand Down
4 changes: 3 additions & 1 deletion src/copier_template/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@
// Allow the container to access the host X11 display and EPICS CA
// "--net=host",
// Make sure SELinux does not disable with access to host filesystems like tmp
"--security-opt=label=disable"
"--security-opt=label=disable",
"--env-file",
"src/.env"
],
"forwardPorts": [
5173
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff",
},
"python.envFile": "${workspaceFolder}/workspaces/{{repo_name}}/src/.env"
}
45 changes: 44 additions & 1 deletion src/copier_template/pyproject.toml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ dependencies = [
"hera",
"requests",
"PyYAML",
"pillow",
"numpy",
"h5py",
"dotenv",
"python-keycloak",
] # Add project dependencies here, e.g. ["click", "numpy"]
dynamic = ["version"]
license.file = "LICENSE"
Expand All @@ -36,8 +41,14 @@ dev = [
"tox-uv",
"types-mock",
"PyYAML",
"pillow",
"numpy",
"h5py",
"dotenv",
"python-keycloak",
]


[project.scripts]
{{repo_name}} = "{{project_name}}.__main__:main"

Expand All @@ -52,8 +63,40 @@ name = "{{author_name}}"
version_file = "src/{{project_name}}/_version.py"

[tool.pyright]
typeCheckingMode = "strict"
typeCheckingMode = "standard"
reportMissingImports = false # Ignore missing stubs in imported modules
reportMissingTypeStubs = "none"
reportMissingModuleSource="warning"
reportInvalidTypeForm="warning"
reportMissingImports="warning"
reportUndefinedVariable="warning"
reportAbstractUsage="warning"
reportArgumentType="warning"
reportAssertTypeFailure="warning"
reportAssignmentType="warning"
reportAttributeAccessIssue="warning"
reportCallIssue="warning"
reportGeneralTypeIssues="warning"
reportInconsistentOverload="warning"
reportIndexIssue="warning"
reportInvalidTypeArguments="warning"
reportNoOverloadImplementation="warning"
reportOperatorIssue="warning"
reportOptionalSubscript="warning"
reportOptionalMemberAccess="warning"
reportOptionalCall="warning"
reportOptionalIterable="warning"
reportOptionalContextManager="warning"
reportOptionalOperand="warning"
reportRedeclaration="warning"
reportReturnType="warning"
reportTypedDictNotRequiredAccess="warning"
reportPrivateImportUsage="warning"
reportUnboundVariable="warning"
reportUnhashable="warning"
reportUnusedCoroutine="warning"
reportUnusedExcept="warning"


[tool.pytest.ini_options]
# Run pytest with all our checkers, and don't spam us with massive tracebacks on error
Expand Down
9 changes: 9 additions & 0 deletions src/copier_template/src/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Setting up a development environment
1. Build the dev container
2. run "uv lock" to generate the uv.lock file
3. Create .env in this folder (with the path src/.env) containing the following variables:
HOST=https://argo-workflows.workflows.diamond.ac.uk/ (to submit to the production repo)
IMAGE= (usually python 3.10)
TOKEN=
NAMESPACE= (the cluster you wish to run the templates on)
AUTH=
181 changes: 0 additions & 181 deletions src/copier_template/src/{{ project_name }}/auth/get_token.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import os

import dotenv
from keycloak import KeycloakOpenID
from keycloak.pkce_utils import generate_code_challenge, generate_code_verifier

from {{project_name}}.auth.open_auth_url import open_auth_url


def set_token_env_variable() -> str:
keycloak_openid = KeycloakOpenID(
client_id="workflows-dashboard",
server_url="https://identity.diamond.ac.uk/",
realm_name="dls",
client_secret_key="",
pool_maxsize=1,
)
port = 8000
code_verifier = generate_code_verifier()
code_challenge, code_challenge_method = generate_code_challenge(code_verifier)
auth_url = keycloak_openid.auth_url(
redirect_uri=f"http://localhost:{port}/",
scope="openid posix-uid profile email fedid",
state="",
code_challenge=code_challenge,
code_challenge_method=code_challenge_method,
)
open_auth_url(auth_url)
token: dict[str, str] = ( # pyright: ignore[reportUnknownVariableType]
keycloak_openid.token( # pyright: ignore[reportUnknownMemberType]
grant_type="authorization_code",
code=os.environ["AUTH"],
redirect_uri=f"http://localhost:{port}/",
code_verifier=code_verifier,
)
)
dotenv.set_key("src/.env", "TOKEN", token["access_token"].strip("'"))
return token["access_token"] # pyright: ignore[reportUnknownArgumentType]
Loading
Loading