Skip to content
Snippets Groups Projects
Commit c7668dd8 authored by Remi  PLANEL's avatar Remi PLANEL
Browse files

Resolve "Multiple analysis upload: not working for the first time"

parent 65a00aab
No related branches found
No related tags found
1 merge request!10Resolve "Multiple analysis upload: not working for the first time"
workflow:
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: never
- when: always
stages: stages:
- delete-release - delete-release
- build - build
......
...@@ -28,6 +28,15 @@ def csrf(request): ...@@ -28,6 +28,15 @@ def csrf(request):
return JsonResponse({"token": token}) return JsonResponse({"token": token})
@router.get("init-session")
def init_session(request):
if not request.session.session_key:
request.session.create()
request.session.set_expiry(60000)
return JsonResponse({"session": "ok"})
@router.post("add", response=AnalysisOutSchema) @router.post("add", response=AnalysisOutSchema)
def add( def add(
request, request,
...@@ -42,14 +51,17 @@ def add( ...@@ -42,14 +51,17 @@ def add(
if request.session.session_key: if request.session.session_key:
session_key = request.session.session_key session_key = request.session.session_key
else: else:
print("should not create a token !!!!!")
request.session.create() request.session.create()
request.session.set_expiry(60000) request.session.set_expiry(60000)
session_key = request.session.session_key session_key = request.session.session_key
print(session_key)
session = Session.objects.get(session_key=session_key) session = Session.objects.get(session_key=session_key)
aw = AnalysisWorkflow.objects.get(pk=1) aw = AnalysisWorkflow.objects.get(pk=1)
input_files = [ input_files = [
genome_path, genome_path,
] ]
params = {} params = {}
analysis = aw.invoke(session, input_files, params, f"{genomefile.name}") analysis = aw.invoke(session, input_files, params, f"{genomefile.name}")
...@@ -57,6 +69,7 @@ def add( ...@@ -57,6 +69,7 @@ def add(
return analysis return analysis
@router.get("/", response=list[AnalysisOutSchema]) @router.get("/", response=list[AnalysisOutSchema])
def list(request): def list(request):
session_key = request.session.session_key session_key = request.session.session_key
......
...@@ -65,21 +65,27 @@ class AnalysisWorkflow(Workflow): ...@@ -65,21 +65,27 @@ class AnalysisWorkflow(Workflow):
galaxy_inv = self.galaxy_workflow.invoke( galaxy_inv = self.galaxy_workflow.invoke(
datamap, history=history.galaxy_history, params=params datamap, history=history.galaxy_history, params=params
) )
analysis = Analysis(
name=history_name, try:
galaxy_id=galaxy_inv.id, analysis = Analysis(
galaxy_state=galaxy_inv.state, name=history_name,
analysis_workflow=self, galaxy_id=galaxy_inv.id,
workflow=self, galaxy_state=galaxy_inv.state,
history=history, analysis_workflow=self,
analysis_history=history, workflow=self,
params=params, history=history,
datamap=datamap, analysis_history=history,
create_time=load_galaxy_invocation_time_to_datetime(galaxy_inv), params=params,
) datamap=datamap,
analysis.save() create_time=load_galaxy_invocation_time_to_datetime(galaxy_inv),
analysis.create_output_files() )
return analysis except ZeroDivisionError as e:
print(e)
finally:
analysis.save()
analysis.create_output_files(max_retry=20)
return analysis
def prepare_invocation( def prepare_invocation(
self, self,
......
...@@ -6,12 +6,16 @@ export interface Props { ...@@ -6,12 +6,16 @@ export interface Props {
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
fluid: true fluid: true
}); });
useCsrfToken() const { csrfToken } = await useCsrfToken()
// init session
if (csrfToken.value) {
const { data, pending, error } = useFetch("/api/analysis/init-session", {
headers: [["X-CSRFToken", csrfToken.value]]
})
}
const scrollThreshold = ref(200) const scrollThreshold = ref(200)
const density = ref<'compact' | 'prominent'>("prominent") const density = ref<'compact' | 'prominent'>("prominent")
// Hanle CSRF token
function onScroll() { function onScroll() {
if (window.scrollY > scrollThreshold.value) { if (window.scrollY > scrollThreshold.value) {
density.value = "compact" density.value = "compact"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment