Skip to content

Commit 1128bc6

Browse files
committed
feat: Setup transfer collector to fetch from voyager
1 parent 89768cc commit 1128bc6

5 files changed

Lines changed: 42 additions & 6 deletions

File tree

xpcs_portal/xpcs_index/api.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import logging
2+
import globus_sdk
23
from django.contrib.auth.decorators import login_required
34
from django.http import JsonResponse
45
from xpcs_portal.xpcs_index.models import FilenameFilter
56
from globus_portal_framework.gclients import load_transfer_client
7+
from xpcs_portal.xpcs_index.auth import get_globus_app_client
68

79
log = logging.getLogger(__name__)
810

@@ -26,7 +28,12 @@ def operation_ls(request, index):
2628
return JsonResponse({'error': f'Missing param: {item}'}, status=400)
2729

2830
try:
29-
tc = load_transfer_client(request.user)
31+
globus_app_client = request.GET.get("service_account")
32+
if globus_app_client:
33+
app = get_globus_app_client(request.user, globus_app_client)
34+
tc = globus_sdk.TransferClient(app=app)
35+
else:
36+
tc = load_transfer_client(request.user)
3037
response = tc.operation_ls(request.GET["collection"], path=request.GET["path"])
3138
return JsonResponse(response.data)
3239
except Exception as e:

xpcs_portal/xpcs_index/auth.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import logging
2+
import globus_sdk
3+
from django.conf import settings
4+
from django.contrib.auth.models import User
5+
6+
log = logging.getLogger(__name__)
7+
8+
9+
def get_globus_app_client(user: User, globus_app_client: str):
10+
if user.username != "nickolaussaint@globusid.org":
11+
raise Exception("Auth not implemented!")
12+
log.warning("Danger zone, requesting CC creds on unimplemented auth groups")
13+
cc = settings.GLOBUS_APP_FLOWS_AUTHORIZATIONS["confidential_client"][globus_app_client]
14+
app = globus_sdk.ClientApp("CC_AUTH", client_id=cc["client_id"], client_secret=cc["client_secret"])
15+
return app

xpcs_portal/xpcs_index/collectors.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@
33
import urllib
44
import copy
55
import collections
6+
import globus_sdk
67
from globus_app_flows.collectors.search import SearchCollector
78
from globus_app_flows.collectors.transfer import TransferCollector
89
from gladier_xpcs.deployments import deployment_map
910
from gladier_xpcs.flows.flow_boost import XPCSBoost
11+
from gladier_xpcs.deployments import BaseDeployment
12+
from xpcs_portal.xpcs_index.auth import get_globus_app_client
13+
1014

1115
log = logging.getLogger(__name__)
1216

@@ -22,6 +26,10 @@ def __init__(self, collection=None, path=None, *args, **kwargs):
2226
# super().__init__(collection="74defd5b-5f61-42fc-bcc4-834c9f376a4f", path="/XPCSDATA/2019-1/comm201901/", user=kwargs["user"])
2327
super().__init__(collection, path, *args, **kwargs)
2428

29+
def get_transfer_client(self):
30+
app = get_globus_app_client(self.user, "aps8idi-polaris")
31+
return globus_sdk.TransferClient(app=app)
32+
2533
def get_files(self, globus_dir: str):
2634
tc = self.get_transfer_client()
2735
log.debug(f'Fetching path for {globus_dir}')

xpcs_portal/xpcs_index/templates/xpcs/transfer-selection-form.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
function getParent() {
2323
var cycle = $('#id_cycle').find(":selected").val();
2424
var cycle_path = path + '/' + cycle
25-
$.get({url: "{% url 'xpcs-index:operation-ls' globus_portal_framework.index %}?collection=" + collection + "&path=" + cycle_path,
25+
$.get({url: "{% url 'xpcs-index:operation-ls' globus_portal_framework.index %}?collection=" + collection + "&path=" + cycle_path + "&service_account=aps8idi-polaris",
2626
dataType: "json",
2727
success: function(data) {updateOptions(data, "#id_parent")}
2828
});
@@ -36,7 +36,7 @@
3636
var cycle = $('#id_cycle').find(":selected").val();
3737
var qmap_path = qmap_basepath + cycle + '/';
3838
var include_only = $('#id_parent').find(":selected").val();
39-
$.get({url: "{% url 'xpcs-index:operation-ls' globus_portal_framework.index %}?collection=" + collection + "&path=" + qmap_path,
39+
$.get({url: "{% url 'xpcs-index:operation-ls' globus_portal_framework.index %}?collection=" + collection + "&path=" + qmap_path + "&service_account=aps8idi-polaris",
4040
dataType: "json",
4141
success: function(data) {
4242
var includes = []
@@ -57,7 +57,7 @@
5757
$( document ).ready(function() {
5858
$("#div_id_qmap").hide()
5959

60-
$.get({url: "{% url 'xpcs-index:operation-ls' globus_portal_framework.index %}?collection=" + collection + "&path=" + path,
60+
$.get({url: "{% url 'xpcs-index:operation-ls' globus_portal_framework.index %}?collection=" + collection + "&path=" + path + "&service_account=aps8idi-polaris",
6161
dataType: "json",
6262
success: function(data) {data.DATA = data.DATA.reverse(); updateOptions(data, "#id_cycle", exclude=cycle_exclude)},
6363
error: function(data) {

xpcs_portal/xpcs_index/views.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,14 @@ class XPCSComputeTransfer(XPCSReprocessing, BatchCreateView):
106106
template_name = "xpcs/transfer-selection-form.html"
107107
form_class = CollectionSelectionForm
108108
collector = XPCSTransferCollector
109-
collection = "74defd5b-5f61-42fc-bcc4-834c9f376a4f"
110-
path = "/XPCSDATA/"
109+
# Eagle endpoint and path
110+
# collection = "74defd5b-5f61-42fc-bcc4-834c9f376a4f"
111+
# path = "/XPCSDATA/"
112+
113+
# Voyager endpoint and path
114+
collection = "dc86d51b-81d1-4827-81be-2b5e64ba7dc1"
115+
path = "/"
116+
111117
cycle_exclude = [
112118
"spec_data",
113119
"partitionMapLibrary",

0 commit comments

Comments
 (0)