diff options
author | Thomas White <taw@physics.org> | 2020-10-29 14:14:41 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2020-10-29 14:14:41 +0100 |
commit | 4029011f2097165537b5425f20012d57fdf7ef9c (patch) | |
tree | 691d38974a179db8eec3f6202544808bbdb4b4cd /src/gui_backend_slurm.c | |
parent | c0fa862b74eb54da3e4d5e859ef6ac5775509f29 (diff) |
Merge backend plumbing
Diffstat (limited to 'src/gui_backend_slurm.c')
-rw-r--r-- | src/gui_backend_slurm.c | 134 |
1 files changed, 128 insertions, 6 deletions
diff --git a/src/gui_backend_slurm.c b/src/gui_backend_slurm.c index 4ac06a5e..69d7b31f 100644 --- a/src/gui_backend_slurm.c +++ b/src/gui_backend_slurm.c @@ -43,9 +43,16 @@ struct slurm_indexing_opts { char *partition; - int block_size; char *email_address; char *path_add; + int block_size; +}; + + +struct slurm_merging_opts +{ + char *partition; + char *email_address; }; @@ -619,7 +626,7 @@ static GtkWidget *make_indexing_parameters_widget(void *opts_priv) } -static struct slurm_indexing_opts *make_default_slurm_opts() +static struct slurm_indexing_opts *make_default_slurm_indexing_opts() { struct slurm_indexing_opts *opts = malloc(sizeof(struct slurm_indexing_opts)); if ( opts == NULL ) return NULL; @@ -683,20 +690,135 @@ static void read_indexing_opt(void *opts_priv, } +static void *run_merging(const char *job_title, + const char *job_notes, + struct crystfelproject *proj, + void *opts_priv) +{ + return NULL; +} + + +static struct slurm_merging_opts *make_default_slurm_merging_opts() +{ + struct slurm_merging_opts *opts = malloc(sizeof(struct slurm_merging_opts)); + if ( opts == NULL ) return NULL; + + opts->email_address = NULL; + opts->partition = NULL; + + return opts; +} + + +static void write_merging_opts(void *opts_priv, FILE *fh) +{ + struct slurm_merging_opts *opts = opts_priv; + + if ( opts->partition != NULL) { + fprintf(fh, "merging.slurm.partition %s\n", + opts->partition); + } + + if ( opts->email_address != NULL ) { + fprintf(fh, "merging.slurm.email_address %s\n", + opts->email_address); + } +} + + +static void read_merging_opt(void *opts_priv, + const char *key, + const char *val) +{ + struct slurm_merging_opts *opts = opts_priv; + + if ( strcmp(key, "merging.slurm.email_address") == 0 ) { + opts->email_address = strdup(val); + } + + if ( strcmp(key, "merging.slurm.partition") == 0 ) { + opts->partition = strdup(val); + } +} + + +static GtkWidget *make_merging_parameters_widget(void *opts_priv) +{ + struct slurm_merging_opts *opts = opts_priv; + GtkWidget *vbox; + GtkWidget *hbox; + GtkWidget *entry; + GtkWidget *label; + + vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 8); + + hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8); + gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(hbox), + FALSE, FALSE, 0); + label = gtk_label_new("Submit job to partition:"); + gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(label), + FALSE, FALSE, 0); + entry = gtk_entry_new(); + if ( opts->partition != NULL ) { + gtk_entry_set_text(GTK_ENTRY(entry), opts->partition); + } + gtk_entry_set_placeholder_text(GTK_ENTRY(entry), "maxwell"); + gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(entry), + FALSE, FALSE, 0); + g_signal_connect(G_OBJECT(entry), "activate", + G_CALLBACK(partition_activate_sig), + opts); + g_signal_connect(G_OBJECT(entry), "focus-out-event", + G_CALLBACK(partition_focus_sig), + opts); + + hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8); + gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(hbox), + FALSE, FALSE, 0); + label = gtk_label_new("Send notifications to:"); + gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(label), + FALSE, FALSE, 0); + entry = gtk_entry_new(); + if ( opts->email_address != NULL ) { + gtk_entry_set_text(GTK_ENTRY(entry), opts->email_address); + } + gtk_entry_set_placeholder_text(GTK_ENTRY(entry), + "myself@example.org"); + gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(entry), + FALSE, FALSE, 0); + g_signal_connect(G_OBJECT(entry), "activate", + G_CALLBACK(email_activate_sig), + opts); + g_signal_connect(G_OBJECT(entry), "focus-out-event", + G_CALLBACK(email_focus_sig), + opts); + + return vbox; +} + + int make_slurm_backend(struct crystfel_backend *be) { be->name = "slurm"; be->friendly_name = "SLURM"; + be->cancel_task = cancel_task; + be->task_status = get_task_status; + be->make_indexing_parameters_widget = make_indexing_parameters_widget; be->run_indexing = run_indexing; + be->indexing_opts_priv = make_default_slurm_indexing_opts(); + if ( be->indexing_opts_priv == NULL ) return 1; be->write_indexing_opts = write_indexing_opts; be->read_indexing_opt = read_indexing_opt; - be->cancel_task = cancel_task; - be->task_status = get_task_status; - be->indexing_opts_priv = make_default_slurm_opts(); - if ( be->indexing_opts_priv == NULL ) return 1; + be->make_merging_parameters_widget = make_merging_parameters_widget; + be->run_merging = run_merging; + be->merging_opts_priv = make_default_slurm_merging_opts(); + if ( be->merging_opts_priv == NULL ) return 1; + be->write_merging_opts = write_merging_opts; + be->read_merging_opt = read_merging_opt; return 0; }; |