public void GetCurrentTimestampMillisecondsShouldReturnCorrectResult() { var datetime = DateTime.UtcNow; var timestampinmiliseconds = UnixDateTimeHelpers.GetCurrentTimestampMilliseconds(); var convertedDatetime = UnixDateTimeHelpers.DateTimeFromUnixTimestampMilliseconds(timestampinmiliseconds); Assert.AreEqual(datetime.ToString(CultureInfo.InvariantCulture), convertedDatetime.UtcDateTime.ToString(CultureInfo.InvariantCulture)); }
public void DateTimeFromUnixTimestampMillisecondsShouldReturnCorrectDateTime() { var timestampinmiliseconds = 1544591489027; var datetime = (DateTimeOffset)DateTime.Parse("12/12/2018 5:11:29 AM +00:00"); var convertedDatetime = UnixDateTimeHelpers.DateTimeFromUnixTimestampMilliseconds(timestampinmiliseconds); Assert.AreEqual(datetime.UtcDateTime.ToString(CultureInfo.InvariantCulture), convertedDatetime.UtcDateTime.ToString(CultureInfo.InvariantCulture)); }
public async Task <RunResponse> _createRun(int experiementId, IMLFlowService flowService) { var experimentId = experiementId; var userId = "azadeh khojandi"; var runName = "this is a run name"; var sourceType = SourceType.NOTEBOOK; var sourceName = "String descriptor for the run’s source"; var entryPointName = "Name of the project entry point associated with the current run, if any."; var startTime = UnixDateTimeHelpers.GetCurrentTimestampMilliseconds(); //unix timestamp var path = Directory.GetCurrentDirectory(); var repopath = path.Substring(0, path.IndexOf("src", StringComparison.Ordinal)); var repo = new Repository(repopath); var lastcommit = repo.Commits.Last(); var sourceVersion = lastcommit.Sha; RunTag[] tags = { new RunTag() { Key = "testkey", Value = "testvalue" } }; //todo [az] run name is empty - check mlflow source code var createRunRequest = new CreateRunRequest() { ExperimentId = experimentId, UserId = userId, Runname = runName, SourceType = sourceType, SourceName = sourceName, EntryPointName = entryPointName, StartTime = startTime, SourceVersion = sourceVersion, Tags = tags }; var runResult = await flowService.CreateRun( createRunRequest); return(runResult); }
public async Task <LogMetric> LogMetric(string run_uuid, string key, float value, long?timeStamp = null) { if (!timeStamp.HasValue) { timeStamp = UnixDateTimeHelpers.GetCurrentTimestampMilliseconds(); } var response = await _httpService.Post <LogMetric, Dictionary <string, string> >( _getPath(MLFlowAPI.Runs.BasePath, MLFlowAPI.Runs.LogMetric), _getParameters( ("run_uuid", run_uuid), ("key", key), ("value", value.ToString()), ("timeStamp", timeStamp.ToString()) )); return(response); }
private IEnumerable <Column> GetColumns() { using (var stream = File.OpenRead(_reqionFilePath)) { var offsets = new List <int>(); var timestamps = new List <int>(); using (var reader = new BinaryReader(stream)) { for (int i = 0; i < SECTOR_INTS; i++) { int offset = reader.ReadInt32BE(); offsets.Add(offset); } for (int i = 0; i < SECTOR_INTS; i++) { int timestamp = reader.ReadInt32BE(); timestamps.Add(timestamp); } for (int i = 0; i < offsets.Count; i++) { if (offsets[i] == 0) { continue; } int sectorNumber = offsets[i] >> 8; int numSectors = offsets[i] & 0xFF; if (numSectors == 0) { continue; } stream.Seek(sectorNumber * SECTOR_BYTES, SeekOrigin.Begin); int length = reader.ReadInt32BE(); ChunkFormat format = (ChunkFormat)reader.ReadByte(); var data = reader.ReadBytes(length - 1); Column column = null; try { column = new Column(format, new MemoryStream(data), UnixDateTimeHelpers.ToDateTime(timestamps[i])); } catch (InvalidDataException) { //Ignore } if (column != null) { yield return(column); } } } } }