Winidea Python script called from Jenkins - python-3.x

I am trying to launch Winidea configuration stored on U: drive. I am able to execute this script using command promt. However when I am trying to execute this script using Jenkins, it is giving error related to dll. My code is
import isystem.connect as ic
import time
print('isystem.connect version: ' + ic.getModuleVersion())
# 1. connect to winIDEA Application
pathTowinIDEA = 'C:/winIDEA/iConnect.dll'
cmgr_APPL = ic.ConnectionMgr(pathTowinIDEA)
cmgr_APPL.connectMRU('U:/winIDEA/myconfig.xjrf')
debug_APPL = ic.CDebugFacade(cmgr_APPL)
ec = ic.CExecutionController(cmgr_APPL)
The error is coming at line
cmgr_APPL.connectMRU('U:/winIDEA/myconfig.xjrf')
Error is as follow
enter image description here

Related

My script works flawlessly in IDE but gives error when run in CMD

The following code takes in path to an image, removes the background, and saves it to desktop under a name the user decides:
from rembg import remove
from PIL import Image
input_path = input("Please Drag & Drop an image:") # Takes image path
output_name = input("Give it a name:")
output_path = rf'C:\Users\user\Desktop\{output_name}.png'
input_image = Image.open(input_path)
output = remove(input_image)
output.save(output_path)
It works fine when I run it in PyCharm. I copy the image file, the code executes flawlessly and the output is seen in the desktop. But when I run the code through CMD terminal, it asks for image, and I drag the image to the terminal and it copies the path and everything works well, but when I press enter to begin I get this error and I cannot figure out what is the issue:
Does anyone know what the issue is?
You may encounter the loadlibrary failed with error 126 when the problematic application does not have the privileges to access a protected system resource. In this case, launching the problematic application as an administrator may solve the problem. I would recommend running the CMD terminal as an administrator

How to execute Chrome-webdriver in Azure Cloud Service?

You are about to run the chrome-webdriver on an azure cloud service.
However, the following error occurs.
chrome_webdriver sample code
from selenium import webdriver
driver = webdriver.Chrome('/.chromedriver.exe')
url = "https://www.instagram.com/"
driver.get(url)
If you look at the picture, I put the chrome-driver file in the same directory as .ipynb
The path was set to './chromedriver.exe', but an error occurred.
Other attempted methods
1. driver = webdriver.Chrome(r"\chromedriver.exe")
2. driver = webdriver.Chrome("\\chromedriver.exe")
3. driver = webdriver.Chrome("/chromedriver.exe")
-> I tried a different method, but an error occurred.
how to chrome-webdriver excute in azure cloud service?
Vova Bilyachat Update posts for comments
1. driver = webdriver.Chrome('./Users/admin/chromedriver.exe')
-> Message: 'chromedriver.exe' executable needs to be in PATH.
2. driver = webdriver.Chrome('./chromedriver.exe')
-> OSError: [Errno 8] Exec format error: './chromedriver.exe'
update post2
I think your error is that you set path "/chromedriver.exe" which is looking for file in root folder, change it to "./chromedriver.exe" where "./" means start from folder you execute script
Also you must be sure that you deployed right driver for right Operating System
And since its linux use
driver = webdriver.Chrome('/.chromedriver')

Python Script Executes Manually in CMD but Errors in Scheduler

So, I have a python script, that I can run in cmd using python [path to script]
I have it set in scheduler, but it doesn't run through scheduler and finds an error. Cmd closes out before being able to read the error. I created a batch file to launch to script, and it shows an error that a package doesn't exist [lxml]. But, the package exists as the script will run when manually executed
Any thoughts?
Script scrapes data from a website, creates a dataframe, posts dataframe to a google sheet, then pulls the full google sheet that it posts to, turns that into a dataframe with all of the data, then creates a plotly graph, turns that plotly into an html file, then sends the html file to a SFTP server
Figured it out...
import sys
import platform
import imp
print("Python EXE : " + sys.executable)
print("Architecture : " + platform.architecture()[0])
#print("Path to arcpy : " + imp.find_module("arcpy")[1])
#raw_input("\n\nPress ENTER to quit")
Run this to get the proper path to your Python.exe, and place this in Program/Script.
Then you need to verify that EVERY directory in your script starts at C:/ and works its way through the full path.

