Unable to get the result from Google machine learning Cloud REST API - machine-learning

I am trying to run a job using Google Cloud Machine Learning REST-API ml.jobs.project.create
The latest job that I submitted has job id 'drivermonitoring20180109335'. Here on completion of the job, message 'job completed successfully' is displayed but I cannot see any desired output file in the specified location. Output logs can be seen in fig1
Also I would like to keep in-front of you my few observations while running this job id:
i) Running the job took very less time in comparison to any other job that I executed before.
ii) While running jobs before, every job earlier was executed via two different tasks viz a)master-replica-0 and b)service (refer fig2) but this job didn't have master-replica-0 task(refer fig3) I tried to Google the issue, but was unable to find any solution related to the issue.
So I can infer that the task that I was trying to run is being scheduled but the python script that I am trying to run is never scheduled to be executed.
Kindly let me know if you require more screenshots or if you want to have a look at the project structure to help with the issue.
Thanks in advance.
EDIT 1: Added JSON while making API call
POST https://ml.googleapis.com/v1/projects/drivermonitoringsystem/jobs?key={YOUR_API_KEY}
{
"trainingInput": {
"pythonModule": "trainer.retrain",
"args": [
"--bottleneck_dir=ModelTraining/tf_files/bottlenecks \
--model_dir=ModelTraining/tf_files/models/ \
--architecture=mobilenet_0.50_224 \
--output_graph=gs://<BUCKET_NAME>/tf_files/retrained_graph.pb \
--output_labels=gs://<BUCKET_NAME>/tf_files/retrained_labels.txt \
--image_dir=gs://<BUCKET_NAME>/dataset224x224/"
],
"region": "us-central1",
"packageUris": [
"gs://<BUCKET_NAME>/ModelTraining4.tar.gz"
],
"jobDir": "gs://<BUCKET_NAME>/tf_files/",
"runtimeVersion": "1.4"
},
"jobId": "job_id201801101535"
}

I have just run myself some sample jobs using both the gcloud command and the REST API, and everything has just worked fine in both of the cases. It looks like, in your case, the job was never executed, as there is no cluster created for processing the job itself (that is why master-replica-0 is missing).
The jobs that you had run previously and which had worked were launched also using the REST API, or instead with gcloud or a Client Library?
Here I share an example JSON I used when making the API call to ml.projects.jobs.create through the API Explorer link you shared, I suggest you try adapting it to your requirements and check if you got any missing field:
POST https://ml.googleapis.com/v1/projects/<YOUR_PROJECT>/jobs?key={YOUR_API_KEY}
{
"jobId": "<JOB_ID>",
"trainingInput": {
"jobDir": "gs://<LOCATION_TO_STORE_OUTPUTS>",
"runtimeVersion": "1.4",
"region": "<REGION>",
"packageUris": [
"gs://<PATH_TO_YOUR_TRAINER>/trainer-0.0.0.tar.gz"
],
"pythonModule": "<PYTHON_MODULE_TO_RUN>",
"args": [
"--train-files",
"gs://<PATH_TO_YOUR_TRAINING_DATA>/data.csv",
"--eval-files",
"gs://<PATH_TO_YOUR_TEST_DATA>/test.csv",
"--train-steps",
"100",
"--eval-steps",
"10",
"--verbosity",
"DEBUG"
]
}
}
Change TrainingInput to PredictionInput (and the appropriate child fields) if you are trying to run a prediction job instead of a training one, as in this example.

Related

Cancel job within CircleCI workflow when another workflow with that job is triggered

