Return a dictionary of {app_id: (app_name, tracking_url)} for running Spark applications.
434952
def _mesos_init(self, instance, master_address, requests_config, tags):
        
        running_apps = {}

        metrics_json = self._rest_request_to_json(
            master_address, MESOS_MASTER_APP_PATH, MESOS_SERVICE_CHECK, requests_config, tags
        )

        if metrics_json.get('frameworks'):
            for app_json in metrics_json.get('frameworks'):
                app_id = app_json.get('id')
                tracking_url = app_json.get('webui_url')
                app_name = app_json.get('name')

                if app_id and tracking_url and app_name:
                    spark_ports = instance.get('spark_ui_ports')
                    if spark_ports is None:
                        # No filtering by port, just return all the frameworks
                        running_apps[app_id] = (app_name, tracking_url)
                    else:
                        # Only return the frameworks running on the correct port
                        tracking_url_port = urlparse(tracking_url).port
                        if tracking_url_port in spark_ports:
                            running_apps[app_id] = (app_name, tracking_url)

        # Report success after gathering all metrics from ResourceManager
        self.service_check(
            MESOS_SERVICE_CHECK,
            AgentCheck.OK,
            tags=['url:%s' % master_address] + tags,
            message='Connection to ResourceManager "%s" was successful' % master_address,
        )

        return running_apps
580486
def executor_ips(sc):
    
    try:
        app_id = sc.applicationId
    except AttributeError:
        app_id = sc.getConf().get('spark.app.id')
    # for getting the url (see: https://github.com/apache/spark/pull/15000)
    try:
        base_url = sc.uiWebUrl
    except AttributeError:
        base_url = sc._jsc.sc().uiWebUrl().get()
    url = base_url + '/api/v1/applications/' + app_id + '/executors'
    try:
        data = json.load(urlopen(url))
    except TypeError:
        response = urlopen(url)
        str_response = response.read().decode('utf-8')
        data = json.loads(str_response)
    ips = set(map(lambda x: x[u'hostPort'].split(':')[0], data))
    return ips
643519
def application_name(self):
        
        if self._application_name is None and self.units:
            self._application_name = self.units[0].unit_name.split('/')[0]
        return self._application_name
953636
def app_id(iface=''):
    
    if iface:
        return uniqid(iface)

    if platform.system() == 'Darwin':
        _ava_start = ['en']
    elif platform.system() == 'Linux':
        _ava_start = ['eth', 'wla']
    else:
        return None

    nics = psutil.net_if_addrs()
    _ifces = list(nics.keys())
    _ifces.sort()

    for _ in _ifces:
        if _[:len(_ava_start[0])] in _ava_start:
            return uniqid(_)
756693
def get_process_by_id(self, process_id):
        
        route_values = {}
        if process_id is not None:
            route_values['processId'] = self._serialize.url('process_id', process_id, 'str')
        response = self._send(http_method='GET',
                              location_id='93878975-88c5-4e6a-8abb-7ddd77a8a7d8',
                              version='5.1-preview.1',
                              route_values=route_values)
        return self._deserialize('Process', response)
1283871
def get_urls(self):
        

        info = self.model._meta.app_label, self.model._meta.model_name
        return [
            url(r'^report/(?P<key>\w+)/(?P<period>\w)$',
                self.admin_site.admin_view(self.report_view),
                name='%s_%s_tracking_report' % info)
        ] + super(TrackedLiveAdmin, self).get_urls()
1167175
def load(app_id):
    """"""
    path_to_data = find_experiment_export(app_id)
    if path_to_data is None:
        raise IOError("Dataset {} could not be found.".format(app_id))

    return Data(path_to_data)
924102
def read_data(self, **kwargs):
        
        model = get_model(kwargs['app_label'], kwargs['model_name'])

        return model.objects.get(trigger_id=kwargs['trigger_id'])
321444
def get_app(self, reference_app=None):
        """"""

        if reference_app is not None:
            return reference_app

        if current_app:
            return current_app._get_current_object()

        if self.app is not None:
            return self.app

        raise RuntimeError(
            'No application found. Either work inside a view function or push'
            ' an application context. See'
            ' http://flask-sqlalchemy.pocoo.org/contexts/.'
        )
107284
def get_tracer(
        app: Application, tracer_key: str = APP_AIOZIPKIN_KEY) -> Tracer:
    
    return cast(Tracer, app[tracer_key])
72800
def get_application(self, id=None, name=None):
        
        log.info("Picking application: %s (%s)" % (name, id))
        return self.applications[id or name]
846728
def devices(self):
        """"""
        params = {'access_token': self.access_token}
        r = self.spark_api.GET(params=params, timeout=self.timeout)
        self._check_error(r)
        json_list = r.json()

        devices_dict = {}
        if json_list:
            # it is possible the keys in json responses varies from one device to another: compute the set of all keys
            allKeys = {'functions', 'variables', 'api', 'requires_deep_update', 'status'} # added by device_info
            for device_json in json_list:
                allKeys.update(device_json.keys())

            Device = _BaseDevice.make_device_class(self, allKeys, timeout = self.timeout)
                    
            for d in json_list:
                if d["connected"]:
                    info = self._get_device_info(d['id'])
                    d['functions'] = info.get('functions')
                    d['variables'] = info.get('variables')
                    d['api'] = self.spark_api(d['id'])
                    d['requires_deep_update'] = d.get('requires_deep_update', False)
                    d['status'] = info.get('status')
                # ensure the set of all keys is present in the dictionnary (Device constructor requires all keys present)
                [d.setdefault(key, None) for key in allKeys]

                devices_dict[d['name']] = Device(**d)
                
        return devices_dict
1046888
function getAppContextFromArgv(apps) {
  return Promise.try(function() {
    return _.find(apps, function(app) {
      return app.name === argv.payload[0];
    });
  });
}
674057
def get_app_properties(self, token: dict = None, prot: str = "https"):
        
        # check if app properties have already been retrieved or not
        if not hasattr(self, "app_properties"):
            first_app = self.shares()[0].get("applications")[0]
            app = {
                "admin_url": "{}/applications/{}".format(
                    self.mng_url, first_app.get("_id")
                ),
                "creation_date": first_app.get("_created"),
                "last_update": first_app.get("_modified"),
                "name": first_app.get("name"),
                "type": first_app.get("type"),
                "kind": first_app.get("kind"),
                "url": first_app.get("url"),
            }
            self.app_properties = app
        else:
            pass
1301687
def plotly_app_identifier(name=None, slug=None, da=None, postfix=None):
    ''

    da, app = _locate_daapp(name, slug, da)

    slugified_id = app.slugified_id()

    if postfix:
        return "%s-%s" %(slugified_id, postfix)
    return slugified_id
94251
def get_id(self):
        '''
        
        '''
        if self._dxid is not None:
            return self._dxid
        else:
            return 'app-' + self._name + '/' + self._alias
688343
function extractRunId(app_id, mqtt_channel) {
    var pc = '/nutella/apps/' + app_id + '/runs/';
    var sp =  mqtt_channel.replace(pc, '').split('/');
    return sp[0];
}