Skip to content

Commit

Permalink
Improve Proactive code generation
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-maynou committed Mar 12, 2024
1 parent 560887b commit fde2433
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
16 changes: 12 additions & 4 deletions Modules/IntentSpecification2WorkflowGenerator/api/api_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ def annotate_dataset_from_frontend():
def download_proactive():
graph = Graph().parse(data=request.json.get("graph", ""), format='turtle')
ontology = Graph().parse(data=request.json.get('ontology', ''), format='turtle')
layout = request.json.get('layout', '')
label_column = request.json.get('label_column', '')
data_product_name = request.json.get('data_product_name', '')

# Connect to Proactive
gateway = proactive.ProActiveGateway(base_url="https://try.activeeon.com:8443", debug=False, javaopts=[], log4j_props_file=None,
Expand Down Expand Up @@ -185,21 +188,26 @@ def download_proactive():
bucket = gateway.getBucket("ai-machine-learning")

################## Change file path (name) and label name (send both as parameters)
load_dataset_task = bucket.create_Import_Data_task(import_from="PA:USER_FILE", file_path="countries.csv", file_delimiter=",", label_column="IncomeGroup")
load_dataset_task = bucket.create_Import_Data_task(import_from="PA:USER_FILE", file_path=data_product_name + ".csv", file_delimiter=";", label_column=label_column)
proactive_job.addTask(load_dataset_task)

split_data_task = bucket.create_Split_Data_task()
split_data_task.addDependency(load_dataset_task)
proactive_job.addTask(split_data_task)

# Model depends on the layout, the rest is the same
scale_task = bucket.create_Scale_Data_task()
model_task = bucket.create_Support_Vector_Machines_task()
for key in layout:
if "decision_tree_predictor" in key:
model_task = bucket.create_Random_Forest_task()
break
random_forest_task = bucket.create_Random_Forest_task()
proactive_job.addTask(random_forest_task)

bucket.create_Support_Vector_Machines_task()

train_model_task = bucket.create_Train_Model_task()
train_model_task.addDependency(split_data_task)
train_model_task.addDependency(random_forest_task)
train_model_task.addDependency(model_task)
proactive_job.addTask(train_model_task)

download_model_task = bucket.create_Download_Model_task()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,20 @@ public String postIntent(String intentName, String problem, String projectID, St
newIntent = saveIntent(newIntent);

Project project = projectService.getProject(projectID);
project.addIntent(newIntent);
List<Intent> intentsOfProject = project.getIntents();

// Before adding the new intent, we remove all those that have no workflows. This is because we first create the
// intent and then the workflows, but an intent with no workflows (which can happen if user cancels the process)
// is of no use.
for (Intent intentInProject : project.getIntents()) {
if (intentInProject.getWorkflows().isEmpty()) {
intentsOfProject.remove(intentInProject);
break;
}
}

intentsOfProject.add(newIntent);
project.setIntents(intentsOfProject);
projectService.saveProject(project);

return newIntent.getIntentID();
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/intents/AbstractPlanner.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const handleSubmit = async() => {
data.append("dataProductID", selectedDataProduct.id)
await intentsStore.postIntent(projectID, data)
await intentsStore.getAllIntents(projectID, data) // Refresh the list of intents
$q.loading.show({message: 'Materializing data product...'}) // Then, create the csv file from the dataProduct
await dataProductsStore.materializeDataProduct(projectID, selectedDataProduct.id)
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/stores/intentsStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const useIntentsStore = defineStore('intents', {
intent_graph: {}, // Graph definition of the current intent
ontology: "", // Ontology of the system (graph)
algorithmImplementations: [], // List of algorithms defined in the ontology
labelColumn: "", // Column over which a classification model will operate. ONLY FOR INTEGRATION WITH PROACTIVE. SHOULD BE REMOVED WHEN INTEGRATION DEPENDS ON THE GRAPH

abstractPlans: [], // List of abstract plans (displayed in Logical Planner)
logicalPlans: [], // List of logical plans (displayed in Workflow Planner)
Expand Down Expand Up @@ -82,6 +83,7 @@ export const useIntentsStore = defineStore('intents', {
},

async annotateDataset(data) {
this.labelColumn = data["label"] // SHOULD BE REMOVED EVENTUALLY
try {
const response = await intentsAPI.annotateDataset(data);
notify.positive(`Dataset annotated`)
Expand Down Expand Up @@ -186,7 +188,10 @@ export const useIntentsStore = defineStore('intents', {
},

async downloadProactive(plan) {
const data = {"graph": plan.graph, "ontology": this.ontology, "layout": this.plan}
const currentIntent = this.intents.find(intent => intent.intentID === String(this.intentID)) // SHOULD BE REMOVED EVENTUALLY
const dataProductName = currentIntent.dataProduct.datasetName // SHOULD BE REMOVED EVENTUALLY
// At some point, the translation to the Proactive ontology should be done, and the API should only require the graph to make it
const data = {"graph": plan.graph, "ontology": this.ontology, "layout": plan.plan, "label_column": this.labelColumn, "data_product_name": dataProductName}
try {
const response = await intentsAPI.downloadProactive(data);
FileSaver.saveAs(new Blob([response.data]), `${plan.id}.xml`);
Expand Down

0 comments on commit fde2433

Please sign in to comment.