{"action":"created","comment":{"url":"https://api.github.com/repos/Microsoft/edx-platform/pulls/comments/234763650","pull_request_review_id":176473640,"id":234763650,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzNDc2MzY1MA==","diff_hunk":"@@ -0,0 +1,99 @@\n+import logging\n+import time\n+\n+from celery.task import task\n+from celery.utils.log import get_task_logger\n+from edxval.api import update_video_status\n+from requests import RequestException\n+\n+from .media_service import AccessPolicyPermissions, LocatorTypes, MediaServiceClient\n+\n+\n+LOGGER = logging.getLogger(__name__)\n+TASK_LOGGER = get_task_logger(__name__)\n+\n+\n+class JobStatus(object):\n+    \"\"\"\n+    Azure Job entity status code enum.\n+\n+    ref: https://docs.microsoft.com/en-us/rest/api/media/operations/job#list_jobs\n+    \"\"\"\n+\n+    QUEUED = 0\n+    SCHEDULED = 1\n+    PROCESSING = 2\n+    FINISHED = 3\n+    ERROR = 4\n+    CANCELED = 5\n+    CANCELING = 6\n+\n+\n+@task()\n+def run_job_monitoring_task(job_id, azure_config):\n+    \"\"\"\n+    Monitor completed Azure encode jobs.\n+\n+    Fetches all jobs, finds all completed, looks for relevant videos with `in progress` status and updates them.\n+    :param job_id: monitored Job ID\n+    :param azure_config: Organization's Azure profile\n+    \"\"\"\n+    TASK_LOGGER.info('Starting job monitoring [{}]'.format(job_id))\n+    ams_api = MediaServiceClient(azure_config)\n+\n+    def get_video_id_for_job(job_id, api_client):\n+        output_media_asset = api_client.get_output_media_asset(job_id)\n+        video_id = output_media_asset['Name'].split('::')[1]\n+        return output_media_asset, video_id\n+\n+    while True:\n+        job_info = ams_api.get_job(job_id)\n+        state = job_info['State']\n+        TASK_LOGGER.info('Got state[{}] for Job[{}]'.format(state, job_id))\n+\n+        if int(state) == JobStatus.FINISHED:\n+            try:\n+                output_media_asset, video_id = get_video_id_for_job(job_id, ams_api)\n+                TASK_LOGGER.info('Starting output Asset publishing [video ID:{}]...'.format(video_id))\n+\n+                TASK_LOGGER.info('Creating AccessPolicy...')\n+                policy_name = u'OpenEdxVideoPipelineAccessPolicy'\n+                access_policy = ams_api.create_access_policy(\n+                    policy_name,\n+                    duration_in_minutes=60 * 24 * 365 * 10,\n+                    permissions=AccessPolicyPermissions.READ\n+                )\n+                TASK_LOGGER.info('Creating streaming locator...')\n+                ams_api.create_locator(\n+                    access_policy['Id'],\n+                    output_media_asset['Id'],\n+                    locator_type=LocatorTypes.OnDemandOrigin\n+                )\n+                TASK_LOGGER.info('Creating progressive locator...')\n+                ams_api.create_locator(\n+                    access_policy['Id'],\n+                    output_media_asset['Id'],\n+                    locator_type=LocatorTypes.SAS\n+                )\n+                # Job is finished and processed asset is published:\n+                update_video_status(video_id, 'file_complete')\n+\n+            except RequestException:","path":"cms/djangoapps/azure_video_pipeline/tasks.py","position":81,"original_position":81,"commit_id":"69288321d2319086549acf900c5d1d3257f7c782","original_commit_id":"69288321d2319086549acf900c5d1d3257f7c782","user":{"login":"vivalams","id":21183036,"node_id":"MDQ6VXNlcjIxMTgzMDM2","avatar_url":"https://avatars0.githubusercontent.com/u/21183036?v=4","gravatar_id":"","url":"https://api.github.com/users/vivalams","html_url":"https://github.com/vivalams","followers_url":"https://api.github.com/users/vivalams/followers","following_url":"https://api.github.com/users/vivalams/following{/other_user}","gists_url":"https://api.github.com/users/vivalams/gists{/gist_id}","starred_url":"https://api.github.com/users/vivalams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vivalams/subscriptions","organizations_url":"https://api.github.com/users/vivalams/orgs","repos_url":"https://api.github.com/users/vivalams/repos","events_url":"https://api.github.com/users/vivalams/events{/privacy}","received_events_url":"https://api.github.com/users/vivalams/received_events","type":"User","site_admin":false},"body":"Please add a generic exception here too","created_at":"2018-11-19T20:06:17Z","updated_at":"2018-11-19T20:08:35Z","html_url":"https://github.com/Microsoft/edx-platform/pull/350#discussion_r234763650","pull_request_url":"https://api.github.com/repos/Microsoft/edx-platform/pulls/350","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/Microsoft/edx-platform/pulls/comments/234763650"},"html":{"href":"https://github.com/Microsoft/edx-platform/pull/350#discussion_r234763650"},"pull_request":{"href":"https://api.github.com/repos/Microsoft/edx-platform/pulls/350"}}},"pull_request":{"url":"https://api.github.com/repos/Microsoft/edx-platform/pulls/350","id":223150256,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIzMTUwMjU2","html_url":"https://github.com/Microsoft/edx-platform/pull/350","diff_url":"https://github.com/Microsoft/edx-platform/pull/350.diff","patch_url":"https://github.com/Microsoft/edx-platform/pull/350.patch","issue_url":"https://api.github.com/repos/Microsoft/edx-platform/issues/350","number":350,"state":"open","locked":false,"title":"Azure course videos as course introduction video","user":{"login":"oksana-slu","id":352595,"node_id":"MDQ6VXNlcjM1MjU5NQ==","avatar_url":"https://avatars1.githubusercontent.com/u/352595?v=4","gravatar_id":"","url":"https://api.github.com/users/oksana-slu","html_url":"https://github.com/oksana-slu","followers_url":"https://api.github.com/users/oksana-slu/followers","following_url":"https://api.github.com/users/oksana-slu/following{/other_user}","gists_url":"https://api.github.com/users/oksana-slu/gists{/gist_id}","starred_url":"https://api.github.com/users/oksana-slu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oksana-slu/subscriptions","organizations_url":"https://api.github.com/users/oksana-slu/orgs","repos_url":"https://api.github.com/users/oksana-slu/repos","events_url":"https://api.github.com/users/oksana-slu/events{/privacy}","received_events_url":"https://api.github.com/users/oksana-slu/received_events","type":"User","site_admin":false},"body":"This PR makes it possible to set video (in addition to Youtube direct VideoID) from Video Uploads page (and stored on Azure service) as course's introduction video (`Studio => Settings => Schedule & Details => Course Details section`).\r\n\r\nPlease, see details in [inner README](https://github.com/raccoongang/edx-platform/blob/hawthorn_master_4racoongang_pr_3_course_about/cms/djangoapps/azure_video_pipeline/README.md#course-introduction-video-enhancements)\r\n\r\n#### Added \r\n\r\n- Azure Media Player used for Azure videos playback (LMS + CMS);\r\n\r\n#### Changed\r\n\r\n- JS / python unit tests coverage improved;\r\n\r\nNote: this PR includes changes from the [#344](https://github.com/Microsoft/edx-platform/pull/344) and based on the top of those changes.","created_at":"2018-10-16T08:01:08Z","updated_at":"2018-11-19T20:08:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"283362999028bc74a68740fc63f01820a8be23c2","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Microsoft/edx-platform/pulls/350/commits","review_comments_url":"https://api.github.com/repos/Microsoft/edx-platform/pulls/350/comments","review_comment_url":"https://api.github.com/repos/Microsoft/edx-platform/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Microsoft/edx-platform/issues/350/comments","statuses_url":"https://api.github.com/repos/Microsoft/edx-platform/statuses/69288321d2319086549acf900c5d1d3257f7c782","head":{"label":"raccoongang:hawthorn_master_4racoongang_pr_3_course_about","ref":"hawthorn_master_4racoongang_pr_3_course_about","sha":"69288321d2319086549acf900c5d1d3257f7c782","user":{"login":"raccoongang","id":11388447,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExMzg4NDQ3","avatar_url":"https://avatars0.githubusercontent.com/u/11388447?v=4","gravatar_id":"","url":"https://api.github.com/users/raccoongang","html_url":"https://github.com/raccoongang","followers_url":"https://api.github.com/users/raccoongang/followers","following_url":"https://api.github.com/users/raccoongang/following{/other_user}","gists_url":"https://api.github.com/users/raccoongang/gists{/gist_id}","starred_url":"https://api.github.com/users/raccoongang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raccoongang/subscriptions","organizations_url":"https://api.github.com/users/raccoongang/orgs","repos_url":"https://api.github.com/users/raccoongang/repos","events_url":"https://api.github.com/users/raccoongang/events{/privacy}","received_events_url":"https://api.github.com/users/raccoongang/received_events","type":"Organization","site_admin":false},"repo":{"id":26811891,"node_id":"MDEwOlJlcG9zaXRvcnkyNjgxMTg5MQ==","name":"edx-platform","full_name":"raccoongang/edx-platform","private":false,"owner":{"login":"raccoongang","id":11388447,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExMzg4NDQ3","avatar_url":"https://avatars0.githubusercontent.com/u/11388447?v=4","gravatar_id":"","url":"https://api.github.com/users/raccoongang","html_url":"https://github.com/raccoongang","followers_url":"https://api.github.com/users/raccoongang/followers","following_url":"https://api.github.com/users/raccoongang/following{/other_user}","gists_url":"https://api.github.com/users/raccoongang/gists{/gist_id}","starred_url":"https://api.github.com/users/raccoongang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raccoongang/subscriptions","organizations_url":"https://api.github.com/users/raccoongang/orgs","repos_url":"https://api.github.com/users/raccoongang/repos","events_url":"https://api.github.com/users/raccoongang/events{/privacy}","received_events_url":"https://api.github.com/users/raccoongang/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/raccoongang/edx-platform","description":"Open edX, the edX platform that powers http://edx.org","fork":true,"url":"https://api.github.com/repos/raccoongang/edx-platform","forks_url":"https://api.github.com/repos/raccoongang/edx-platform/forks","keys_url":"https://api.github.com/repos/raccoongang/edx-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/raccoongang/edx-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/raccoongang/edx-platform/teams","hooks_url":"https://api.github.com/repos/raccoongang/edx-platform/hooks","issue_events_url":"https://api.github.com/repos/raccoongang/edx-platform/issues/events{/number}","events_url":"https://api.github.com/repos/raccoongang/edx-platform/events","assignees_url":"https://api.github.com/repos/raccoongang/edx-platform/assignees{/user}","branches_url":"https://api.github.com/repos/raccoongang/edx-platform/branches{/branch}","tags_url":"https://api.github.com/repos/raccoongang/edx-platform/tags","blobs_url":"https://api.github.com/repos/raccoongang/edx-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/raccoongang/edx-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/raccoongang/edx-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/raccoongang/edx-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/raccoongang/edx-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/raccoongang/edx-platform/languages","stargazers_url":"https://api.github.com/repos/raccoongang/edx-platform/stargazers","contributors_url":"https://api.github.com/repos/raccoongang/edx-platform/contributors","subscribers_url":"https://api.github.com/repos/raccoongang/edx-platform/subscribers","subscription_url":"https://api.github.com/repos/raccoongang/edx-platform/subscription","commits_url":"https://api.github.com/repos/raccoongang/edx-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/raccoongang/edx-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/raccoongang/edx-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/raccoongang/edx-platform/issues/comments{/number}","contents_url":"https://api.github.com/repos/raccoongang/edx-platform/contents/{+path}","compare_url":"https://api.github.com/repos/raccoongang/edx-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/raccoongang/edx-platform/merges","archive_url":"https://api.github.com/repos/raccoongang/edx-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/raccoongang/edx-platform/downloads","issues_url":"https://api.github.com/repos/raccoongang/edx-platform/issues{/number}","pulls_url":"https://api.github.com/repos/raccoongang/edx-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/raccoongang/edx-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/raccoongang/edx-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/raccoongang/edx-platform/labels{/name}","releases_url":"https://api.github.com/repos/raccoongang/edx-platform/releases{/id}","deployments_url":"https://api.github.com/repos/raccoongang/edx-platform/deployments","created_at":"2014-11-18T14:05:58Z","updated_at":"2018-09-21T09:16:05Z","pushed_at":"2018-11-19T15:32:58Z","git_url":"git://github.com/raccoongang/edx-platform.git","ssh_url":"git@github.com:raccoongang/edx-platform.git","clone_url":"https://github.com/raccoongang/edx-platform.git","svn_url":"https://github.com/raccoongang/edx-platform","homepage":"http://openedx.org/","size":1070949,"stargazers_count":9,"watchers_count":9,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":13,"mirror_url":null,"archived":false,"open_issues_count":12,"license":{"key":"agpl-3.0","name":"GNU Affero General Public License v3.0","spdx_id":"AGPL-3.0","url":"https://api.github.com/licenses/agpl-3.0","node_id":"MDc6TGljZW5zZTE="},"forks":13,"open_issues":12,"watchers":9,"default_branch":"ginkgo-rg"}},"base":{"label":"Microsoft:hawthorn_master_4racoongang","ref":"hawthorn_master_4racoongang","sha":"58d2ac8c92c4cffe3d8db180b45bdcfba7040a7f","user":{"login":"Microsoft","id":6154722,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYxNTQ3MjI=","avatar_url":"https://avatars2.githubusercontent.com/u/6154722?v=4","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":65483935,"node_id":"MDEwOlJlcG9zaXRvcnk2NTQ4MzkzNQ==","name":"edx-platform","full_name":"Microsoft/edx-platform","private":false,"owner":{"login":"Microsoft","id":6154722,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYxNTQ3MjI=","avatar_url":"https://avatars2.githubusercontent.com/u/6154722?v=4","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Microsoft/edx-platform","description":"The Open edX platform, the software that powers edX!","fork":true,"url":"https://api.github.com/repos/Microsoft/edx-platform","forks_url":"https://api.github.com/repos/Microsoft/edx-platform/forks","keys_url":"https://api.github.com/repos/Microsoft/edx-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/edx-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/edx-platform/teams","hooks_url":"https://api.github.com/repos/Microsoft/edx-platform/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/edx-platform/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/edx-platform/events","assignees_url":"https://api.github.com/repos/Microsoft/edx-platform/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/edx-platform/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/edx-platform/tags","blobs_url":"https://api.github.com/repos/Microsoft/edx-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/edx-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/edx-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/edx-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/edx-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/edx-platform/languages","stargazers_url":"https://api.github.com/repos/Microsoft/edx-platform/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/edx-platform/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/edx-platform/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/edx-platform/subscription","commits_url":"https://api.github.com/repos/Microsoft/edx-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/edx-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/edx-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/edx-platform/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/edx-platform/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/edx-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/edx-platform/merges","archive_url":"https://api.github.com/repos/Microsoft/edx-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/edx-platform/downloads","issues_url":"https://api.github.com/repos/Microsoft/edx-platform/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/edx-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/edx-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/edx-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/edx-platform/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/edx-platform/releases{/id}","deployments_url":"https://api.github.com/repos/Microsoft/edx-platform/deployments","created_at":"2016-08-11T16:18:42Z","updated_at":"2018-11-08T22:13:08Z","pushed_at":"2018-11-14T17:34:39Z","git_url":"git://github.com/Microsoft/edx-platform.git","ssh_url":"git@github.com:Microsoft/edx-platform.git","clone_url":"https://github.com/Microsoft/edx-platform.git","svn_url":"https://github.com/Microsoft/edx-platform","homepage":"http://open.edx.org/","size":944166,"stargazers_count":20,"watchers_count":20,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":29,"mirror_url":null,"archived":false,"open_issues_count":11,"license":{"key":"agpl-3.0","name":"GNU Affero General Public License v3.0","spdx_id":"AGPL-3.0","url":"https://api.github.com/licenses/agpl-3.0","node_id":"MDc6TGljZW5zZTE="},"forks":29,"open_issues":11,"watchers":20,"default_branch":"oxa/dev.fic"}},"_links":{"self":{"href":"https://api.github.com/repos/Microsoft/edx-platform/pulls/350"},"html":{"href":"https://github.com/Microsoft/edx-platform/pull/350"},"issue":{"href":"https://api.github.com/repos/Microsoft/edx-platform/issues/350"},"comments":{"href":"https://api.github.com/repos/Microsoft/edx-platform/issues/350/comments"},"review_comments":{"href":"https://api.github.com/repos/Microsoft/edx-platform/pulls/350/comments"},"review_comment":{"href":"https://api.github.com/repos/Microsoft/edx-platform/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Microsoft/edx-platform/pulls/350/commits"},"statuses":{"href":"https://api.github.com/repos/Microsoft/edx-platform/statuses/69288321d2319086549acf900c5d1d3257f7c782"}},"author_association":"NONE"}}
{"actor":{"display_login":"vivalams"}}