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 | |
parent | c0fa862b74eb54da3e4d5e859ef6ac5775509f29 (diff) |
Merge backend plumbing
-rw-r--r-- | src/crystfelmergeopts.h | 2 | ||||
-rw-r--r-- | src/gui_backend_local.c | 17 | ||||
-rw-r--r-- | src/gui_backend_slurm.c | 134 | ||||
-rw-r--r-- | src/gui_project.c | 8 |
4 files changed, 152 insertions, 9 deletions
diff --git a/src/crystfelmergeopts.h b/src/crystfelmergeopts.h index 0b485b88..aa2ed164 100644 --- a/src/crystfelmergeopts.h +++ b/src/crystfelmergeopts.h @@ -85,4 +85,6 @@ typedef struct _crystfelmergeoptsclass CrystFELMergeOptsClass; extern GType crystfel_merge_opts_get_type(void); extern GtkWidget *crystfel_merge_opts_new(void); +extern float crystfel_merge_opts_get_push_res(CrystFELMergeOpts *opts); + #endif /* CRYSTFELMERGEOPTS_H */ diff --git a/src/gui_backend_local.c b/src/gui_backend_local.c index 4c5bf907..82f4b167 100644 --- a/src/gui_backend_local.c +++ b/src/gui_backend_local.c @@ -340,7 +340,7 @@ static GtkWidget *make_indexing_parameters_widget(void *opts_priv) } -static struct local_indexing_opts *make_default_local_opts() +static struct local_indexing_opts *make_default_local_indexing_opts() { struct local_indexing_opts *opts = malloc(sizeof(struct local_indexing_opts)); if ( opts == NULL ) return NULL; @@ -432,6 +432,17 @@ static void *run_merging(const char *job_title, } +static struct local_merging_opts *make_default_local_merging_opts() +{ + struct local_merging_opts *opts = malloc(sizeof(struct local_merging_opts)); + if ( opts == NULL ) return NULL; + + opts->n_threads = 4; + + return opts; +} + + static void write_merging_opts(void *opts_priv, FILE *fh) { struct local_merging_opts *opts = opts_priv; @@ -465,14 +476,14 @@ int make_local_backend(struct crystfel_backend *be) be->make_indexing_parameters_widget = make_indexing_parameters_widget; be->run_indexing = run_indexing; - be->indexing_opts_priv = make_default_local_opts(); + be->indexing_opts_priv = make_default_local_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->make_merging_parameters_widget = make_merging_parameters_widget; be->run_merging = run_merging; - be->merging_opts_priv = make_default_local_opts(); + be->merging_opts_priv = make_default_local_merging_opts(); if ( be->merging_opts_priv == NULL ) return 1; be->write_merging_opts = write_merging_opts; be->read_merging_opt = read_merging_opt; 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; }; diff --git a/src/gui_project.c b/src/gui_project.c index 3e28e806..f1e1ce4a 100644 --- a/src/gui_project.c +++ b/src/gui_project.c @@ -769,6 +769,14 @@ int save_project(struct crystfelproject *proj) fprintf(fh, "merging.push_res %f\n", proj->merging_params.push_res); + fprintf(fh, "merging.backend %s\n", + proj->backends[proj->merging_backend_selected].name); + for ( i=0; i<proj->n_backends; i++ ) { + struct crystfel_backend *be; + be = &proj->backends[i]; + be->write_merging_opts(be->merging_opts_priv, fh); + } + fprintf(fh, "show_peaks %i\n", proj->show_peaks); fprintf(fh, "show_refls %i\n", proj->show_refls); |