Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
workspaces
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ssa
workspaces
Commits
01c32abd
Commit
01c32abd
authored
2 years ago
by
Charlotte Hausman
Committed by
Jim Sheckard
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
add capability level access to inspector
parent
d0afc457
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!991
add capability level access to inspector
Pipeline
#5855
passed
2 years ago
Stage: cache-build
Stage: build
Stage: unit-test
Stage: test-coverage
Stage: push
Stage: deploy-coverage-page
Stage: generate-yaml
Stage: trigger
Stage: deploy
Stage: .post
Pipeline: workspaces
#5858
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
apps/cli/executables/pexable/wf_inspector/wf_inspector/inspector.py
+57
-5
57 additions, 5 deletions
...xecutables/pexable/wf_inspector/wf_inspector/inspector.py
with
57 additions
and
5 deletions
apps/cli/executables/pexable/wf_inspector/wf_inspector/inspector.py
+
57
−
5
View file @
01c32abd
...
...
@@ -66,7 +66,7 @@ def make_arg_parser() -> argparse.ArgumentParser:
formatter_class
=
argparse
.
RawTextHelpFormatter
,
)
arg_parser
.
add_argument
(
"
workflow_
request_id
"
,
"
request_id
"
,
type
=
int
,
action
=
"
store
"
,
help
=
"
the workflow request ID of the running workflow
"
,
...
...
@@ -78,6 +78,14 @@ def make_arg_parser() -> argparse.ArgumentParser:
required
=
False
,
help
=
"
Return only the HTCondor ID for the given workflow request id
"
,
)
arg_parser
.
add_argument
(
"
-v
"
,
"
--version
"
,
nargs
=
1
,
action
=
"
store
"
,
required
=
False
,
help
=
"
Run the inspector with a capability request id and version id
"
,
)
return
arg_parser
...
...
@@ -140,6 +148,44 @@ def get_wf_request_htcondor_id(workflow_request_id: str) -> int:
raise
NoSuchWorkflowRequestError
(
f
"
No workflow request found with ID
{
workflow_request_id
}
"
)
def
get_capability_request_htcondor_id
(
capability_request_id
:
str
,
version_id
:
str
)
->
int
:
"""
Given a capability request ID, get the HTCondor job ID that corresponds
:param capability_request_id: ID of workflow request
:param version_id: ID of the capability version
:return: HTCondor job ID for workflow request
:raises NoIdForWorkflow if no ID was found for the workflow
"""
if
os
.
environ
[
"
CAPO_PROFILE
"
]
==
"
docker
"
:
capability_url
=
"
http://localhost:3457
"
workflow_url
=
"
http://localhost:3456
"
else
:
# Non-local scenario; use normal CAPO setting
capability_url
=
CapoConfig
().
settings
(
"
edu.nrao.workspaces.CapabilitySettings
"
).
externalServiceUrl
workflow_url
=
CapoConfig
().
settings
(
"
edu.nrao.workspaces.WorkflowSettings
"
).
serviceUrl
response
=
requests
.
get
(
f
"
{
capability_url
}
/capability/requests/
{
capability_request_id
}
/version/
{
version_id
}
/execution
"
)
if
response
.
status_code
==
http
.
HTTPStatus
.
OK
:
response2
=
requests
.
get
(
# About "name" in URL: workflow name not necessary for this endpoint, so any string works here
f
"
{
workflow_url
}
/workflows/name/requests/
{
response
.
json
()[
'
current_workflow_request_id
'
]
}
/htcondor_id
"
)
if
response2
.
status_code
==
http
.
HTTPStatus
.
OK
:
htcondor_id
=
response2
.
json
()[
"
htcondor_job_id
"
]
if
htcondor_id
!=
"
None
"
:
return
int
(
htcondor_id
)
raise
NoIdForWorkflowError
raise
NoSuchWorkflowRequestError
(
f
"
No capability request found with ID
{
capability_request_id
}
"
)
def
get_running_class_ads
(
workflow_container_id
:
bytes
)
->
List
[
ClassAd
]:
"""
Query the cluster for a list of the ClassAds of all running jobs in JSON format
...
...
@@ -245,15 +291,21 @@ def list_running_jobs(workflow_container_id: bytes):
def
main
():
args
=
make_arg_parser
().
parse_args
()
request_id
=
args
.
workflow_
request_id
request_id
=
args
.
request_id
condor
=
args
.
condor
from_cap_request
=
args
.
version
workflow_container_id
=
get_container_id_by_substr
(
"
workflow
"
)
# Get HTCondor ID for workflow request
logger
.
info
(
"
Getting HTCondor ID for workflow request %s
"
,
request_id
)
try
:
htcondor_job_id
=
get_wf_request_htcondor_id
(
request_id
)
if
from_cap_request
is
not
None
:
# Get HTCondor ID for capability request
logger
.
info
(
"
Getting HTCondor ID for capability request %s
"
,
request_id
)
htcondor_job_id
=
get_capability_request_htcondor_id
(
request_id
,
args
.
version
[
0
])
else
:
# Get HTCondor ID for workflow request
logger
.
info
(
"
Getting HTCondor ID for workflow request %s
"
,
request_id
)
htcondor_job_id
=
get_wf_request_htcondor_id
(
request_id
)
except
NoIdForWorkflowError
:
logger
.
warning
(
"
No HTCondor ID found for workflow request %s
"
,
request_id
)
list_running_jobs
(
workflow_container_id
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment