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
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@
*/
package org.apache.airavata.research.service.config;

import static org.apache.airavata.research.service.enums.AuthorRoleEnum.PRIMARY;
import static org.apache.airavata.research.service.enums.StateEnum.ACTIVE;

import java.util.HashSet;
import java.util.Set;
import org.apache.airavata.research.service.enums.PrivacyEnum;
import org.apache.airavata.research.service.enums.StatusEnum;
import org.apache.airavata.research.service.model.entity.DatasetResource;
import org.apache.airavata.research.service.model.entity.Project;
import org.apache.airavata.research.service.model.entity.RepositoryResource;
import org.apache.airavata.research.service.model.entity.ResourceAuthor;
import org.apache.airavata.research.service.model.entity.Tag;
import org.apache.airavata.research.service.model.repo.ProjectRepository;
import org.apache.airavata.research.service.model.repo.ResourceRepository;
Expand Down Expand Up @@ -54,7 +58,7 @@ public DevDataInitializer(
}

private void createProject(
String name, String description, String repoUrl, String datasetUrl, String[] tags, String user) {
String name, String description, String repoUrl, String datasetUrl, String[] tags, Set<String> authors) {
Set<Tag> tagSet = new HashSet<>();
for (String tag : tags) {
Tag t = tagRepository.findByValue(tag);
Expand All @@ -68,12 +72,6 @@ private void createProject(
}
}

Set<String> authors = new HashSet<>() {
{
add(user);
}
};

RepositoryResource repo = new RepositoryResource();
repo.setName(name);
repo.setDescription(description);
Expand All @@ -82,7 +80,16 @@ private void createProject(
repo.setStatus(StatusEnum.VERIFIED);
repo.setPrivacy(PrivacyEnum.PUBLIC);
repo.setTags(tagSet);
repo.setAuthors(authors);
repo.setState(ACTIVE);
Set<ResourceAuthor> repoResourceAuthors = new HashSet<>();
for (String author : authors) {
ResourceAuthor a = new ResourceAuthor();
a.setResource(repo);
a.setRole(PRIMARY);
a.setAuthorId(author);
repoResourceAuthors.add(a);
}
repo.setAuthors(repoResourceAuthors);
repo = resourceRepository.save(repo);

DatasetResource dataset = new DatasetResource();
Expand All @@ -93,120 +100,133 @@ private void createProject(
dataset.setStatus(StatusEnum.VERIFIED);
dataset.setPrivacy(PrivacyEnum.PUBLIC);
dataset.setTags(tagSet);
dataset.setAuthors(authors);
dataset.setState(ACTIVE);
Set<ResourceAuthor> datasetResourceAuthors = new HashSet<>();
for (String author : authors) {
ResourceAuthor a = new ResourceAuthor();
a.setResource(repo);
a.setRole(PRIMARY);
a.setAuthorId(author);
datasetResourceAuthors.add(a);
}
dataset.setAuthors(datasetResourceAuthors);
dataset = resourceRepository.save(dataset);

Project project = new Project();
project.setRepositoryResource(repo);
project.getDatasetResources().add(dataset);
project.setName(name);
project.setOwnerId(user);
project.setState(ACTIVE);
project.setOwnerId(String.join(", ", authors.stream().toString()));
projectRepository.save(project);

System.out.println("Initialized Project with id: " + project.getId());
}

@Override
public void run(String... args) {
System.out.println("HRSDSF");
if (projectRepository.count() > 0) {
System.out.println("Dev data already initialized. Skipping initialization.");
return;
}

System.out.println("Initializing dev data...");

createProject(
"Bio-realistic multiscale simulations of cortical circuits",
"Running the AllenAI V1 model, with thalamacortical (LGN) and background (BKG) inputs",
"https://github.com/cyber-shuttle/allenai-v1",
"allenai-v1",
new String[] {"neurodata25", "allenai", "visual_cortex"},
"Anton Arkhipov, Laura Green");
Set.of("Anton Arkhipov", "Laura Green"));

createProject(
"Apache Cerebrum",
"Constructing computational neuroscience models from large public databases and brain atlases",
"https://github.com/cyber-shuttle/airavata-cerebrum",
"apache-airavata-cerebrum",
new String[] {"neurodata25", "apache", "cerebrum"},
"Sriram Chockalingam");
Set.of("Sriram Chockalingam"));

createProject(
"Spatio-temporal dynamics of sleep in large-scale brain models",
"Running a large-scale brain model during awake and sleep states",
"https://github.com/cyber-shuttle/whole-brain-public",
"bazhlab-whole-brain",
new String[] {"neurodata25", "bazhlab", "whole-brain"},
"Maxim Bazhenov, Gabriela Navas Zuloaga");
Set.of("Maxim Bazhenov", "Gabriela Navas Zuloaga"));