How can I set run_name in mlflow command line?

MLFlow version: 1.4.0
Python version: 3.7.4
I'm running the UI as mlflow server... with all the required command line options.
I am logging to MLFlow as an MLFlow project, with the appropriate MLproject.yaml file. The project is being run on a Docker container, so the CMD looks like this:
mlflow run . -P document_ids=${D2V_DOC_IDS} -P corpus_path=... --no-conda --experiment-name=${EXPERIMENT_NAME}
Running the experiment like this results in a blank run_name. I know there's a run_id but I'd also like to see the run_name and set it in my code -- either in the command line, or in my code as mlflow.log.....
I've looked at Is it possible to set/change mlflow run name after run initial creation? but I want to programmatically set the run name instead of changing it manually on the UI.
One of the parameters to mlflow.start_run() is run_name. This would give you programmatic access to set the run name with each iteration. See the docs here.
Here's an example:
from datetime import datetime
## Define the name of our run
name = "this run is gonna be bananas" + datetime.now()
## Start a new mlflow run and set the run name
with mlflow.start_run(run_name = name):
## ...train model, log metrics/params/model...
## End the run
mlflow.end_run()
If you want to include set the name as part of an MLflow Project, you'll have to specify it as a parameter in the entry points to the project. This is located in in the MLproject file. Then you can pass those values into the mlflow.start_run() function from the command line.
for CLI, this seems to now be available:
--run-name <runname>
https://mlflow.org/docs/latest/cli.html#cmdoption-mlflow-run-run-name

Execute Long running jobs from bottle web server

What I am trying to do
I have a front end system that is generating output. I am accessing this data(JSON) with a post request using bottle. My post receives the json without issue. I need to execute a backend python program(blender automation) and pass this JSON data to that program.
What I have tried to do
Subprocess - Using subprocess call the program and pass the input. In appearance seems to execute but when i check System Monitor the program is not starting but my server continues to run as it should. This subprocess command runs perfectly fine when executed independently from the server.
blender, script, and json are all string objects with absolute file paths
sub = subprocess.Popen([blender + " -b -P " + script + " -- " + json], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)
C Style os.fork() - Same as above which i found reading pydoc that subprocess operates using these methods
Double Fork - From a posting on here tried forking from the server and then calling subprocess from that fork and terminating the parent of the subprocess to create an orphan. My subprocess command still does not execute and never shows up in System Monitor.
What I need
I need a solution that will run from the bottle server in its own process. It will handle multiple requests so the subprocess cannot block in the server. The process being called is fully automated and just requires sending the JSON data in the execution command. The result of the subprocess program will be string path to a file created on the server.
The above subprocess works perfectly fine when called from my test driver program. I just need to connect the execution to the webservice so my front end can trigger its execution.
My bottle post method - prints json when called without issue.
#post('/getData')
def getData():
json_text = request.json
print(json_text)
I am not sure where to go from here. From what i have read thus far, subprocess should work. Any help or suggestions would be very much appreciated. If additional information is needed please let me know. I will edit with more details. Thank you.
Relevant Information:
OS: Ubuntu 16.04 LTS,
Python 3.x
*EDIT
This isn't an elegant solution but my subprocess call works now.
cmd = blender
cmd += " -b -P "
cmd += script
cmd += " -- "
cmd += str(json)
sub = subprocess.Popen([cmd], shell=True)
It seems by setting shell=True and removing the stdout, stderr=PIPE allowed me to see output where i was throwing an unhandled exception because my json data was a list and not a string.
When using python for executing your scripts a process created by Popen.subprocess will unintentionally inherited and keeps open a file descriptor.
You need to close that so that process can run independently. (close_fds=True)
subprocess.Popen(['python', "-u", Constant.WEBAPPS_FOLDER + 'convert_file.py', src, username], shell=False, bufsize=-1, close_fds=True)
Alsso, u dont have to use shell for creating another process. It might have unintended consequences.
I had the exact same problem where bottle was not returning/hangs. It works now.

Resources