I've made a jupyter notebook that displays some graphs and dataframes. I can then change the widget values to refresh the dataframes and graphs.
I'm running into two problems:
Every time I run the book for the first time after opening Jupyter notebook, I get this:
Yet when I run all cells again, I get the desired output:
Every time I use the widgets and make a change, the notebook eventually refreshes correctly, but for some reason it continually outputs the top few graphs, seems to clear the output, then show them again, then clear output, and after a few iterations of this, is able to display everything. Here is my event handler:
def handle_submit(sender):
clear_output(wait=True)
start = w.slider_start.value.strftime('%Y-%m-%d')
end = w.slider_end.value.strftime('%Y-%m-%d')
zval = z.value
yval = y.value
xval = x.value
df_dlm,df_dgo,df_stats = show_stats(zval,yval,xval,start,end)
df_e = show_stats_exp(zval,yval,xval,start,end)
display_dataframe(df_stats)
plot_lines_e(df_e)
dfx = prepare_data(df_dlm,df_dgo)
plot_lines(dfx)
plot_scatter(dfx)
where the display_dataframe, plot_lines, and plot_scatter functions all have a "display" type line in them to actually show the graph since %matplotlib inline does not play well with ipywidgets...feels like that has something to do with it, but not sure how to get around this.
FYI the graphs are done in Bokeh, certain dataframes are plotted at matplotlib objects.
Thanks for your help!
That warning is just a bug that should be fixed in the next version of ipywidgets I believe. In the mean time the only thing that you can do is wait ~10-20 seconds after loading or reloading the notebook and the "trusted" box appears in the right hand corner as picture below;
Try executing all of your code only after you see that box come up.
Related
I'm relatively new to Lightning and Loggers vs manually tracking metrics. I am trying to train two distinct models and have their accuracy and loss plotted on the same charts in tensorboard (or any other logger) within Colab.
What I have right now is basically:
trainer1 = pl.Trainer(gpus=n_gpus, max_epochs=n_epochs, progress_bar_refresh_rate=20, num_sanity_val_steps=0)
trainer2 = pl.Trainer(gpus=n_gpus, max_epochs=n_epochs, progress_bar_refresh_rate=20, num_sanity_val_steps=0)
trainer1.fit(Model1, train_loader, val_loader)
trainer2.fit(Model2, train_loader, val_loader)
#Then later:
%load_ext tensorboard
%tensorboard --logdir lightning_logs/
What I'd like to see at this point are those logged metrics charted together on the same chart, any help would be appreciated. I've spent some time trying to toy with this but I'm a bit out of my depth on this, thank you!
The exact chart used for logging a specific metric depends on the key name you provide in the .log() call (its a feature that Lightning inherits from TensorBoard itself)
def validation_step(self, batch, _):
# This string decides which chart to use in the TB web interface
# vvvvvvvvv
self.log('valid_acc', acc)
Just use the same string for both .log() calls and have both runs saved in same directory.
logger = TensorBoardLogger(save_dir='lightning_logs/', name='model1')
logger = TensorBoardLogger(save_dir='lightning_logs/', name='model2')
If you run tesnsorboard --logdir ./lightning_logs pointing at the parent directory, you should be able to see both metric in the same chart with the key named valid_acc.
In my use-case, I'm performing Session as well as Sliding window inside Dataflow job. So basically my Sliding window timing is 10 hour with sliding time 4 min. Since I'm applying grouping and performing max function on top of that, on every 3 min interval, window will fire the pane and it will go into Session window with triggering logic on it. Below is the code for the same.
Window<Map<String, String>> windowMap = Window.<Map<String, String>>into(
SlidingWindows.of(Duration.standardHours(10)).every(Duration.standardMinutes(4)));
Window<Map<String, String>> windowSession = Window
.<Map<String, String>>into(Sessions.withGapDuration(Duration.standardHours(10))).discardingFiredPanes()
.triggering(Repeatedly
.forever(AfterProcessingTime.pastFirstElementInPane().plusDelayOf(Duration.standardSeconds(5))))
.withAllowedLateness(Duration.standardSeconds(10));
I would like to add logger on some steps for Debugging, so I'm trying to update the current streaming job using below code:
options.setRegion("asia-east1");
options.setUpdate(true);
options.setStreaming(true);
So previously I had around 10k data and I updated the existing pipeline using above config and now I'm not able to see that much data in steps of updated DF job. So help me with the understanding whether it preserves the previous job data or not as I'm not seeing previous DF step count in updated Job.
This is my first question on Stack Overflow. I am not much of a programmer, I just learnt about Selenium and went as far as I could but there is this mistake I can't fix alone so I am asking for help. I am using Python 2.7 in PyCharm.
As of now, I have been using anything.send_keys(Keys.ENTER) to click some buttons in my code as the .click() function always returned me a ElementNotInteractableException error in Chrome for this website. The goal here is simply to clear a text area, insert the list of genes down there and click on this "submit" button. This is supposed to show me an updated table that I want to download.
For this one troublesome button though, nothing works. The thing is, it doesn't even return an error, the code keeps going on as if it indeed had clicked, and it eventually downloads the non-updated table. I tried switching to Firefox, where neither .click() nor .send_keys(Keys.ENTER) worked (I never get an error as well, it just downloads the wrong table). Clicking myself does work and produces the updated table.
Based on other questions I saw here, I tried using ActionChains or scroll_into_view but still, nothing happens. Here is the code :
baseline_url = "http://mtsspdb.noble.org/atlas-internal/3880/transcript/profile/5?charttype=barchart&sessionid=1553076490500118&feature_accs=%20Medtr1g079760.1"
driver = webdriver.Chrome("C:\Webdrivers\chromedriver.exe")
driver.set_page_load_timeout(30)
driver.get(baseline_url)
driver.maximize_window()
peptides_list = """Medtr4g068220.1
Medtr1g107390.1
Medtr1g018740.1
Medtr5g016470.1
Medtr4g095002.1
Medtr5g004930.1
MT4Noble_020581.1
Medtr1g107395.1
Medtr1g107400.1
Medtr1g107405.1
Medtr1g107410.1
Medtr4g095010.1
MT4Noble_057127.1
"""
WebDriverWait(driver, 5).until(EC.presence_of_element_located((By.XPATH, "//*[#id='feature_accs']")))
text_area = driver.find_element_by_xpath("//*[#id='feature_accs']")
text_area.clear()
text_area.send_keys(peptides_list)
time.sleep(1)
troublesome = driver.find_element_by_xpath("//*[#id='form1']/div[8]/div/input")
print troublesome
#scroll_into_view = troublesome.location_once_scrolled_into_view
ActionChains(driver).move_to_element(troublesome).send_keys(Keys.ENTER)
time.sleep(3)
print "Sucess for x"
The html location of this button is
<input class="btn btn-primary" type="submit" name="submit" value="Submit">
Do you have any idea on how to click it, and most of all on why it doesn't work ?
Many thanks
PS: As I said previously, it is my first question. Please tell me if I need to update/change something.
This will definitely work, as I just tried it given your information
driver.execute_script("$('#form1').find('.btn-primary').click()")
Now, there must be something strange about it finding the element, as Selenium would error if it could not click. So the element we are clicking with the code must not have the events we expect it to have. I am investigating more and will update this with specifics.
Edit:
Interesting. The submit button does not seem to have normal event listeners.
getEventListeners($(".btn-primary")[0]);
$._data($(".btn-primary")[0], "events");
Both of these return nothing. This would seem to be the cause of the Selenium issue. It isn't triggering the actual submission with its click. Selenium does not use Javascript, and also does not use a real user32.dll (Windows ex) click, so it does not always behave identically to a real click or a javascript click.
Welcome to SO. Here is the option to click on the button.
Option 1: click using javascript
driver.exeucte_script("arguments[0].click();",troublesome)
Option 2: Scrolling to element
troublesome.location_once_scrolled_into_view
troublesome.click()
This works well for me:
for i in range(1, 10):
try:
driver.find_element_by_xpath(
f'/html/body/div[{i}]/div/div[2]/span[1]/span/span/input').click()
except:
pass
I need a qtf script that selects a line and proceeds. Recording the steps gave the following code:
Window("[windowname]").WinList("ListBox").Select "[Name of the item] "
But when I try to run it I see an error box: Cannot identify the specific item of the ListBox object.
This does not work with any of the lines. I cannot even select one with the arrow down key, the error is always the same.
Please try to highlight WinList from object repository before you run the script. If the object cannot be found, using an updating function to update the object property.
Also, make sure that every time you are running your script for standard window, your screen doesn't minimize.
I need to change the time working unit of Maya using the API.
(see Window->Settings/Preferences->Preferences->Settings->Working Units->Time)
So I do:
MTime::Unit mayaTime = MTime::k120FP;
status = MTime::setUIUnit(mayaTime);
[import some animated data]
// For debug
MTime::Unit tm = MTime::uiUnit();
tm is k120FPS so it is ok. Also, animated data are ok. BUT, when I open the GUI, time working units is still the default one...
The documentation says:
"MTime::setUIUnit: Set the unit system to be used by the user in the UI. After the successful completion of this method, Maya's timeslider will be displaying frames in the specified units."
Do you see what I did wrong here?
Thanks for any help.
Try setting the optionVar "workingUnitTime".