createProject(
"Biologically Constrained RNNs",
"Running a biologically constrained RNN via Dale's backpropagation and topologically-informed pruning",
"https://github.com/cyber-shuttle/biologicalRNNs",
"hchoilab-biologicalRNNs",
new String[] {"neurodata25", "hchoilab", "biological-rnn"},
"Hannah Choi, Aishwarya Balwani");
Set.of("Hannah Choi", "Aishwarya Balwani"));

createProject(
"One-hot Generalized Linear Model for Switching Brain State Discovery",
"Reproducing the One-hot HMM-GLM paper (ICLR 2024)",
"https://github.com/cyber-shuttle/onehot-hmmglm",
"brainml-onehot-hmmglm",
new String[] {"neurodata25", "brainml", "hmm-glm"},
"Anqi Wu, Chengrui Li");
Set.of("Anqi Wu", "Chengrui Li"));

createProject(
"Scaling up neural data analysis with torch_brain and temporaldata",
"Understand and highlight the features of torch_brain and temporaldata",
"https://github.com/cyber-shuttle/neurodata25_torchbrain_notebooks",
"nerdslab-neurodata25",
new String[] {"neurodata25", "nerdslab", "torch_brain", "temporaldata"},
"Eva Dyer, Vinam Arora, Mahato Shivashriganesh");
Set.of("Eva Dyer, Vinam Arora", "Mahato Shivashriganesh"));

createProject(
"Bridge the Gap between the Structure and Function in the Brain",
"Run the NetFormer model for neural connectivity",
"https://github.com/cyber-shuttle/neuroaihub-netformer",
"neuroaihub-netformer",
new String[] {"neurodata25", "neuroaihub", "netformer"},
"Lu Mi");
Set.of("Lu Mi"));

createProject(
"Computing with Neural Oscillators",
"A speech demo that uses Neural Oscillators",
"https://github.com/cyber-shuttle/imamlab-neural-oscillators",
"imamlab-neurodata25",
new String[] {"neurodata25", "imamlab", "neural-oscillators"},
"Nabil Imam, Nand Chandravadia");
Set.of("Nabil Imam, Nand Chandravadia"));

createProject(
"Getting started with Cybershuttle",
"Run a simulation and understand the minimum macros required to run Cybershuttle",
"https://github.com/cyber-shuttle/cybershuttle-reference",
"cybershuttle-reference",
new String[] {"cybershuttle", "apache-airavata", "reference"},
"Suresh Marru");
Set.of("Suresh Marru"));

createProject(
"Malicious URL Detector",
"Detect malicious URLs using machine learning models",
"https://github.com/airavata-courses/malicious-url-detector",
"airavata-courses-malicious-url-detector",
new String[] {"airavata-courses", "spring-2025"},
"Krish Katariya, Jesse Gong, Shreyas Arisa, Devin Fromond");
Set.of("Krish Katariya", "Jesse Gong", "Shreyas Arisa", "Devin Fromond"));

createProject(
"Deepseek Remote Execution",
"Executing deepseek model on remote HPC",
"https://github.com/ZhenmeiOng/proj2-llama",
"airavata-courses-deepseek-chat",
new String[] {"airavata-courses", "spring-2025", "llm"},
"Yashkaran Chauhan, Zhenmei Ong, Varenya Amagowni");
Set.of("Yashkaran Chauhan", "Zhenmei Ong", "Varenya Amagowni"));

createProject(
"Fast Chat",
"Fast and easy communication with fast chat",
"https://github.com/riccog/cybershuttle",
"airavata-courses-fast-chat",
new String[] {"airavata-courses", "spring-2025"},
"Ricco Goss, Mason Graham, Talam, Ruchira");
Set.of("Ricco Goss", "Mason Graham", "Talam", "Ruchira"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.research.service.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.List;
import org.apache.airavata.research.service.enums.StatusEnum;
import org.apache.airavata.research.service.handlers.AdminHandler;
import org.apache.airavata.research.service.handlers.ResourceHandler;
import org.apache.airavata.research.service.model.entity.Resource;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/rf/admin")
@Tag(name = "Admin Controls ", description = "Operations performable by Cybershuttle admins")
public class AdminController {

private final ResourceHandler resourceHandler;
private final AdminHandler adminHandler;

public AdminController(ResourceHandler resourceHandler, AdminHandler adminHandler) {
this.resourceHandler = resourceHandler;
this.adminHandler = adminHandler;
}

@PostMapping("/resources/{id}/verify")
@Operation(summary = "Verify a resource")
public ResponseEntity<Resource> verifyResource(@PathVariable(value = "id") String id) {
Resource resource = resourceHandler.getResourceById(id);
return ResponseEntity.ok(adminHandler.verifyResource(resource));
}

@PostMapping("/resources/{id}/reject")
@Operation(summary = "Verify a resource")
public ResponseEntity<Resource> rejectResource(
@PathVariable(value = "id") String id, @RequestBody String rejectionMessage) {
Resource resource = resourceHandler.getResourceById(id);
return ResponseEntity.ok(adminHandler.rejectResource(resource, rejectionMessage));
}

@GetMapping("/resources/pending")
@Operation(summary = "Get all pending verification resources")
public ResponseEntity<List<Resource>> getPendingResources() {
return ResponseEntity.ok(resourceHandler.getAllResourcesWithStatus(List.of(StatusEnum.PENDING)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.apache.airavata.research.service.model.entity.Project;
import org.apache.airavata.research.service.model.entity.RepositoryResource;
import org.apache.airavata.research.service.model.entity.Resource;
import org.apache.airavata.research.service.model.entity.ResourceVerificationActivity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
Expand Down Expand Up @@ -167,6 +168,19 @@ public ResponseEntity<List<Project>> getProjectsFromResourceId(@PathVariable(val
return ResponseEntity.ok(projects);
}

@Operation(summary = "Submit a resource for verification")
@PostMapping(value = "/{id}/verify")
public ResponseEntity<Resource> submitResourceForVerification(@PathVariable(value = "id") String id) {
return ResponseEntity.ok(resourceHandler.submitResourceForVerification(id));
}

@Operation(summary = "Get verification activities for a resource")
@GetMapping(value = "/{id}/verification-activities")
public ResponseEntity<List<ResourceVerificationActivity>> getResourceVerificationActivities(
@PathVariable(value = "id") String id) {
return ResponseEntity.ok(resourceHandler.getResourceVerificationActivities(id));
}

@Operation(summary = "Star/unstar a resource")
@PostMapping(value = "/{id}/star")
public ResponseEntity<Boolean> starOrUnstarResource(@PathVariable(value = "id") String id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@

import java.util.Set;
import org.apache.airavata.research.service.enums.PrivacyEnum;
import org.apache.airavata.research.service.model.entity.ResourceAuthor;

public class CreateResourceRequest {

public String name;
public String description;
public String headerImage;
Set<String> tags;
Set<String> authors;
Set<ResourceAuthor> authors;
PrivacyEnum privacy;

public PrivacyEnum getPrivacy() {
Expand All @@ -39,11 +40,11 @@ public void setPrivacy(PrivacyEnum privacy) {
this.privacy = privacy;
}

public Set<String> getAuthors() {
public Set<ResourceAuthor> getAuthors() {
return authors;
}

public void setAuthors(Set<String> authors) {
public void setAuthors(Set<ResourceAuthor> authors) {
this.authors = authors;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.airavata.research.service.enums;

public enum AuthorRoleEnum {
PRIMARY,
SECONDARY,
TERTIARY,
QUATERNARY,
QUINARY
}
Loading