Azure / azure-sdk-for-python

This repository is for active development of the Azure SDK for Python. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/python/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-python.
MIT License
4.63k stars 2.84k forks source link

AzureML - sdk v2.0 - Rename Job from inner code #30102

Open FrsECM opened 1 year ago

FrsECM commented 1 year ago

Hello ! I'll use the bug template but it's maybe more a lack of documentation / information.

Describe the bug I'm working with azureml-sdk and i try to switch to azure-ai-ml.

In the past, i was naming my tensorboard logdir programatically in order to have an information about the date and to do the link between my azureml job and my output dir.

I was doing this way (from inside a job) :

class AMLTensorboardLogger(IDistributed):
    def __init__(self,rootLogDir='tb_results',LogDir_suffix='',logbatch:bool=False,log_freq:int=1):
        self.logname = datetime.now().strftime("%y%m%d_%H%M")+f"_{LogDir_suffix}"
        logdir=os.path.join(rootLogDir,self.logname)
        os.makedirs(logdir,exist_ok=True)
        self.logdir=logdir
        self.logbatch = logbatch
        self.logwriter=SummaryWriter(logdir)
        ###################################################################################
        ### We add this part in order to be able to run in AzureML Dashboard natively
        ###################################################################################
        if os.getenv('AZUREML_LOGGING'):
            print('Logging enable in AzureML Pipelines...')
            from azureml.core import Run
            current_run=Run.get_context()
            current_run:Run
            if 'Offline' not in current_run._run_id:
                self._azrun = current_run
                print(f'Run ID : {self._azrun._run_id}')
                current_run.display_name = f"AZRun - {self.logname}"
                print(f'Run Name : {current_run.display_name}')

To Reproduce NA

Expected behavior I would like a way to get the current run with the new SDK.

Screenshots In the bottom, you can see a job that have been renamed from inside it. I'd like to do this with sdk v2.0 but i don't know how. image

kashifkhan commented 1 year ago

Thank you for the feedback @FrsECM . We will investigate and get back to you asap.

cc @azureml-github

FrsECM commented 2 months ago

@kashifkhan, Do you have any update on this point ?

Thanks