Let's say we have a workflow called Workflow1 which contains jobs A, B, C and D.
First developer pushes a change and triggers Workflow1.
Second developer also pushes a change and triggers Workflow1.
Is there a way to ensure that when job C starts in the second developer's workflow, it automatically cancels only job C in the first developer's workflow, without affecting any of the other jobs?
You could implement something using the CircleCI API v2 and some jq wizardry. Note: you'll need to create a personal API token, and store it in an environment variable (let's call it MyToken)
I'm suggesting the below approach, but there could be another (maybe simpler ¯\_(ツ)_/¯) way.
Get the IDs of pipelines in the project that have the created status:
PIPE_IDS=$(curl --header "Circle-Token: $MyToken" --request GET "https://circleci.com/api/v2/project/gh/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pipeline?branch=$CIRCLE_BRANCH"|jq -r '.items[]|select(.state == "created")')
Get the IDs of currently running/on_hold workflows with the name Workflow1 excluding the current workflow ID:
if [ ! -z "$PIPE_IDS" ]; then
for PIPE_ID in $PIPE_IDS
do curl --header "Circle-Token: $MyToken" --request GET "https://circleci.com/api/v2/pipeline/${PIPE_ID}/workflow"|jq -r --arg CIRCLE_WORKFLOW_ID "$CIRCLE_WORKFLOW_ID" '.items[]|select(.status == "on_hold" or .status == "running")|select(.name == "Workflow1")|select(.id != $CIRCLE_WORKFLOW_ID)|.id' >> currently_running_Workflow1s.txt
done
fi
Then (sorry, I'm getting a bit lazy here, and you also need to do some of the work :p), use the currently_running_Workflow1s.txt file generated above and the "Get a workflow's jobs" endpoint to get the job number of each job in the related running Workflow1 workflows whose name matches job C and that has a status running.
Finally, use the "Cancel job" endpoint to cancel each of these jobs.
Note that there might be a slight delay between the "cancel API call" and the job actually being cancelled, so you might want to add
a short sleep, or even better a while loop that checks those
jobs' respective statuses, before moving further.
I hope this helps.

Self-delete Jenkins builds after they're finished

tl;dr: I'd like to delete builds from within their execution, or rather, in a post statement (though the specifics shouldn't matter).
Background: In a project I'm working on, there is a "gateway" job of sorts that aggregates all new job triggers into one launch as long as certain other jobs are still running. For this purpose, this job aborts itself such that there is only ever one instance running (which is often not the latest build).
Unfortunately, this means that in the job preview, the job is often shown as aborted, which is undesirable (ending the job as "successful" or some other status wouldn't improve anything). Thus, I have two options:
Change the abortion logic so the newest build survives and older ones are aborted. This is technically possible, but has other drawbacks due to some internal logic, which is why I'd like to avoid this solution.
Delete the aborted builds once they're finished
However, this is apparently not as easy as just calling the "doDelete" REST API inside the job, and the build discarder can't be set to store 0 builds (it needs to be a positive integer). This is what I tried code-wise (MWE):
steps {
script {
currentBuild.result = 'ABORTED'
error("abort")
}
}
post {
always {
withCredentials([string(credentialsId: 'x', variable: 'TOKEN')]) {
sh "curl -X POST \"https://jenkins.example.com/etc/job/jobname/${env.BUILD_NUMBER}/doDelete\" -i -H 'Authorization: Bearer $TOKEN'"
}
}
}
This code deletes some job information (for instance, the console log is empty), but not the build itself. Thus, my question remains:
How can I make a job delete itself?

Dataflow Job success but data is not transferred

I have Cloud Dataflow Job to pull the data from Oracle to Google CloudSQL in GCP Project which has VPC/VPN setup. Scheduled this dataflow job using Composer and executed it periodically. It was working fine, however sometime Dataflow Job executes successfully but data is not moved to CloudSQL. Nothing error/ specific events from Logs. Its weird...This happens very rare... It would be good if any one give suggestion to find out the root cause of this case.
Here is the dataflow operator definition,
dataFlowStatus = DataFlowJavaOperator( task_id='dataflowlabelstatus', jar=jar_pathr, gcp_conn_id='google_cloud_default', options={ 'project': project_id, 'region': gcp_region, 'usePublicIps': ip_condition, 'stagingLocation': staging_location, 'tempLocation': staging_location, 'subnetwork': gcp_sub_network, 'RTMaxDate': "{{ task_instance.xcom_pull(task_ids='validateDate', key='job_last_fetch_date') }}", 'oracleJDBCSource': oracle_connection_url, 'oracleUserName': rm_username, 'oraclePassword': rm_password, 'postgreUserName_RT': receipt_username, 'postgrePassword_RT': receipt_password, 'postgresDatabaseName_RT': receipt_schema, 'postgreUserName_Label': label_username, 'postgrePassword_Label': label_password, 'postgresDatabaseName_Label': label_schema, 'cloudSqlInstance_RT': receipt_cloud_instance, 'cloudSqlInstance_Label': label_cloud_instance, 'autoscalingAlgorithm': 'BASIC', 'maxNumWorkers': '50' }, dag=dag )

Custom build task not showing in YAML task list

We wrote a custom Azure DevOps build task, but we can't find it in the YAML editor task list. It doesn't even show up in search.
This is my task.json:
{
"id": "17813657-13c6-4cd8-b245-8d8b3b0cf210",
"name": "ApplitoolsBuildTask",
"friendlyName": "Applitools Build Task",
"description": "Add the Applitools dashboard as a tab in the Azure DevOps build results page.",
"categories": [ "Build" ],
"category": "Build",
"author": "Applitools",
"version": {
"Major": 0,
"Minor": 44,
"Patch": 0
},
"instanceNameFormat": "Applitools Build Task $(version)",
"execution": {
"Node": {
"target": "dist/index.js"
}
}
}
I also tried with only categories property, and it still didn't show in the search.
I then tried downloading Augurk locally and examined its content (also available in GitHub: https://github.com/Augurk/vsts-extension/tree/master/src), and I saw in AugurkCLI it doesn't even have categories property, as it has a typo: categorues, and for some reason it still shows up. This leads me to think there's no relation between that property and the task list.
I also tried examining the XML file and saw it has <PublisherDetails> section, which my .vsix file doesn't have. What should I put in my vss-extension.json file to have it? And will it help getting my extension to show up in the Task List?
Note that in the Classic editor (the one with the UI) I see it just fine, in the right categories (if I have the "category" property), and if I don't have it then it still shows up when I search. The problem I have is to get my build-task to show up in the YAML editing Task List.
Indeed, our team is fixing this issues now. The issue caused by the YAML assistant panel doesn't allow tasks without input parameters. But worked in classic editor.
Before our fixed release deployed, you can use this workaround to achieve your customize task appeared in the YAML editor task list:
Change your script to accept an input parameter. And then the task will appeared in YAML editor task list.
You can reference this ticket we received recently. We will inform you here once we deployed the fixed release and the issue be fixed.
Well, it seems it's a bug on Microsoft side. I don't have any input fields in the build task, and the Azure DevOps YAML editor task list filters out any task that doesn't have input fields.
They told me they had fixed it:
https://developercommunity.visualstudio.com/content/problem/576169/our-custom-azure-devops-build-task-doesnt-show-in.html
The fix should be available in a few weeks.

How to pass pipeline variables to post build gerrit message?

I have a Pylint running in a Jenkins pipeline. To implement it, I used Gerrit trigger plugin and Next Generation Warnings plugin. Everything is working as expected - Jenkins is joining the review, checks change with pylint and generates report.
Now, I'd like to post pylint score in a custom "Build successful" message. I wanted to pass the pylint score to a environment variable and use it in dedicated window for Gerrit plugin message.
Unfortunately no matter what I try, I cannot pass any "new" variable to the message. Passing parameters embedded in pipeline works (e.g. patchset number).
I created new environment variable in Configure Jenkins menu, tried exporting to shell, writing to it (via $VAR and env. syntax) but nothing works - that is, build message displays raw string like $VAR instead of what variable contains.
What should I do to pass local pylint score (distinct for every pipeline occurence) to the custom build message for Gerrit?
I don't think the custom message can be used for this. This is just supposed to be a static message.
They way I do this is to use the SSH command to perform the review. You can also achieve the same using the REST API.
First I run my linting and white space checking script that will generate a json file with the information I would like to pass to Gerrit. Next I send it to Gerrit using SSH. See below my pipeline script and an example json file.
As a bonus I have added the robot comments. This will now show up in your review as a remark from Jenkins that line 8 of my Jenkins file has a trailing white space. You can easily replace this with your lint result of you like or just ignore it and only put the message. It is easier to use a json file as it will make it easier to create multi line messages
node('master') {
sh """
cat lint_change.json | ssh -p ${env.GERRIT_PORT} ${env.GERRIT_HOST} gerrit review ${env.GERRIT_PATCHSET_REVISION} --json
"""
}
Example json file:
{
"labels": {
"Code-Style": "-1"
},
"message": "Lint Bot Review\nLint Results:\n Errors: 0\n Warnings: 0\n\nWhitespace results:\n Errors: 1",
"robot_comments": {
"Jenkinsfile": [
{
"robot_id": "lint-bot",
"line": "8",
"message": "trailing whitespace."
}
]
}
}
Alternatively, you may want to look at a new gerrit-code-review-plugin that should make this things even easier. However, I have not tried this yet.

Resources